[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Handling aborted connections with ra_serf?

From: Justin Erenkrantz <justin_at_erenkrantz.com>
Date: 2006-10-30 00:07:37 CET

So, I'm now able to build ra_serf with Visual Studio 2005 and I've
seem to have gotten most of the kinks out (see my recent commits to
serf and ra_serf). I can do checkouts and commits fine, AFAICT, in my
limited tests.

There's one remaining nit and I'd like to get feedback from others as
there are two options and both are just as 'valid' - and this somewhat
applies to Unix and Win32 as well.

For some reason, ra_serf on Windows is prone to getting RST packets
from the upstream server. In my test case, I was going against
svn.collab.net and it happens about once per checkout of trunk. There
are a variety of valid reasons why we can get the RST: let's ignore
the cause of the server sending RST for the sake of this discussion.
(FWIW, my analysis of the protocol traces doesn't lead me to believe
ra_serf is doing anything wrong - httpd on the other end is sending
the RST - possibly because it's timeout expired on its end and it also
suffers from a lingering close buglet.)

Right now, when the connection is aborted like this, ra_serf will emit
a "Premature EOF seen from server" warning and error out. (N.B.
ra_dav if it hit this would emit this same error, but because it
combines everything into one giant request, it doesn't tend to hit
this as often as ra_serf does.)

The question is what should we do about an aborted connection? Should
ra_serf try again automatically, or should it error out?

Note that on Win32, this RST yields an aborted TCP connection -
however, unlike Unix, Win32 doesn't treat this any differently than a
normal FIN-driven close. So, instead of getting something like
ECONNRESET, Winsock just treats it as a normal EOF. But, on Linux
variants, it's handled slightly differently as we have the ECONNRESET
hint - so serf already has logic in place to silently retry the
aborted connection and requeue all outstanding requests - i.e. the
user doesn't have to do anything special - we already just retry on
Linux/POSIX platforms that give us that hint...

So, see the patch below to enable the retry on Win32. But, is this
the right thing to do? I'd like it to be consistent: either we retry
on all platforms when the server drops the connection, or we error out
and inform the user. A possible compromise is to retry only a limited
number of times (say 5 per session?) if we run into this condition;
but that doesn't quite feel 'right' either...

Thoughts? -- justin

Index: subversion/libsvn_ra_serf/util.c
===================================================================
--- subversion/libsvn_ra_serf/util.c (revision 22157)
+++ subversion/libsvn_ra_serf/util.c (working copy)
@@ -747,10 +747,7 @@
        */
       if (strcmp(ctx->method, "HEAD") != 0)
         {
- ctx->session->pending_error =
- svn_error_create(SVN_ERR_RA_DAV_MALFORMED_DATA, NULL,
- _("Premature EOF seen from server"));
- return ctx->session->pending_error->apr_err;
+ return APR_ECONNRESET;
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Oct 30 00:08:01 2006

This is an archived mail posted to the Subversion Dev mailing list.