GIOChannel subclassing in libsoup

(I initially sent this do Dan Winship only, but I assume it is better
to have technical discussion like this on the list.)

I think I have noticed a fundamental portability problem in how
libsoup derives its SoupGNUTLSChannel from GIOChannel. I guess it is
not an accident that the int fd field of the SoupGNUTLSChannel struct
"happens" to be after the GIOChannel channel field? I.e. the start of
the SoupGNUTLSChannel struct matches exactly the layout of the
"private" GIOUnixChannel struct in giounix.c. And in
soup_ssl_wrap_iochannel() the fd field is initialized to be what
g_io_channel_unix_get_fd() returns for the wrapped GIOChannel, i.e.
the fd field of the GIOUnixChannel.

So, on Unix, calling one of the GIOFuncs functions of real_sock,
passing it the SoupGNUTLSChannel, is not a problem, as to the
functions in giounix.c, the SoupGNUTLSChannel will look and work just
like a GIOUnixChannel.

But... on Windows, the GIOWin32Channel struct in giowin32.c has a lot
more fields than just fd. Surely it cannot work to call GIOFuncs
functions from giowin32.c and pass them a pointer to a
SoupGNUTLSChannel when they expect a GIOWin32Channel.

But still, the SSL wrapping of socket GIOChannels does apparently work
to a certain extent, in some cases, on Windows. I manage to connect to
a groupwise server from Evolution, and that uses SSL wrapping in
libsoup, to the best of my knowledge. I guess this is because not all
use of this goes through the problematic functions in soup-gnutls.c.
(soup_gnutls_read() and soup_gnutls_write() are not problematic, but
the other ones are.)

Does what I say make any sense? I clearly need to think harder and add
debugging printouts to this stuff and pour over the output to
understand what is really going on...

(Now I think I recall that I wondered about this exact issue already a
couple of years ago. But that was just at the time I stopped working
on Evolution for Windows, so I didn't need to peruse it further
then... Now I am again spending some time on Evolution.)


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