common: Not handle missing method 89/124389/3
authorpr.jung <pr.jung@samsung.com>
Tue, 11 Apr 2017 08:08:23 +0000 (17:08 +0900)
committerJung <pr.jung@samsung.com>
Wed, 12 Apr 2017 01:43:04 +0000 (18:43 -0700)
- If there is method call with not implemented method,
it is not handled and return DBUS_HANDLER_RESULT_NOT_YET_HANDLED

Change-Id: I46e24e2a71e7b29f589705ac7a5439b8c7c6e755
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/shared/dbus.c

index e8502e4..5c0fb9b 100644 (file)
@@ -222,11 +222,12 @@ static DBusHandlerResult method_call_handler(DBusConnection *connection,
        const dbus_interface_s *iface;
        const dbus_method_s *methods;
        DBusMessage *result = NULL;
+       bool method_is_implemented = false;
 
        _D("Method call handler");
 
        if (!msg || !mh) {
-               return DBUS_HANDLER_RESULT_HANDLED;
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; // No message to handle
        }
 
        iface = mh->iface;
@@ -236,10 +237,11 @@ static DBusHandlerResult method_call_handler(DBusConnection *connection,
                if (dbus_message_is_method_call(msg, iface->name, methods[i].member) != TRUE)
                        continue;
 
+               method_is_implemented = true;
                reply = calloc(1, sizeof(struct dbus_method_reply_handle_s));
                if (!reply) {
                        _E("calloc() failed");
-                       return DBUS_HANDLER_RESULT_HANDLED;
+                       return DBUS_HANDLER_RESULT_NEED_MEMORY; // Failed to create reply, try again later
                }
 
                reply->handle = mh->handle;
@@ -250,8 +252,11 @@ static DBusHandlerResult method_call_handler(DBusConnection *connection,
                break;
        }
 
+       if (!method_is_implemented)
+               return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; // Missing method, no reply
+       /* If result is null, reply will be sent by worker thread */
        if (result)
-               reply_dbus_method_result(reply, result);
+               reply_dbus_method_result(reply, result); // Method handled, reply sent
 
        return DBUS_HANDLER_RESULT_HANDLED;
 }