diff options
author | Bjørn Mork <bjorn@mork.no> | 2019-05-30 11:48:35 +0200 |
---|---|---|
committer | Bjørn Mork <bjorn@mork.no> | 2019-05-30 12:40:25 +0200 |
commit | 4d2c72513120d8ed7d6cf4b2500e04d754b96b66 (patch) | |
tree | b11fcb649005ad10b38b5b84f4d539df273d4dde | |
parent | c6ab125dc63e558d559676b2c05d81e32e687c37 (diff) |
poll will return on HUP, so we need to handle cfg read there
Also need to clear revents to continue polling...
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r-- | obinsectd.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/obinsectd.c b/obinsectd.c index f28d3a9..a8beb0e 100644 --- a/obinsectd.c +++ b/obinsectd.c @@ -1527,9 +1527,20 @@ static int read_and_parse(int fd, unsigned char *rbuf, size_t rbuflen) while (1) { ret = poll(fds, 1, -1); - if (ret == -1) + if (ret == -1 && !reread_cfg) return -errno; + /* we might have been requested to read the config file again */ + if (reread_cfg) { + fds[0].revents = 0; + reread_cfg = false; + info("reading new configuration from '%s'\n", cfgfile); + if (cfg) + json_object_put(cfg); + read_config(); + continue; + } + if (fds[0].revents & POLLIN) rlen = read(fd, cur, rbuflen + rbuf - cur); else @@ -1571,15 +1582,6 @@ nextframe: if (framelen > 0 && (cur - hdlc) < (framelen + 2)) continue; - /* we might have been requested to read the config file again */ - if (reread_cfg) { - reread_cfg = false; - info("reading new configuration from '%s'\n", cfgfile); - if (cfg) - json_object_put(cfg); - read_config(); - } - /* Yay! We got a complete frame - let's save some metadata now */ json = save_metadata(framelen, &tv); @@ -1872,6 +1874,7 @@ static void usage() static void sig_handler(int sig) { + debug("handling signal %d\n", sig); switch (sig) { case SIGHUP: reread_cfg = true; |