Re: Windows binaries for GLib-2.2.2, GTK+-2.2.2, GIMP-1.2.5 etc



 >  > g_io_channel_unix_new is broken in GLib-2.2.2:
 >  > 
 >  > (glib_io_demo.exe:1096): GLib-WARNING **: giowin32.c:1500: 520 is
 >  > neither a file descriptor or a socket

Yes. It turns out that the call to getsockopt():

  if (getsockopt (fd, SOL_SOCKET, SO_TYPE, NULL, NULL) != SOCKET_ERROR)
    return g_io_channel_win32_new_socket(fd);

fails with WSAGetLastError() == WSAEFAULT. The docs clearly say that
this means "One of the optval or the optlen parameters is not a valid
part of the user address space, or the optlen parameter is too small."

The code doesn't use the socket type information for anything, which
probably explains why I used NULL for the &optval and &optlen
arguments. But that's not OK. It should be:

  int optval, optlen;
  ...  
  optlen = sizeof (optval);
  if (getsockopt (fd, SOL_SOCKET, SO_TYPE, (char *) &optval, &optlen) != SOCKET_ERROR)
    return g_io_channel_win32_new_socket(fd);

Fix committed to HEAD and glib-2-2.

How this wasn't noticed earlier is probably explained by this
ChangeLog entry:

2003-02-04  Tor Lillqvist  <tml iki fi>

	* glib/giowin32.c (g_io_channel_unix_new): Fix typo: Should be
	SOCKET_ERROR, not SO_ERROR. Noticed by Daniel Kaufmann.

I.e. before that change, the getsockopt() failed and returned
SOCKET_ERROR, like it does in 2.2.2, but it wasn't noticed as the
return value was compared to SO_ERROR, so in the end passing a socket
to g_io_channel_unix_new() worked anyway in 2.2.1...

--tml





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]