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

[PATCH] Re: timeout on report

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2002-10-25 14:27:18 CEST

Philip Martin <philip@codematters.co.uk> writes:

> I wonder if this
> should be configurable in the config file, just like the proxy?

It's quite easy to put this in the proxies file. Does anyone feel it
is an abuse of that file? I'm not sure I'd want more than one file
specifying paramaters on a per-host basis, so the proxies file seems
the best one to me.

Make neon session timeout configurable.

* subversion/libsvn_ra_dav/session.c
  (get_proxy_and_timeout): Renamed from get_proxy. Now gets timeout value
  as well.
  (svn_ra_dav__open): Set neon timeout.

* subversion/libsvn_subr/config_file.c (svn_config_ensure): Add timeout
  to initial config file text.

* subversion/include/svn_error_codes.h (SVN_ERR_RA_DAV_INVALID_TIMEOUT): New
  error.

Index: ../svn/subversion/include/svn_error_codes.h
===================================================================
--- ../svn/subversion/include/svn_error_codes.h (revision 3495)
+++ ../svn/subversion/include/svn_error_codes.h (working copy)
@@ -525,6 +525,10 @@
               SVN_ERR_RA_DAV_CATEGORY_START + 5,
               "RA layer file already exists")
 
+ SVN_ERRDEF (SVN_ERR_RA_DAV_INVALID_TIMEOUT,
+ SVN_ERR_RA_DAV_CATEGORY_START + 6,
+ "invalid timeout")
+
   /* ra_local errors */
   
   SVN_ERRDEF (SVN_ERR_RA_LOCAL_REPOS_NOT_FOUND,
Index: ../svn/subversion/libsvn_subr/config_file.c
===================================================================
--- ../svn/subversion/libsvn_subr/config_file.c (revision 3495)
+++ ../svn/subversion/libsvn_subr/config_file.c (working copy)
@@ -642,7 +642,8 @@
       apr_file_t *f;
       const char *contents =
         "### This file determines which proxy servers to use, if\n"
- "### any, when contacting a remote repository.\n"
+ "### any, when contacting a remote repository and the duration\n"
+ "### of the timeout waiting for a response from the server.\n"
         "###\n"
         "### The commented-out examples below are intended only to\n"
         "### demonstrate how to use this file; any resemblance to\n"
@@ -663,6 +664,7 @@
         "# port = 80\n"
         "# username = blah\n"
         "# password = doubleblah\n"
+ "# timeout = 60\n"
         "\n"
         "### Information for the second group:\n"
         "# [othergroup]\n"
Index: ../svn/subversion/libsvn_ra_dav/session.c
===================================================================
--- ../svn/subversion/libsvn_ra_dav/session.c (revision 3495)
+++ ../svn/subversion/libsvn_ra_dav/session.c (working copy)
@@ -188,26 +188,25 @@
     return TRUE;
 }
 
-
-/* Set *PROXY_HOST, *PROXY_PORT, *PROXY_USERNAME, and *PROXY_PASSWORD
- * to the proxy information for REQUESTED_HOST, allocated in POOL, if
- * there is any applicable information. If there is no applicable
- * information or if there is an error, then set *PROXY_PORT to
- * (unsigned int) -1 and the rest to NULL. This function can return
- * an error, so before checking *PROXY_*, check for error return
- * value.
+/* Set *PROXY_HOST, *PROXY_PORT, *PROXY_USERNAME, *PROXY_PASSWORD and
+ * *TIMEOUT_SECONDS to the proxy information for REQUESTED_HOST, allocated
+ * in POOL, if there is any applicable information. If there is no
+ * applicable information or if there is an error, then set *PROXY_PORT to
+ * (unsigned int) -1 and the rest to NULL. This function can return an
+ * error, so before checking *PROXY_*, check for error return value.
  */
-static svn_error_t *get_proxy(const char **proxy_host,
- unsigned int *proxy_port,
- const char **proxy_username,
- const char **proxy_password,
- const char *requested_host,
- apr_pool_t *pool)
+static svn_error_t *get_proxy_and_timeout(const char **proxy_host,
+ unsigned int *proxy_port,
+ const char **proxy_username,
+ const char **proxy_password,
+ int *timeout_seconds,
+ const char *requested_host,
+ apr_pool_t *pool)
 {
   struct search_groups_baton gb;
   svn_config_t *cfg;
   const char *exceptions;
- const char *port_str;
+ const char *port_str, *timeout_str;
 
   /* If we find nothing, default to nulls. */
   *proxy_host = NULL;
@@ -215,6 +214,7 @@
   *proxy_username = NULL;
   *proxy_password = NULL;
   port_str = NULL;
+ timeout_str = NULL;
 
   SVN_ERR( svn_config_read_proxies(&cfg, pool) );
 
@@ -227,6 +227,7 @@
       svn_config_get(cfg, &port_str, "default", "port", NULL);
       svn_config_get(cfg, proxy_username, "default", "username", NULL);
       svn_config_get(cfg, proxy_password, "default", "password", NULL);
+ svn_config_get(cfg, &timeout_str, "default", "timeout", NULL);
     }
 
   /* Search for a proxy pattern specific to this host. */
@@ -243,6 +244,10 @@
                      *proxy_username);
       svn_config_get(cfg, proxy_password, gb.proxy_group, "password",
                      *proxy_password);
+ svn_config_get(cfg, proxy_password, gb.proxy_group, "password",
+ *proxy_password);
+ svn_config_get(cfg, &timeout_str, gb.proxy_group, "timeout",
+ timeout_str);
     }
 
   /* Special case: convert the port value, if any. */
@@ -266,6 +271,22 @@
   else
     *proxy_port = 80;
 
+ if (timeout_str)
+ {
+ char *endstr;
+ const long int timeout = strtol(timeout_str, &endstr, 10);
+
+ if (*endstr)
+ return svn_error_create(SVN_ERR_RA_DAV_INVALID_TIMEOUT, 0, NULL, pool,
+ "illegal character in timeout value");
+ if (timeout < 0)
+ return svn_error_create(SVN_ERR_RA_DAV_INVALID_TIMEOUT, 0, NULL, pool,
+ "negative timeout value");
+ *timeout_seconds = timeout;
+ }
+ else
+ *timeout_seconds = 0;
+
   return SVN_NO_ERROR;
 }
 
@@ -391,20 +412,22 @@
   sess = ne_session_create(uri.scheme, uri.host, uri.port);
   sess2 = ne_session_create(uri.scheme, uri.host, uri.port);
 
- /* If there's a proxy for this URL, use it. */
+ /* If there's a timeout or proxy for this URL, use it. */
   {
     const char *proxy_host;
     unsigned int proxy_port;
     const char *proxy_username;
     const char *proxy_password;
+ int timeout;
     svn_error_t *err;
     
- err = get_proxy(&proxy_host,
- &proxy_port,
- &proxy_username,
- &proxy_password,
- uri.host,
- pool);
+ err = get_proxy_and_timeout(&proxy_host,
+ &proxy_port,
+ &proxy_username,
+ &proxy_password,
+ &timeout,
+ uri.host,
+ pool);
     if (err)
       {
         ne_uri_free(&uri);
@@ -428,6 +451,12 @@
             ne_set_proxy_auth(sess, proxy_auth, pab);
             ne_set_proxy_auth(sess2, proxy_auth, pab);
           }
+ }
+
+ if (timeout)
+ {
+ ne_set_read_timeout(sess, timeout);
+ ne_set_read_timeout(sess2, timeout);
       }
   }
 

-- 
Philip Martin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Oct 25 14:28:02 2002

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.