From 28f4f00194ceb8225190202588d3ecb8d0e12c47 Mon Sep 17 00:00:00 2001 From: Ondrej Kos Date: Fri, 11 Jan 2013 13:25:11 +0100 Subject: Cancel ping-check if service goes away backport of https://fedorahosted.org/sssd/changeset/4134936f56911686e908dbd6bc9634767f399e3d --- src/monitor/monitor.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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) { -- cgit