This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug at getsockopt when TCP_NODELAY is used as parameter


Hi Jorge,

On Apr 27 11:05, jdzstz wrote:
> 
> While compiling varnish 3.0.5, I have detected a possible bug at
> getsockopt when TCP_NODELAY is used as parameter. The issue is
> caused because at cygwin it returns a BOOL, instead returning INT
> value like at Linux.

It's worse.  Officially these socket options return with an optlen ==
sizeof(BOOL) == sizeof(int).  If you look into all MSDN manual pages
related to getsockopt/setsockopt and their supported socket options,
they claim that the size of the options returning a boolean value are
sizeof(BOOL) == 4, or sizeof(DWORD) == 4.  And that's what they did
up to and including Windows XP and Windows 2003.

Only, starting with Windows Vista, getsockopt suddenly returned with
optlen set to 1, which is sizeof(BOOLEAN), the boolean type used by the
underlying kernel.  And this has never been fixed again.

Cygwin already handles this problem by converting the value to a
sizeof(int) value and changing optlen accordingly, but only for the
socket options SOL_SOCKET/SO_KEEPALIVE and SOL_SOCKET/SO_DONTROUTE.

I will fix that at one point, but I have to dig into that a bit more to
see which socket options have to be special-cased, or if this
special-casing can be radically simplified somehow.  Special-casing
dozens of socket options just to tweak the return type isn't exactly
fun.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgpW7RfUbT9JA.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]