Status Query - Please respond - Re: Patch to avoid 'Connection reset by peer' error for rsync on cygwin

Max Bowsher maxb at
Fri May 10 03:43:03 EST 2002

Martin Pool <mbp at> wrote:
> Sorry, I've been out of town this week.

No problem.

> This is the shutdown one, right?  I wanted to check about portability
> before we put it in.  Snader's "Effective TCP/IP Programming" says that
>   shutdown(fd, 1);
> is OK on both Unix and Windows and will avoid errors from closing the
> socket.  So I think it's OK to put it in.  Winsock misinterprets other
> values of the second parameter so we can't use them.

Yes, this is the shutdown one. This issue certainly does not require any other
shutdown second parameter, so we are safe there.

> I don't understand why you need to only insert this call here and
> not in every case where a socket is closed.  If there's no specific
> reason we should have a common shutdownsocket() routine and call it;
> if there is a reason we should document it.

Kludginess. I did the quickest fix to the immediate problem I had, which didn't
require me to trace through the lifetime of all socket handles used everywhere
in rsync. The problem was especially severe here, because rsync didn't even
close the socket in these cases - it would write its last data, then return a
couple of times, and exit().

We could have a shutdownsocket(). Is it worth it for just for 2 lines of code?
shutdown(fd, SHUT_WR);

If you say yes, then fair enough.

In any case, I will study the rsync code in greater detail, and produce a patch
covering every case a socket is closed.


PS: Someone mentioned that 2.5.6 has branched in CVS. I'm a bit of a CVS newbie
unfortunately - what is the command for 'what branches exist in the repository?'

More information about the rsync mailing list