Fix the problem that can't add a device from next time once add_device_failed.
authorsaerome.kim <saerome.kim@samsung.com>
Thu, 21 Nov 2019 04:39:37 +0000 (13:39 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Thu, 21 Nov 2019 05:37:10 +0000 (14:37 +0900)
- Problem: Once add_device failed, we can't add the device anymore.
- Cause: The request stored in the internal queue is not deleted.
- Solution: If the request is not processed for a certain period of time,
  remove the request from the queue

Change-Id: I14990e3854d599ca3adfed491f64bb215e94d232
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/ua-manager.spec
ua-daemon/include/ua-manager-common.h
ua-daemon/src/ua-manager-common.c
ua-daemon/src/ua-manager-request-handler.c

index 9f7a12f..6a915d3 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.3
+Version:    0.13.4
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 188df77..9da4270 100644 (file)
@@ -80,6 +80,7 @@ typedef struct {
        int result;
        int function;
        char *sender;
+       unsigned int tid;
        GDBusMethodInvocation *context;
        gpointer data;
 } uam_request_context_t;
index c8125de..14db69a 100644 (file)
@@ -181,7 +181,7 @@ guint _uam_add_timer_full(gint res, gint priority,
 
        retv_if(NULL == function, 0);
 
-       if (TIMER_RES_MSEC)
+       if (TIMER_RES_MSEC == res)
                source = g_timeout_source_new(interval);
        else
                source = g_timeout_source_new_seconds(interval);
index cf0846d..c69792a 100644 (file)
@@ -47,6 +47,8 @@ static const gchar uam_manager_introspection_xml[] =
 "      </interface>"
 "</node>";
 
+#define UAM_ASYNC_REQUEST_TIMEOUT 10 /* 10 sec */
+
 static void __uam_manager_copy_params(
                GVariant *in_param, void *value, int size)
 {
@@ -717,6 +719,20 @@ static gboolean __uam_manager_is_request_pending(int function)
        return FALSE;
 }
 
+static gboolean __uam_request_context_timeout_cb(gpointer p)
+{
+       FUNC_ENTRY;
+
+       uam_request_context_t *info = p;
+       retv_if(info == NULL, G_SOURCE_REMOVE);
+
+       /* Remove unhandled async-request */
+       _uam_manager_remove_req_ctxt_from_list(info);
+
+       FUNC_EXIT;
+       return G_SOURCE_REMOVE;
+}
+
 static void __uam_manager_save_request_context(
                GDBusMethodInvocation *context, int result,
                char *sender, int function, gpointer data)
@@ -745,6 +761,9 @@ static void __uam_manager_save_request_context(
        info->data = data;
        request_list = g_slist_append(request_list, info);
 
+       info->tid = _uam_add_timer_full(TIMER_RES_SEC, G_PRIORITY_DEFAULT,
+               UAM_ASYNC_REQUEST_TIMEOUT, __uam_request_context_timeout_cb, info, NULL);
+
        FUNC_EXIT;
 }
 
@@ -1090,24 +1109,32 @@ GSList *_uam_manager_get_request_list(void)
 void _uam_manager_remove_req_ctxt_from_list(uam_request_context_t *req_info)
 {
        FUNC_ENTRY;
-       GSList *l;
 
        ret_if(NULL == req_info);
        ret_if(NULL == req_info->sender);
 
-       for (l = request_list; NULL != l; l = g_slist_next(l)) {
+       GSList *l = request_list;
+       while (l) {
+
+               GSList *next = l->next;
                uam_request_context_t *info = l->data;
+
                if (NULL == info || NULL == info->sender)
                        continue;
 
                if ((strcasecmp(info->sender, req_info->sender) == 0) &&
-                               req_info->function == info->function) {
-                       request_list = g_slist_remove(request_list, req_info);
+                       req_info->function == info->function) {
+
                        g_free(req_info->sender);
                        g_free(req_info);
+
+                       request_list = g_slist_remove_link(request_list, l);
+
                        break;
                }
+               l = next;
        }
+
        FUNC_EXIT;
 }