From: Kay Sievers Date: Thu, 15 May 2014 22:57:29 +0000 (+0200) Subject: never schedule work for a dead connection X-Git-Tag: upstream/0.20140911.160207utc~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d75b7e66d74c9a9a9c49a2eedb209dec2724d4f6;p=platform%2Fcore%2Fsystem%2Fkdbus-bus.git never schedule work for a dead connection --- diff --git a/connection.c b/connection.c index 32bb2e3..367e463 100644 --- a/connection.c +++ b/connection.c @@ -1490,16 +1490,17 @@ int kdbus_conn_disconnect(struct kdbus_conn *conn, bool ensure_queue_empty) continue; } - /* - * In asynchronous cases, send a 'connection - * dead' notification, mark entry as handled, - * and trigger the timeout handler. - */ + /* send a 'connection dead' notification */ kdbus_notify_reply_dead(conn->bus, reply->conn->id, reply->cookie); - reply->deadline_ns = 0; - schedule_delayed_work(&reply->conn->work, 0); + /* mark entry as handled, and trigger the timeout handler */ + mutex_lock(&reply->conn->lock); + if (kdbus_conn_active(conn)) { + reply->deadline_ns = 0; + schedule_delayed_work(&reply->conn->work, 0); + } + mutex_unlock(&reply->conn->lock); list_del(&reply->entry); kdbus_conn_reply_free(reply); @@ -1513,9 +1514,6 @@ int kdbus_conn_disconnect(struct kdbus_conn *conn, bool ensure_queue_empty) kdbus_notify_flush(conn->bus); - /* drop additional reference whe took at HELLO time */ - kdbus_conn_unref(conn); - return 0; } @@ -2075,9 +2073,6 @@ int kdbus_conn_new(struct kdbus_ep *ep, list_add_tail(&conn->ep_entry, &ep->conn_list); hash_add(bus->conn_hash, &conn->hentry, conn->id); - /* take additional reference until we disconnect */ - kdbus_conn_ref(conn); - mutex_unlock(&ep->lock); mutex_unlock(&bus->lock);