summaryrefslogtreecommitdiff
path: root/src/socket-proxy/socket-proxyd.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-13 03:30:42 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-13 04:06:43 +0100
commit7b77ed8cf36e8eca6017791626044b61ae2d68e7 (patch)
treeb9315db260bbd82cfbc4ae7cd736d9d8df65f626 /src/socket-proxy/socket-proxyd.c
parentc5ef10429a7768e3453f29e8c85cb560ce382649 (diff)
event: be more conservative when returning errors from event handler callbacks
We really should return errors from event handlers if we have a continous problem and don't know any other solution.
Diffstat (limited to 'src/socket-proxy/socket-proxyd.c')
-rw-r--r--src/socket-proxy/socket-proxyd.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index c6f56be60a..b066633b1d 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -462,6 +462,7 @@ fail:
}
static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
+ _cleanup_free_ char *peer = NULL;
Context *context = userdata;
int nfd = -1, r;
@@ -471,24 +472,24 @@ static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdat
assert(context);
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
- if (nfd >= 0) {
- _cleanup_free_ char *peer = NULL;
-
+ if (nfd < 0) {
+ if (errno != -EAGAIN)
+ log_warning("Failed to accept() socket: %m");
+ } else {
getpeername_pretty(nfd, &peer);
log_debug("New connection from %s", strna(peer));
r = add_connection_socket(context, sd_event_source_get_event(s), nfd);
if (r < 0) {
+ log_error("Failed to accept connection, ignoring: %s", strerror(-r));
close_nointr_nofail(fd);
- return r;
}
-
- } else if (errno != -EAGAIN)
- log_warning("Failed to accept() socket: %m");
+ }
r = sd_event_source_set_enabled(s, SD_EVENT_ONESHOT);
if (r < 0) {
- log_error("Error %d while re-enabling listener with ONESHOT: %s", r, strerror(-r));
+ log_error("Error while re-enabling listener with ONESHOT: %s", strerror(-r));
+ sd_event_exit(sd_event_source_get_event(s), r);
return r;
}