X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Message-ID: <4D77D923.1090508@tweerlei.de> Date: Wed, 09 Mar 2011 20:46:43 +0100 From: Robert Wruck 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 AT cygwin DOT com Subject: Re: 1.7.8: write fails with EAGAIN References: <4D72992D DOT 4090007 AT tweerlei DOT de> <20110307103951 DOT GL6393 AT calimero DOT vinschen DOT de> <4D77C5CB DOT 1040909 AT tweerlei DOT de> <4D77C9C8 DOT 2000802 AT cygwin DOT com> <4D77CCC4 DOT 3070406 AT tweerlei DOT de> <4D77CF7F DOT 7090009 AT tweerlei DOT de> In-Reply-To: <4D77CF7F.7090009@tweerlei.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com >> I replaced the cygwin1.dll with cygwin1-20110309.dll and now a single >> write() with 78 MB never returns but seems to write repeatedly to the >> pipe (file was 5GB when I hit Ctrl-C). Just terminating the loop after write_overlapped_fallback is not enough. When the size to write exceeds MAX_OVERLAPPED_WRITE_LEN and WriteFile fails for MAX_OVERLAPPED_WRITE_LEN, write() will always return 0. In case of overlapped_error, nbytes should be set to -1. I'd suggest to remove write_overlapped_fallback and instead decrement 'len' on each failure. Since write is not guaranteed to write the whole data, this should be OK. do { bool res = WriteFile (get_output_handle (), ptr, len, &nbytes, get_overlapped ()); switch (wait_overlapped (res, true, &nbytes, is_nonblocking (), (size_t) len)) { case overlapped_fallback: len /= 4; /* feel free to tune */ if (!len) { set_errno (ENOSPC); /* Can't write anything */ nbytes = (DWORD) -1; /* Don't forget */ keep_looping = false; break; } /* fall through intentionally */; case overlapped_signal: keep_looping = true; break; default: /* Added to quiet gcc */ case overlapped_error: nbytes = (DWORD) -1; /* Don't forget */ /* fall through intentionally */; case overlapped_success: keep_looping = false; break; } } while (keep_looping); Result (from the application's perspective) is: writing 78954543 bytes... result is 19738635, errno is 0 writing 59215908 bytes... result is 14803977, errno is 0 writing 44411931 bytes... result is 11102982, errno is 0 writing 33308949 bytes... result is 8327237, errno is 0 writing 24981712 bytes... result is 24981712, errno is 0 -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