summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOndrej Kos <okos@redhat.com>2013-01-11 13:25:11 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-01-30 14:07:21 +0100
commitf4b1683dcff3663c4cc50ce37537ff439dbc4418 (patch)
tree99e7540e55ea7908aacbc44b9091ee3883e60afb
parent7f2a82103d8537438470f5d560b5bfd12e52a915 (diff)
downloadsssd-f4b1683dcff3663c4cc50ce37537ff439dbc4418.tar.gz
sssd-f4b1683dcff3663c4cc50ce37537ff439dbc4418.tar.xz
sssd-f4b1683dcff3663c4cc50ce37537ff439dbc4418.zip
Cancel ping-check if service goes away
backport of https://fedorahosted.org/sssd/changeset/4134936f56911686e908dbd6bc9634767f399e3d
-rw-r--r--src/monitor/monitor.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c
index 0728d1078..cfe571281 100644
--- a/src/monitor/monitor.c
+++ b/src/monitor/monitor.c
@@ -85,6 +85,7 @@ struct mt_svc {
int restarts;
time_t last_restart;
int failed_pongs;
+ DBusPendingCall *pending;
int debug_level;
@@ -310,6 +311,11 @@ static int svc_destructor(void *mem)
DLIST_REMOVE(svc->mt_ctx->svc_list, svc);
}
+ /* Cancel any pending pings */
+ if (svc->pending) {
+ dbus_pending_call_cancel(svc->pending);
+ }
+
/* svc is beeing freed, neutralize the spy */
if (svc->conn_spy) {
talloc_set_destructor((TALLOC_CTX *)svc->conn_spy, NULL);
@@ -2110,7 +2116,8 @@ static int service_send_ping(struct mt_svc *svc)
ret = sbus_conn_send(svc->conn, msg,
svc->ping_time * 1000, /* milliseconds */
- ping_check, svc, NULL);
+ ping_check, svc, &svc->pending);
+
dbus_message_unref(msg);
return ret;
}
@@ -2124,6 +2131,13 @@ static void ping_check(DBusPendingCall *pending, void *data)
int type;
svc = talloc_get_type(data, struct mt_svc);
+ if (!svc) {
+ /* The connection probably went down before the callback fired.
+ * Not much we can do. */
+ DEBUG(1, ("Invalid service pointer.\n"));
+ return;
+ }
+ svc->pending = NULL;
reply = dbus_pending_call_steal_reply(pending);
if (!reply) {