From 1f65ab0c19ea9b881fbabdd5b8a058367181ea78 Mon Sep 17 00:00:00 2001 From: oetiker Date: Wed, 24 Sep 2008 22:21:21 +0000 Subject: [PATCH] Allow ports to be specified with -l addr:port also. -- kevin brintnall git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1521 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/doc/rrdcached.pod | 3 +++ program/src/rrd_daemon.c | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/program/doc/rrdcached.pod b/program/doc/rrdcached.pod index e718791c..0f34dc20 100644 --- a/program/doc/rrdcached.pod +++ b/program/doc/rrdcached.pod @@ -34,6 +34,9 @@ socket. If I
begins with C, everything following that prefix is interpreted as the path to a UNIX domain socket. Otherwise the address or node name are resolved using L. +For network sockets, a port may be specified by using the form +I
:I. The default port is 42217. + If the B<-l> option is not specified the default address, C, will be used. diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 2bd19a14..6f01f899 100644 --- a/program/src/rrd_daemon.c +++ b/program/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: " -- 2.30.2