diff options
author | Tom Gundersen <teg@jklm.no> | 2015-01-29 07:26:58 +0100 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2015-01-31 15:26:08 +0100 |
commit | 233ba5c3a0f73e01fe6149fd8c377826a83c2a0a (patch) | |
tree | 9ddd7b42550e4b708244e86cb8557039f293277c /src/libsystemd | |
parent | 81f5fc2d43800c23a4440ed94cfe38d579e896fe (diff) |
sd-rtnl: don't fail event handler when callback fails
As in sd-bus, simply log at debug level when a callback fails, but don't fail the event handler.
Otherwise any error returned by any callback will disable the rtnl event handler. We should
only do that on serious internal errors in sd-rtnl that we know cannot be recovered from.
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-rtnl/sd-rtnl.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c index 5778ea53c0..7f1ec308a8 100644 --- a/src/libsystemd/sd-rtnl/sd-rtnl.c +++ b/src/libsystemd/sd-rtnl/sd-rtnl.c @@ -379,9 +379,12 @@ static int process_timeout(sd_rtnl *rtnl) { hashmap_remove(rtnl->reply_callbacks, &c->serial); r = c->callback(rtnl, m, c->userdata); + if (r < 0) + log_debug_errno(r, "sd-rtnl: timedout callback failed: %m"); + free(c); - return r < 0 ? r : 1; + return 1; } static int process_reply(sd_rtnl *rtnl, sd_rtnl_message *m) { @@ -404,9 +407,12 @@ static int process_reply(sd_rtnl *rtnl, sd_rtnl_message *m) { prioq_remove(rtnl->reply_callbacks_prioq, c, &c->prioq_idx); r = c->callback(rtnl, m, c->userdata); + if (r < 0) + log_debug_errno(r, "sd-rtnl: callback failed: %m"); + free(c); - return r; + return 1; } static int process_match(sd_rtnl *rtnl, sd_rtnl_message *m) { @@ -424,12 +430,16 @@ static int process_match(sd_rtnl *rtnl, sd_rtnl_message *m) { LIST_FOREACH(match_callbacks, c, rtnl->match_callbacks) { if (type == c->type) { r = c->callback(rtnl, m, c->userdata); - if (r != 0) - return r; + if (r != 0) { + if (r < 0) + log_debug_errno(r, "sd-rtnl: match callback failed: %m"); + + break; + } } } - return 0; + return 1; } static int process_running(sd_rtnl *rtnl, sd_rtnl_message **ret) { |