runit

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit c8fe64717cac68cfbbbe0807478e0c62cfd4446f
parent 42747b987630ba558f7a9ac484023a6c6afbdc3b
Author: Gerrit Pape <pape@smarden.org>
Date:   Tue, 17 Apr 2007 07:49:14 +0000

svlogd.c: don't statically bind local udp socket

..., but request new source port for each log message sent through udp.

Diffstat:
Mpackage/CHANGES | 2++
Msrc/svlogd.c | 17++++++++---------
2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/package/CHANGES b/package/CHANGES @@ -4,6 +4,8 @@ in short time. * chpst.c, uidgid.c: improve error reporting if getpwnam() or getgrnam() fails; cleanup. + * svlogd.c: don't statically bind local udp socket, but request new + source port for each log message sent through udp. 1.7.2 Tue, 21 Nov 2006 15:13:47 +0000 diff --git a/src/svlogd.c b/src/svlogd.c @@ -507,14 +507,6 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { else port =514; ld->udpaddr.sin_port =htons(port); - if (fdudp == -1) { - fdudp =socket(AF_INET, SOCK_DGRAM, 0); - if (fdudp) - if (ndelay_on(fdudp) == -1) { - close(fdudp); - fdudp =-1; - } - } break; case 'p': if (len > 1) { @@ -756,7 +748,7 @@ int main(int argc, const char **argv) { case 2: fmt_ptime(stamp, &now); break; case 3: fmt_ptime_iso8601(stamp, &now); break; } - stamp[25] =' '; stamp[26] =0; + stamp[25] =' '; stamp[26] =0; } if (ch == '\n') break; if (repl) { @@ -784,6 +776,12 @@ int main(int argc, const char **argv) { } if (dir[i].match != '+') continue; if (dir[i].udpaddr.sin_port != 0) { + fdudp =socket(AF_INET, SOCK_DGRAM, 0); + if (fdudp) + if (ndelay_on(fdudp) == -1) { + close(fdudp); + fdudp =-1; + } if (fdudp == -1) { buffer_puts(&dir[i].b, "warning: no udp socket available: "); if (timestamp) buffer_puts(&dir[i].b, stamp); @@ -809,6 +807,7 @@ int main(int argc, const char **argv) { buffer_put(&dir[i].b, sa.s, sa.len); buffer_flush(&dir[i].b); } + close(fdudp); } } if (! dir[i].udponly) {