X-Recipient: archive-cygwin@delorie.com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:from:date:message-id:subject:to
	:content-type; q=dns; s=default; b=bG5Tvci8z8uxeEy6v4UfzSZ/pAMs0
	9PSyTmJLy0Pj8EX1XM227CO1FkD7jBEte8gsCZNkHr4TXP7WI48jiBkdutZuLEtS
	1RYIh9FvzCIL3wUnm1Nv4hMHg0n5B9W9SNqs3yhCM0JVhWC7Rmal9LcoLNX4r/jN
	P3i8SwXb7ql5c8=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
	:list-unsubscribe:list-subscribe:list-archive:list-post
	:list-help:sender:mime-version:from:date:message-id:subject:to
	:content-type; s=default; bh=hfIQhSUn34zw5Q73OfPLV5h9kI0=; b=c68
	v4yYNUm1wufMQ/zWNTtqVqb0WGYnNqdIoUhITr2SR/Sxs28h+uaV0mc0J7NImtai
	7ilAK1ssRhvcG8EVuJykhPDj+HFDNSFLmRwuo2v3+Lvm20Ow0ZnoWQgAMRUPYGm4
	gvUy7j3qRDzwFVCK04jSfi9n/ggP1mohKvxZSqEU=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=UD:It, Hx-languages-length:1132, browser
X-HELO: mail-it0-f47.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=1e100.net; s=20130820;        h=x-gm-message-state:mime-version:from:date:message-id:subject:to;        bh=XNbTWN49+TyQiRg1RM3AjgSAV6eI0pQrLg+VpKT6a8Y=;        b=elYTka2JmDNaOJUevocKPI59cu8KH2cXqo4fNmIAUpphSV4ZLbZviuOpKFYtbjNdAk         tZ7tlloU7PWUttSE8PjVrlfHr/NW+eqOsszD3sU0iavQEsKkEO5ByOi/8LDUXa9OBZcc         RJv63T0EyOm/usMRmKkrR+2+Z7yfObZCm5h/tp0BHhxHQO0IeVair/ZSHr+LMcYfnJlj         9Rneg122ukmkIUwqZ/o+S9ptC2nLfRawBGc5WF7J5GuwSVwJjJ+7F6MYefRkxSQz8nt6         MLAl5tu6AzFupzKz2xbRx34E8MzHQaf+IGUIgn9XirMjU+oaH8r/zUiR0K5owtF+560u         eKbQ==
X-Gm-Message-State: AEkoousdpNlHmPNF+vJsr5z4JYOw0LBwm2vfQLuBMD2pyP389p7pO6iBO2eoeDrggk/Y7QpSKpRhcdpLPND5LA==
X-Received: by 10.36.127.75 with SMTP id r72mr16084671itc.55.1471286063958; Mon, 15 Aug 2016 11:34:23 -0700 (PDT)
MIME-Version: 1.0
From: Pankaj Yadav <pankajdnapster@gmail.com>
Date: Tue, 16 Aug 2016 00:04:23 +0530
Message-ID: <CAAPqxJx+EPpzESWMOXowp3grKubWJJ7n93ftFPK1L3MKWkqrLQ@mail.gmail.com>
Subject: On WIN7, write() not returning immediately even on non-blocking sockets
To: cygwin@cygwin.com
Content-Type: text/plain; charset=UTF-8
X-IsSubscribed: yes

Hi,
We have a proxy server type of program which has an infinite loop
writing to sockets with write() call.

All of the sockets are set to non-blocking mode.It works fine on linux
and all windows versions except win7(both 32 and 64 bit).We tested on
hundreds of computers.

The code where it gets stuck is

printf("Nonblocking:%d\n",(fcntl(t_qelem->respsock, F_GETFL, 0) &
O_NONBLOCK))?1:0;
i = write(t_qelem->respsock,&t_qelem->webtoresp[t_qelem->webtorespsent],t_qelem->webtoresplen-t_qelem->webtorespsent);
printf("written\n");

Output is :  Non-blocking:1 and then it does NOT print "written" ever.

I also tried to do some debugging using gdb.
write() -> send_internal()  ->{looping through fhandler_socket::wait_for_events}
even when the socket is set to blocking mode.

I am ignoring SIGPIPEs but I know that it probably happens only when
the connection has closed from the other side coz it happens when i
close the browser which is using this proxy software.Can you please
help me out, if i am doing something wrong.

Thanks
-- 
--
Regards
Pankaj Yadav

--
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

