mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-13 15:56:23 +01:00
When WSAEnumNetworkEvents() signals FD_CONNECT that means that the
2007-07-06 Tor Lillqvist <tml@novell.com> * glib/giowin32.c (g_io_win32_check): When WSAEnumNetworkEvents() signals FD_CONNECT that means that the connection attempt finished, either successfully or failed. Test explicitly whether the connnection succeeded and set either G_IO_OUT if it did, G_IO_ERR|G_IO_HUP if it failed. Make sure we never set both G_IO_OUT and G_IO_HUP simultaneously because in Unix poll(2) POLLOUT and POLLHUP are mutually exclusive. Ignore whether the caller wants to watch G_IO_HUP or not. Always select for FD_CLOSE because Unix poll(2) also ignores whether POLLHUP in set the requested events bitmask or not. svn path=/trunk/; revision=5600
This commit is contained in:
parent
36dab3af81
commit
09d6197943
16
ChangeLog
16
ChangeLog
@ -1,3 +1,19 @@
|
|||||||
|
2007-07-06 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
|
* glib/giowin32.c (g_io_win32_check): When WSAEnumNetworkEvents()
|
||||||
|
signals FD_CONNECT that means that the connection attempt
|
||||||
|
finished, either successfully or failed. Test explicitly whether
|
||||||
|
the connnection succeeded and set either G_IO_OUT if it did,
|
||||||
|
G_IO_ERR|G_IO_HUP if it failed.
|
||||||
|
|
||||||
|
Make sure we never set both G_IO_OUT and G_IO_HUP simultaneously
|
||||||
|
because in Unix poll(2) POLLOUT and POLLHUP are mutually
|
||||||
|
exclusive.
|
||||||
|
|
||||||
|
Ignore whether the caller wants to watch G_IO_HUP or not. Always
|
||||||
|
select for FD_CLOSE because Unix poll(2) also ignores whether
|
||||||
|
POLLHUP in set the requested events bitmask or not.
|
||||||
|
|
||||||
Fri Jun 29 2007 Matthias Clasen <mclasen@redhat.com>
|
Fri Jun 29 2007 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
* configure.in: Bump version
|
* configure.in: Bump version
|
||||||
|
@ -822,8 +822,7 @@ g_io_win32_prepare (GSource *source,
|
|||||||
event_mask |= (FD_READ | FD_ACCEPT);
|
event_mask |= (FD_READ | FD_ACCEPT);
|
||||||
if (watch->condition & G_IO_OUT)
|
if (watch->condition & G_IO_OUT)
|
||||||
event_mask |= (FD_WRITE | FD_CONNECT);
|
event_mask |= (FD_WRITE | FD_CONNECT);
|
||||||
if (watch->condition & G_IO_HUP)
|
event_mask |= FD_CLOSE;
|
||||||
event_mask |= FD_CLOSE;
|
|
||||||
|
|
||||||
if (channel->event_mask != event_mask /* || channel->event != watch->pollfd.fd*/)
|
if (channel->event_mask != event_mask /* || channel->event != watch->pollfd.fd*/)
|
||||||
{
|
{
|
||||||
@ -936,13 +935,32 @@ g_io_win32_check (GSource *source)
|
|||||||
watch->pollfd.revents = 0;
|
watch->pollfd.revents = 0;
|
||||||
if (channel->last_events & (FD_READ | FD_ACCEPT))
|
if (channel->last_events & (FD_READ | FD_ACCEPT))
|
||||||
watch->pollfd.revents |= G_IO_IN;
|
watch->pollfd.revents |= G_IO_IN;
|
||||||
if (channel->last_events & (FD_WRITE | FD_CONNECT))
|
if (channel->last_events & FD_WRITE)
|
||||||
watch->pollfd.revents |= G_IO_OUT;
|
watch->pollfd.revents |= G_IO_OUT;
|
||||||
if (watch->pollfd.revents == 0 && (channel->last_events & (FD_CLOSE)))
|
else
|
||||||
watch->pollfd.revents |= G_IO_HUP;
|
{
|
||||||
|
/* We have called WSAEnumNetworkEvents() above but it didn't
|
||||||
|
* set FD_WRITE.
|
||||||
|
*/
|
||||||
|
if (events.lNetworkEvents & FD_CONNECT)
|
||||||
|
{
|
||||||
|
if (events.iErrorCode[FD_CONNECT_BIT] == 0)
|
||||||
|
watch->pollfd.revents |= G_IO_OUT;
|
||||||
|
else
|
||||||
|
watch->pollfd.revents |= (G_IO_HUP | G_IO_ERR);
|
||||||
|
}
|
||||||
|
if (watch->pollfd.revents == 0 && (channel->last_events & (FD_CLOSE)))
|
||||||
|
watch->pollfd.revents |= G_IO_HUP;
|
||||||
|
}
|
||||||
|
|
||||||
if (!channel->write_would_have_blocked && (channel->event_mask & FD_WRITE))
|
/* Regardless of WSAEnumNetworkEvents() result, if watching for
|
||||||
watch->pollfd.revents |= G_IO_OUT; /* This sucks but... */
|
* writability, unless last write would have blocked set
|
||||||
|
* G_IO_OUT. But never set both G_IO_OUT and G_IO_HUP.
|
||||||
|
*/
|
||||||
|
if (!(watch->pollfd.revents & G_IO_HUP) &&
|
||||||
|
!channel->write_would_have_blocked &&
|
||||||
|
(channel->event_mask & FD_WRITE))
|
||||||
|
watch->pollfd.revents |= G_IO_OUT;
|
||||||
|
|
||||||
return ((watch->pollfd.revents | buffer_condition) & watch->condition);
|
return ((watch->pollfd.revents | buffer_condition) & watch->condition);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user