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

Re: svn commit: rev 3499 - trunk/subversion/include trunk/subversion/libsvn_subr trunk/subversion/libsvn_ra_dav

From: Karl Fogel <kfogel_at_newton.ch.collab.net>
Date: 2002-10-25 21:49:21 CEST

philip@tigris.org writes:
> Make the neon timeout adjustable by making it part of the proxy
> configuration.

Great. I guess let's just leave it in there for now; but if we start
shoehorning more non-proxy stuff into that file, we can reconsider
changing the file's name.

-K

> * 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.
>
>
> Modified: trunk/subversion/include/svn_error_codes.h
> ==============================================================================
> --- trunk/subversion/include/svn_error_codes.h (original)
> +++ trunk/subversion/include/svn_error_codes.h Fri Oct 25 14:07:41 2002
> @@ -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,
>
> Modified: trunk/subversion/libsvn_subr/config_file.c
> ==============================================================================
> --- trunk/subversion/libsvn_subr/config_file.c (original)
> +++ trunk/subversion/libsvn_subr/config_file.c Fri Oct 25 14:07:42 2002
> @@ -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"
> @@ -653,6 +654,8 @@
> "### trying to access is matched against the patterns on\n"
> "### the right. If a match is found, the proxy info is\n"
> "### taken from the section with the corresponding name.\n"
> + "### Timeouts, if given, are specified in seconds. A timeout\n"
> + "### of 0, i.e. zero, causes a builtin default to be used.\n"
> "# [groups]\n"
> "# group1 = *.collab.net\n"
> "# othergroup = repository.blarggitywhoomph.com\n"
> @@ -663,6 +666,7 @@
> "# port = 80\n"
> "# username = blah\n"
> "# password = doubleblah\n"
> + "# timeout = 60\n"
> "\n"
> "### Information for the second group:\n"
> "# [othergroup]\n"
> @@ -686,7 +690,8 @@
> "# host = defaultproxy.whatever.com\n"
> "# port = 7000\n"
> "# username = defaultusername\n"
> - "# password = defaultpassword\n";
> + "# password = defaultpassword\n"
> + "# No timeout, so just use the builtin default.\n";
>
> apr_err = apr_file_open (&f, path,
> (APR_WRITE | APR_CREATE | APR_EXCL),
>
> Modified: trunk/subversion/libsvn_ra_dav/session.c
> ==============================================================================
> --- trunk/subversion/libsvn_ra_dav/session.c (original)
> +++ trunk/subversion/libsvn_ra_dav/session.c Fri Oct 25 14:07:42 2002
> @@ -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,7 @@
> *proxy_username);
> 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 +268,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 +409,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 +448,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);
> }
> }
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: svn-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: svn-help@subversion.tigris.org

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Oct 25 22:19:47 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.