X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-1.0 required=5.0	tests=AWL,BAYES_20,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
Message-ID: <4D77C5CB.1040909@tweerlei.de>
Date: Wed, 09 Mar 2011 19:24:11 +0100
From: Robert Wruck <wruck@tweerlei.de>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.16) Gecko/20101125 Lightning/1.0b1 Thunderbird/3.0.11
MIME-Version: 1.0
To: cygwin@cygwin.com
Subject: Re: 1.7.8: write fails with EAGAIN
References: <4D72992D.4090007@tweerlei.de> <20110307103951.GL6393@calimero.vinschen.de>
In-Reply-To: <20110307103951.GL6393@calimero.vinschen.de>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
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

Hi,

> Hang on, you are saying that a *blocking* write(2) to a pipe returns
> with EAGAIN?  Are you sure?  It would be quite a surprise if git would
> actually do that.  EAGAIN is only an expected error for non-blocking
> I/O, so applications which use blocking I/O usually only test for EINTR.

I checked out the winsup sources and built a cygwin1.dll for debugging 
(btw: Could you update the FAQ to state that gcc4 is required instead of 
gcc?).

What I found out:

In fhandler.cc, write_overlapped, there is the call to WriteFile:

	bool res = WriteFile (get_output_handle (), ptr, len, &nbytes,
			      get_overlapped ());

Surprisingly, this returns FALSE / nbytes = 0 / GetLastError = 
ERROR_INVALID_HANDLE on WinXP if the number of bytes exceeds some 
maximum and the handle refers to a pipe.
Since you don't know what kind of handle you're writing to in 
write_overlapped, it seems reasonable to do the write in chunks.

The first comment to WriteFile 
(http://msdn.microsoft.com/en-us/library/aa365747%28v=vs.85%29.aspx) 
suggests to limit the size to less than 32MB per write - although I 
didn't have this problem on X64.

-Robert

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

