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

Re: svn commit: r33748 - branches/issue-2382/subversion/svnserve

From: Greg Stein <gstein_at_gmail.com>
Date: Sun, 19 Oct 2008 10:20:25 -0700

On Sat, Oct 18, 2008 at 6:39 PM, <stsp_at_tigris.org> wrote:
>...
> +++ branches/issue-2382/subversion/svnserve/listen.c Sat Oct 18 18:39:28 2008 (r33748)
>...
> +static apr_array_header_t *listeners;

Ugh. Mutable global! (and it isn't even doc'd)

Why not have init_listeners return this array, and then accept the
array as a parameter in wait_for_client(). Both functions are called
from the same place, so it isn't hard to just pass the value between
them. AND it avoids a mutable global.

(and if you need me to rant further about mutable globals, then ask;
but I hope you simply agree and make the change :-))

>...
> +++ branches/issue-2382/subversion/svnserve/main.c Sat Oct 18 18:39:28 2008 (r33748)
>...
> + /* Process old --listen-host and --listen-port options.
> + * While they are deprecated, we still allow them and
> + * convert them to an equivalent --listen option. */
> + buf = svn_stringbuf_create("", pool);
> + if (host && port)
> + {
> + svn_stringbuf_appendcstr(buf, host);
> + svn_stringbuf_appendcstr(buf, ":");
> + svn_stringbuf_appendcstr(buf, port);
> + APR_ARRAY_PUSH(addresses, const char *) = buf->data;

APR_ARRAY_PUSH(addresses, const char *) = apr_psprintf(pool, "%s:%s",
host, port);

> + }
> + else if (host)
> + {
> + svn_stringbuf_appendcstr(buf, host);
> + /* init_listeners() will use the default port if unspecified. */
> + APR_ARRAY_PUSH(addresses, const char *) = buf->data;

APR_ARRAY_PUSH(addresses, const char *) = host;

> + }
> + else if (port)
> + {
> + /* We just got a port. Bind to this port with the unspecified
> + * address in all available address families. */
> + svn_stringbuf_appendcstr(buf, APR_ANYADDR);
> + svn_stringbuf_appendcstr(buf, ":");
> + svn_stringbuf_appendcstr(buf, port);
> + APR_ARRAY_PUSH(addresses, const char *) = buf->data;

apr_psprintf() again

> #if APR_HAVE_IPV6
> -#ifdef MAX_SECS_TO_LINGER
> - /* ### old APR interface */
> - status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, pool);
> -#else
> - status = apr_socket_create(&sock, APR_INET6, SOCK_STREAM, APR_PROTO_TCP,
> - pool);
> + /* In case you're not familiar with IPv6: The first two colons
> + * represent the unspecified address, while the third colon
> + * separates the address from the port, like in IPv4. */
> + svn_stringbuf_appendcstr(buf, ":::");
> + svn_stringbuf_appendcstr(buf, port);
> + APR_ARRAY_PUSH(addresses, const char *) = buf->data;

apr_psprintf

>...
> + /* Start accepting connections. */
> + err = init_listeners(addresses, pool);
> + if (err)
> + return svn_cmdline_handle_exit_error(err, pool, "svnserve: ");
> + err = wait_for_client(&sock, pool);
> + if (err)
> + return svn_cmdline_handle_exit_error(err, pool, "svnserve: ");

Here is where you'd simply get and pass an array of listeners.

Cheers,
-g

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: dev-help_at_subversion.tigris.org
Received on 2008-10-19 19:20:39 CEST

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