From 00e313d7e9fc487b445b05324148a8931941b8f0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 15 Sep 2014 17:19:15 +0200 Subject: Don't try to poll on invalid status socket FD --- src/poll.c | 14 ++++++++------ src/status.c | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/poll.c b/src/poll.c index 949a597..3419d05 100644 --- a/src/poll.c +++ b/src/poll.c @@ -84,13 +84,15 @@ void fastd_poll_init(void) { exit_errno("epoll_ctl"); #ifdef WITH_STATUS_SOCKET - struct epoll_event event_status = { - .events = EPOLLIN, - .data.ptr = &ctx.status_fd, - }; + if (ctx.status_fd >= 0) { + struct epoll_event event_status = { + .events = EPOLLIN, + .data.ptr = &ctx.status_fd, + }; - if (epoll_ctl(ctx.epoll_fd, EPOLL_CTL_ADD, ctx.status_fd, &event_status) < 0) - exit_errno("epoll_ctl"); + if (epoll_ctl(ctx.epoll_fd, EPOLL_CTL_ADD, ctx.status_fd, &event_status) < 0) + exit_errno("epoll_ctl"); + } #endif } diff --git a/src/status.c b/src/status.c index fd34747..8e0c427 100644 --- a/src/status.c +++ b/src/status.c @@ -195,8 +195,10 @@ static void dump_status(int fd) { /** Initialized the status socket */ void fastd_status_init(void) { - if (!conf.status_socket) + if (!conf.status_socket) { + ctx.status_fd = -1; return; + } uid_t uid = geteuid(); gid_t gid = getegid(); -- cgit v1.2.3