Fix the case when the requested name is already in use
[framework/connectivity/connman.git] / gdbus / mainloop.c
index 7f2d001..ec10ab0 100644 (file)
@@ -347,8 +347,12 @@ gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
                        return FALSE;
        }
 
-       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
+       if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+               if (error != NULL)
+                       dbus_set_error(error, name, "Name already in use");
+
                return FALSE;
+       }
 
        return TRUE;
 }