summaryrefslogtreecommitdiff
path: root/src/lib/eldbus/eldbus_service.c
diff options
context:
space:
mode:
authorJosé Roberto de Souza <jose.souza@intel.com>2013-08-26 16:11:31 -0300
committerJosé Roberto de Souza <jose.souza@intel.com>2013-08-26 16:11:31 -0300
commit091c5425c6cdf0a1acb4728c7fd1d0dc57667ffd (patch)
treed403cfe7b8054319c4bf68ef250918afb9a4f98b /src/lib/eldbus/eldbus_service.c
parent547313ece9db920a2a03cad5e29a6503ab3c611a (diff)
eldbus: Handle correclty the last unref of a object path or conn in service callback
This allow user remove the last reference of service object path or last last reference of connection be removed inside of a method callback.
Diffstat (limited to 'src/lib/eldbus/eldbus_service.c')
-rw-r--r--src/lib/eldbus/eldbus_service.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/eldbus/eldbus_service.c b/src/lib/eldbus/eldbus_service.c
index 490b045b1a..4c793c8a1c 100644
--- a/src/lib/eldbus/eldbus_service.c
+++ b/src/lib/eldbus/eldbus_service.c
@@ -1264,16 +1264,17 @@ _object_unregister(DBusConnection *conn EINA_UNUSED, void *user_data)
1264} 1264}
1265 1265
1266static DBusHandlerResult 1266static DBusHandlerResult
1267_object_handler(DBusConnection *conn EINA_UNUSED, DBusMessage *msg, void *user_data) 1267_object_handler(DBusConnection *dbus_conn EINA_UNUSED, DBusMessage *msg, void *user_data)
1268{ 1268{
1269 Eldbus_Service_Object *obj; 1269 Eldbus_Service_Object *obj;
1270 Eldbus_Service_Interface *iface; 1270 Eldbus_Service_Interface *iface;
1271 const Eldbus_Method *method; 1271 const Eldbus_Method *method;
1272 Eldbus_Message *eldbus_msg; 1272 Eldbus_Message *eldbus_msg, *reply;
1273 Eldbus_Message *reply; 1273 Eldbus_Connection *conn;
1274 1274
1275 obj = user_data; 1275 obj = user_data;
1276 if (!obj) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 1276 if (!obj) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1277 conn = obj->conn;
1277 1278
1278 DBG("Connection@%p Got message:\n" 1279 DBG("Connection@%p Got message:\n"
1279 " Type: %s\n" 1280 " Type: %s\n"
@@ -1299,6 +1300,9 @@ _object_handler(DBusConnection *conn EINA_UNUSED, DBusMessage *msg, void *user_d
1299 dbus_message_ref(eldbus_msg->dbus_msg); 1300 dbus_message_ref(eldbus_msg->dbus_msg);
1300 dbus_message_iter_init(eldbus_msg->dbus_msg, &eldbus_msg->iterator->dbus_iterator); 1301 dbus_message_iter_init(eldbus_msg->dbus_msg, &eldbus_msg->iterator->dbus_iterator);
1301 1302
1303 eldbus_init();
1304 eldbus_connection_ref(conn);
1305
1302 if (!_have_signature(method->in, eldbus_msg)) 1306 if (!_have_signature(method->in, eldbus_msg))
1303 reply = eldbus_message_error_new(eldbus_msg, DBUS_ERROR_INVALID_SIGNATURE, 1307 reply = eldbus_message_error_new(eldbus_msg, DBUS_ERROR_INVALID_SIGNATURE,
1304 "See introspectable to know the expected signature"); 1308 "See introspectable to know the expected signature");
@@ -1318,7 +1322,10 @@ _object_handler(DBusConnection *conn EINA_UNUSED, DBusMessage *msg, void *user_d
1318 1322
1319 eldbus_message_unref(eldbus_msg); 1323 eldbus_message_unref(eldbus_msg);
1320 if (reply) 1324 if (reply)
1321 _eldbus_connection_send(obj->conn, reply, NULL, NULL, -1); 1325 _eldbus_connection_send(conn, reply, NULL, NULL, -1);
1326
1327 eldbus_connection_unref(conn);
1328 eldbus_shutdown();
1322 1329
1323 return DBUS_HANDLER_RESULT_HANDLED; 1330 return DBUS_HANDLER_RESULT_HANDLED;
1324} 1331}