Re: [PATCH] Fix checkout of large files to network shares under Windows XP
- From
- Albert Dvornik <dvornik+git@gmail.com>
- Date
- Apr 19, 2010, 22:46 UTC
- Message-ID
- <z2l9f74dc2c1004191546n5562759an54342e3efdaa9539@mail.gmail.com>
- In-Reply-To
- <4BCCC05E.4030206@lsrfire.ath.cx>
On Mon, Apr 19, 2010 at 4:43 PM, René Scharfe <rene.scharfe@lsrfire.ath.cx> wrote: [...]
Show 8 quoted lines
>> + if (total + size > count) >> + size = count - total; >> + } >> + } > > Shouldn't the loop be left in the successful case, too? write(2) is > allowed to write less than requested, so the caller already needs to > deal with that case anyway.
That's what I thought initially, since the code would be cleaner, but I don't like the fact that you could actually end up making a lot more failed write() calls that way, since you restart the size search on each call to mingw_write().
For example, suppose you were calling mingw_write() with a count that was exactly 11.5 times bigger than whatever maximum size write() was willing to accept. If you only did one write() per mingw_write(), letting the caller restart, this will result in 47 failed writes and 16 successes. Letting mingw_write() do the restart (as in the existing code) will end up with 4 failed writes and 16 successes. Now, I assume (wait, this is Windows-- I'd *like to hope*) that a failed write() is a lot cheaper than a successful one, but this still rubs me the wrong way.
Of course, if we know (or can guess) the maximum size write() will take, that would be best.
--bert