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

Re: [PATCH] fix non interruptable hang in svn client when connecting

From: <kfogel_at_collab.net>
Date: 2005-08-25 18:02:18 CEST

Yun Zheng Hu <yunzheng.hu@gmail.com> writes:
> But here's how to reproduce the hanging process bug:
> Do the same command, but interrupt it with a ctrl-c (one or multiple
> times, doesnt matter):
> $ time svn co svn://svn.edgewall.com
> ^C
> This will result in a hanging process, at least on OS X.
> Its also not killable with a 'kill -9' after you interrupt it, because
> the signal_handler is setup to ignore future interrupts (SIG_IGN).
> Ofcourse you could not interrupt it and let it timeout properly, but
> usually the user knows he made a typo of some kind and want to kill
> the process asap.

Oh, I know, I reproduced it myself on Debian GNU/Linux too.

> The bug might also be related to apr_signal, but havent really tested yet.
> By setting a timeout on the socket the process will become killable
> again, the timeout can be 10 seconds or 4 minutes or whatever, as long
> as we have a timeout.
> If we dont set a timeout, the apr_connect function will use a blocking
> socket connect but does not timeout if the user sent an interrupt (the
> bug).
> If we do set a timeout it will be a nonblocking connect, and resort to
> apr_poll for proper timeout (see apr/network_io/unix/sockets.c).

In other words, it *becomes* interruptable *if* we set a timeout, on
Mac OS/X? That's interesting, and unexpected!

I tried the patch below (same as my earlier patch, but with a
different timeout length, and better comments), and it did not change
the interrupt behavior on Debian GNU/Linux for me. However, at least
it timed out much sooner.

I could easily believe that Mac OS/X and Linux behave differently in
this circumstance. I'm tempted to apply the patch anyway, therefore,
but first would like you to confirm the above summary of Mac OS/X


www.collab.net  <>  CollabNet  |  Distributed Development On Demand
Fix a bug whereby connecting to a non-existent repository can cause
apr_socket_connect() to hang non-interruptably.  To reproduce, try
'svn co svn://svn.edgewall.com'.
Patch by: Yun Zheng Hu <yunzheng.hu@gmail.com>
(Tweaked by me to use apr_socket_set_timeout instead of apr_setsocketopt.)
* subversion/libsvn_ra_svn/client.c
  (make_connection): Set socket timeout to 30 seconds.
Index: subversion/libsvn_ra_svn/client.c
--- subversion/libsvn_ra_svn/client.c	(revision 15904)
+++ subversion/libsvn_ra_svn/client.c	(working copy)
@@ -136,6 +136,22 @@
   if (status)
     return svn_error_wrap_apr(status, _("Can't create socket"));
+  /* Setting a timeout does more than just cause the attempt to fail
+     automatically after 30 seconds without success; it makes
+     apr_socket_connect() interruptable, which it otherwise would not
+     be, at least on Mac OS X.  See this message and thread for more:
+     http://subversion.tigris.org/servlets/ReadMsg?list=dev&msgNo=104587
+     From: Yun Zheng Hu <yunzheng.hu@gmail.com>
+     To: dev@subversion.tigris.org
+     Subject: [PATCH] fix non interruptable hang in svn client when connecting
+     Date: Thu, 25 Aug 2005 00:40:07 +0200
+     Message-ID: <df84014e05082415405cdd9b13@mail.gmail.com>
+  */
+  status = apr_socket_timeout_set(*sock, 30 * APR_USEC_PER_SEC);
+  if (status)
+    return svn_error_wrap_apr(status, _("Can't set timeout"));
   status = apr_socket_connect(*sock, sa);
   if (status)
     return svn_error_wrap_apr(status, _("Can't connect to host '%s'"),
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Aug 25 19:02:12 2005

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.