diff --git a/ChangeLog b/ChangeLog index f03732872..a1d622de4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f03732872..a1d622de4 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f03732872..a1d622de4 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f03732872..a1d622de4 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f03732872..a1d622de4 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f03732872..a1d622de4 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +2003-08-25 Tor Lillqvist + + * glib/giowin32.c (read_thread): Avoid UNLOCKing the critical + section twice, which might cause a hang. (#120653) + + * glib/giowin32.c (g_io_channel_unix_new): Warn if fd is both a + valid file descriptor and socket. + + * glib/trio/trio.c: Use and USE_LOCALE also on + Windows. (#115286, Ernst Lippe) + Mon Aug 25 12:17:20 2003 Owen Taylor * glib/gmain.c (g_main_context_unref_and_unlock): diff --git a/glib/giowin32.c b/glib/giowin32.c index b7336a8f7..dde72e71e 100644 --- a/glib/giowin32.c +++ b/glib/giowin32.c @@ -234,9 +234,9 @@ read_thread (void *parameter) SetEvent (channel->space_avail_event); + LOCK (channel->mutex); while (channel->running) { - LOCK (channel->mutex); if (channel->debug) g_print ("read_thread %#x: rdp=%d, wrp=%d\n", channel->thread_id, channel->rdp, channel->wrp); @@ -294,7 +294,6 @@ read_thread (void *parameter) g_print ("read_thread %#x: rdp=%d, wrp=%d, setting data_avail\n", channel->thread_id, channel->rdp, channel->wrp); SetEvent (channel->data_avail_event); - UNLOCK (channel->mutex); } channel->running = FALSE; @@ -1604,14 +1603,22 @@ g_io_channel_win32_new_socket (int socket) GIOChannel * g_io_channel_unix_new (gint fd) { + gboolean is_fd, is_socket; struct stat st; int optval, optlen; - if (fstat (fd, &st) == 0) - return g_io_channel_win32_new_fd_internal (fd, &st); - + is_fd = (fstat (fd, &st) == 0); + optlen = sizeof (optval); - if (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &optval, &optlen) != SOCKET_ERROR) + is_socket = (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &optval, &optlen) != SOCKET_ERROR); + + if (is_fd && is_socket) + g_warning (G_STRLOC ": %d is both a file descriptor and a socket, file descriptor interpretation assumed.", fd); + + if (is_fd) + return g_io_channel_win32_new_fd_internal (fd, &st); + + if (is_socket) return g_io_channel_win32_new_socket(fd); g_warning (G_STRLOC ": %d is neither a file descriptor or a socket", fd); diff --git a/glib/trio/trio.c b/glib/trio/trio.c index 676d1246b..c0f122606 100644 --- a/glib/trio/trio.c +++ b/glib/trio/trio.c @@ -125,6 +125,8 @@ # include #endif #if defined(TRIO_PLATFORM_WIN32) +# include +# define USE_LOCALE # include # define read _read # define write _write