mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-03 17:48:56 +01:00 
			
		
		
		
	Avoid UNLOCKing the critical section twice, which might cause a hang.
2003-08-25 Tor Lillqvist <tml@iki.fi> * 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 <locale.h> and USE_LOCALE also on Windows. (#115286, Ernst Lippe)
This commit is contained in:
		
				
					committed by
					
						
						Tor Lillqvist
					
				
			
			
				
	
			
			
			
						parent
						
							89628b345b
						
					
				
				
					commit
					6e733d34d2
				
			
							
								
								
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ChangeLog
									
									
									
									
									
								
							@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,14 @@
 | 
			
		||||
2003-08-25  Tor Lillqvist  <tml@iki.fi>
 | 
			
		||||
 | 
			
		||||
	* 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 <locale.h> and USE_LOCALE also on
 | 
			
		||||
	Windows. (#115286, Ernst Lippe)
 | 
			
		||||
 | 
			
		||||
Mon Aug 25 12:17:20 2003  Owen Taylor  <otaylor@redhat.com>
 | 
			
		||||
 | 
			
		||||
	* glib/gmain.c (g_main_context_unref_and_unlock): 
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -125,6 +125,8 @@
 | 
			
		||||
# include <unistd.h>
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(TRIO_PLATFORM_WIN32)
 | 
			
		||||
# include <locale.h>
 | 
			
		||||
# define USE_LOCALE
 | 
			
		||||
# include <io.h>
 | 
			
		||||
# define read _read
 | 
			
		||||
# define write _write
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user