[rrd-developers] [PATCH] Allow ports to be specified with -l addr:port also.

Tobias Oetiker tobi at oetiker.ch
Thu Sep 25 00:24:09 CEST 2008


Hi Kevin,

I have applied the patch. Are you working on the 'stat-only' bit as
well ?

cheers
tobi



Yesterday kevin brintnall wrote:

> ---
>  doc/rrdcached.pod |    3 +++
>  src/rrd_daemon.c  |    9 ++++++++-
>  2 files changed, 11 insertions(+), 1 deletions(-)
>
> diff --git a/doc/rrdcached.pod b/doc/rrdcached.pod
> index e718791..0f34dc2 100644
> --- a/doc/rrdcached.pod
> +++ b/doc/rrdcached.pod
> @@ -34,6 +34,9 @@ socket. If I<address> begins with C<unix:>, everything following that prefix is
>  interpreted as the path to a UNIX domain socket. Otherwise the address or node
>  name are resolved using L<getaddrinfo>.
>
> +For network sockets, a port may be specified by using the form
> +I<address>:I<port>.  The default port is 42217.
> +
>  If the B<-l> option is not specified the default address,
>  C<unix:/tmp/rrdcached.sock>, will be used.
>
> diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c
> index 2bd19a1..6f01f89 100644
> --- a/src/rrd_daemon.c
> +++ b/src/rrd_daemon.c
> @@ -1568,6 +1568,7 @@ static int open_listen_socket (const char *addr) /* {{{ */
>    struct addrinfo ai_hints;
>    struct addrinfo *ai_res;
>    struct addrinfo *ai_ptr;
> +  char *port;
>    int status;
>
>    assert (addr != NULL);
> @@ -1585,8 +1586,14 @@ static int open_listen_socket (const char *addr) /* {{{ */
>    ai_hints.ai_family = AF_UNSPEC;
>    ai_hints.ai_socktype = SOCK_STREAM;
>
> +  port = rindex(addr, ':');
> +  if (port != NULL)
> +    *port++ = '\0';
> +
>    ai_res = NULL;
> -  status = getaddrinfo (addr, RRDCACHED_DEFAULT_PORT, &ai_hints, &ai_res);
> +  status = getaddrinfo (addr,
> +                        port == NULL ? RRDCACHED_DEFAULT_PORT : port,
> +                        &ai_hints, &ai_res);
>    if (status != 0)
>    {
>      RRDD_LOG (LOG_ERR, "open_listen_socket: getaddrinfo(%s) failed: "
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900



More information about the rrd-developers mailing list