delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2010/07/02/10:37:02

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Fri, 2 Jul 2010 16:36:45 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: R: getsockopt(SO_KEEPALIVE) returns incorrect option length
Message-ID: <20100702143645.GD8163@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <i0kb3m$r25$1 AT dough DOT gmane DOT org> <472084 DOT 52146 DOT qm AT web25505 DOT mail DOT ukl DOT yahoo DOT com> <i0kina$nq9$1 AT dough DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <i0kina$nq9$1@dough.gmane.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Jul  2 13:31, Pavel Holejsovsky wrote:
> On 7/2/2010 12:01 PM, Marco Atzeri wrote:
> >--- Ven 2/7/10, Pavel Holejsovsky ha scritto:
> >
> >>Hi,
> >>
> >>I think that following problem shows problematic behavior
> >>in cygwin 1.7.5, at least incompatible with linux:
> >>
> >>#include<stdio.h>
> >>#include<sys/socket.h>
> >>
> >>int main() {
> >>         int sock, option, optlen =
> >>sizeof(int);
> >>         sock = socket(AF_INET,
> >>SOCK_STREAM, 0);
> >>         getsockopt(sock, SOL_SOCKET,
> >>SO_KEEPALIVE,&option,&optlen);
> >>         printf("option=%d,
> >>optlen=%d\n", option, optlen);
> >>         return 0;
> >>}
> >>
> >>Prints optlen=1, while it is expected to be sizeof(int),
> >>i.e. 4.
> >>
> >>This is most probably because uinderlying winsock call has
> >>this (mis)behavior, but I think that in cygwin layer this
> >>could be worked around to be more unix compatible.
> >>
> >>This issue is relevant:
> >>
> >>SO_KEEPALIVE value is actually a char on Windows, not BOOL
> >>https://bugzilla.gnome.org/show_bug.cgi?id=611756
> >>
> >>And causes glib gio 2.24 to fail certain socket operations
> >>on cygwin.
> >>
> >>thanks,
> >>Pavel
> >
> >option=0, optlen=4
> >
> >on XP-sp2, cygwin 1.7.5s(0.227/5/3) 20100628
> >
> 
> Thanks for testing, Marco.
> 
> So it is even system-dependent misbehaviour of winsock.  On w7-x64
> cygwin 1.7.5 it prints
> option=2674688, optlen=1

Looks like a Windows regression.  I can reproduce optlen=1 on Vista
and W7, while I also get optlen=4 on XP.

I tested this a bit further and checked the other BSD-compatible
SOL_SOCKET options which use int as return type in BSD and BOOL in
Winsock.  It turns out that starting with Vista the SO_DONTROUTE option
is also wrongly returning just a one byte value with optlen set to 1.
I assume somebody changed something accidentally from BOOL to BOOLEAN in
the Winsock sources.

I'll added a workaround to Cygwin.


Thanks for the report,
Corinna

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

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019