Re: Win32 Glib 2.8.x g_io_channel issues (receiving window messages on socket io channel)
- From: Tor Lillqvist <tml iki fi>
- To: gtk-app-devel-list gnome org
- Subject: Re: Win32 Glib 2.8.x g_io_channel issues (receiving window messages on socket io channel)
- Date: Wed, 16 Nov 2005 08:37:02 +0200
I fixed that (and what do you know... it works!). Thanks for noticing.
Good to hear!
Should I make an attempt at the changes to giowin32.c, or is that
something you've already got sorted out?
See the patch below that clears up some of the issues: 1) After
getting FD_CLOSE, make the knowledge of that "stick" and always set
G_IO_HUP. 2) Plug a handle leak, WSACloseEvent the socket's event when
the channel is closed.
If you can build GLib yourself, please try it.
Index: glib/giowin32.c
===================================================================
RCS file: /cvs/gnome/glib/glib/giowin32.c,v
retrieving revision 1.65.2.1
diff -p -u -2 -r1.65.2.1 giowin32.c
--- glib/giowin32.c 8 Nov 2005 08:35:50 -0000 1.65.2.1
+++ glib/giowin32.c 15 Nov 2005 19:52:02 -0000
@@ -109,6 +109,7 @@ struct _GIOWin32Channel {
int event_mask;
int last_events;
- int event;
+ WSAEVENT event;
gboolean write_would_have_blocked;
+ gboolean close_event_received;
};
@@ -353,4 +354,5 @@ g_io_channel_win32_init (GIOWin32Channel
channel->event = 0;
channel->write_would_have_blocked = FALSE;
+ channel->close_event_received = FALSE;
InitializeCriticalSection (&channel->mutex);
}
@@ -679,5 +678,5 @@ g_io_win32_check (GSource *source)
channel->fd, watch->pollfd.fd);
}
- else
+ else if (watch->pollfd.revents)
{
WSAEnumNetworkEvents (channel->fd, 0, &events);
@@ -711,5 +710,7 @@ g_io_win32_check (GSource *source)
if (channel->last_events & (FD_WRITE | FD_CONNECT))
watch->pollfd.revents |= G_IO_OUT;
- if (watch->pollfd.revents == 0 && (channel->last_events & (FD_CLOSE)))
+ if (channel->last_events & (FD_CLOSE))
+ channel->close_event_received = TRUE;
+ if (channel->close_event_received)
watch->pollfd.revents |= G_IO_HUP;
@@ -879,5 +875,9 @@ g_io_win32_free (GIOChannel *channel)
CloseHandle (win32_channel->space_avail_event);
if (win32_channel->type == G_IO_WIN32_SOCKET)
- WSAEventSelect (win32_channel->fd, NULL, 0);
+ {
+ WSAEventSelect (win32_channel->fd, NULL, 0);
+ if (win32_channel->event)
+ WSACloseEvent (win32_channel->event);
+ }
DeleteCriticalSection (&win32_channel->mutex);
@@ -1259,7 +1259,7 @@ g_io_win32_sock_create_watch (GIOChannel
if (win32_channel->event == 0)
- win32_channel->event = (int) WSACreateEvent ();
+ win32_channel->event = WSACreateEvent ();
- watch->pollfd.fd = win32_channel->event;
+ watch->pollfd.fd = (int) win32_channel->event;
watch->pollfd.events = condition;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]