Revert "Revert "eldbus: change to idle_enterer from idler"" 49/227549/3
authorArtur Świgoń <a.swigon@samsung.com>
Mon, 23 Mar 2020 11:33:52 +0000 (12:33 +0100)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 18 Jun 2020 00:29:24 +0000 (00:29 +0000)
This reverts commit 2bcc7b48bf2f34a19b0712b030ab143d09dc30fb.

Handling DBus messages during idle carries the risk of starving the DBus
communication (and making the UI unresponsive if screen reader is used). This
is well-explained in the original (reverted) upstream commit: "If an
application does not give idle time, then the eldbus cannot have chance to
work."

Change-Id: Iffde1be749f5dba1ac1e8642c4ce4e3436770b5a

src/lib/eldbus/eldbus_core.c
src/lib/eldbus/eldbus_private_types.h
src/lib/eldbus/eldbus_service.c

index 46e37f5..d665bb3 100644 (file)
@@ -45,7 +45,7 @@ typedef struct _Eldbus_Connection_Context_NOC_Cb
    Eldbus_Name_Owner_Changed_Cb cb;
    const void                 *cb_data;
    Eina_Bool                   deleted : 1;
-   Ecore_Idler                *idler;
+   Ecore_Idle_Enterer         *idle_enterer;
    Eina_Bool                   allow_initial : 1;
 } Eldbus_Connection_Context_NOC_Cb;
 
@@ -814,7 +814,7 @@ cb_timeout_toggle(DBusTimeout *timeout, void *data EINA_UNUSED)
 }
 
 static Eina_Bool
-eldbus_idler(void *data)
+eldbus_idle_enterer(void *data)
 {
    Eldbus_Connection *conn = data;
 
@@ -824,15 +824,22 @@ eldbus_idler(void *data)
    if (dbus_connection_get_dispatch_status(conn->dbus_conn) ==
        DBUS_DISPATCH_COMPLETE)
      {
-        DBG("Connection@%p: Dispatch complete, idler@%p finishing",
-            conn, conn->idler);
-        conn->idler = NULL;
+        DBG("Connection@%p: Dispatch complete, idle_enterer@%p finishing",
+            conn, conn->idle_enterer);
+        conn->idle_enterer = NULL;
         return ECORE_CALLBACK_CANCEL;
      }
    DBG("Connection@%p: Dispatching", conn);
    eldbus_init();
    eldbus_connection_ref(conn);
-   dbus_connection_dispatch(conn->dbus_conn);
+
+   DBusDispatchStatus status;
+   do
+     {
+        status = dbus_connection_dispatch(conn->dbus_conn);
+     }
+   while(status == DBUS_DISPATCH_DATA_REMAINS);
+
    eldbus_connection_unref(conn);
    eldbus_shutdown();
    return ECORE_CALLBACK_RENEW;
@@ -851,19 +858,19 @@ cb_dispatch_status(DBusConnection *dbus_conn EINA_UNUSED, DBusDispatchStatus new
 
    DBG("Connection@%p: Dispatch status: %d", conn, new_status);
 
-   if ((new_status == DBUS_DISPATCH_DATA_REMAINS) && (!conn->idler))
+   if ((new_status == DBUS_DISPATCH_DATA_REMAINS) && (!conn->idle_enterer))
      {
-        conn->idler = ecore_idler_add(eldbus_idler, conn);
-        DBG("Connection@%p: Adding idler@%p to handle remaining dispatch data",
-            conn, conn->idler);
+        conn->idle_enterer = ecore_idle_enterer_add(eldbus_idle_enterer, conn);
+        DBG("Connection@%p: Adding idle_enterer@%p to handle remaining dispatch data",
+            conn, conn->idle_enterer);
      }
-   else if ((new_status != DBUS_DISPATCH_DATA_REMAINS) && (conn->idler))
+   else if ((new_status != DBUS_DISPATCH_DATA_REMAINS) && (conn->idle_enterer))
      {
-        DBG("Connection@%p: No remaining dispatch data, clearing idler@%p",
-            conn, conn->idler);
+        DBG("Connection@%p: No remaining dispatch data, clearing idle_enterer@%p",
+            conn, conn->idle_enterer);
 
-        ecore_idler_del(conn->idler);
-        conn->idler = NULL;
+        ecore_idle_enterer_del(conn->idle_enterer);
+        conn->idle_enterer = NULL;
      }
 }
 
@@ -1299,7 +1306,7 @@ _eldbus_connection_free(Eldbus_Connection *conn)
 
    eldbus_data_del_all(&conn->data);
 
-   if (conn->idler) ecore_idler_del(conn->idler);
+   if (conn->idle_enterer) ecore_idle_enterer_del(conn->idle_enterer);
    if (conn->type && conn->shared)
      {
         if (conn->type == ELDBUS_CONNECTION_TYPE_ADDRESS)
@@ -1400,7 +1407,7 @@ dispach_name_owner_cb(void *context)
    dispatch_name_owner_data *data = context;
    data->ctx->cb((void *)data->ctx->cb_data, data->cn->name, "",
                  data->cn->unique_id);
-   data->ctx->idler = NULL;
+   data->ctx->idle_enterer = NULL;
    free(data);
    return ECORE_CALLBACK_CANCEL;
 }
@@ -1432,7 +1439,7 @@ eldbus_name_owner_changed_callback_add(Eldbus_Connection *conn, const char *bus,
         EINA_SAFETY_ON_NULL_RETURN(dispatch_data);
         dispatch_data->cn = cn;
         dispatch_data->ctx = ctx;
-        ctx->idler = ecore_idler_add(dispach_name_owner_cb, dispatch_data);
+        ctx->idle_enterer = ecore_idle_enterer_add(dispach_name_owner_cb, dispatch_data);
      }
    return;
 
@@ -1475,10 +1482,10 @@ eldbus_name_owner_changed_callback_del(Eldbus_Connection *conn, const char *bus,
 
    cn->event_handlers.list = eina_inlist_remove(cn->event_handlers.list,
                                                 EINA_INLIST_GET(found));
-   if (found->idler)
+   if (found->idle_enterer)
      {
         dispatch_name_owner_data *data;
-        data = ecore_idler_del(found->idler);
+        data = ecore_idle_enterer_del(found->idle_enterer);
         free(data);
      }
    free(found);
index 7af9426..05dfee8 100644 (file)
@@ -54,7 +54,7 @@ struct _Eldbus_Connection
    Eina_Inlist                   *pendings;
    Eina_Inlist                   *fd_handlers;
    Eina_Inlist                   *timeouts;
-   Ecore_Idler                   *idler;
+   Ecore_Idle_Enterer            *idle_enterer;
    Eldbus_Connection_Context_Event event_handlers[ELDBUS_CONNECTION_EVENT_LAST];
    Eina_Inlist                   *root_objs;//service_object
    Eldbus_Proxy                   *fdo_proxy;
@@ -153,7 +153,7 @@ struct _Eldbus_Service_Object
    Eldbus_Service_Interface *objmanager;
    Eina_List *iface_added;
    Eina_List *iface_removed;
-   Ecore_Idler *idler_iface_changed;
+   Ecore_Idle_Enterer *idle_enterer_iface_changed;
 };
 
 struct _Eldbus_Service_Interface
@@ -167,7 +167,7 @@ struct _Eldbus_Service_Interface
    Eina_Hash *properties;
    Eldbus_Property_Set_Cb set_func;
    Eldbus_Property_Get_Cb get_func;
-   Ecore_Idler *idler_propschanged;
+   Ecore_Idle_Enterer *idle_enterer_propschanged;
    Eina_Array *props_changed;
    Eina_Array *prop_invalidated;
 };
index 492e93a..165da86 100644 (file)
@@ -787,7 +787,7 @@ _object_manager_changes_process(void *data)
    Eldbus_Service_Object *obj = data;
    Eldbus_Service_Object *parent = _object_manager_parent_find(obj);
 
-   obj->idler_iface_changed = NULL;
+   obj->idle_enterer_iface_changed = NULL;
 
    if (!parent)
      {
@@ -826,8 +826,8 @@ _eldbus_service_interface_add(Eldbus_Service_Object *obj, const char *interface)
    iface->obj = obj;
    eina_hash_add(obj->interfaces, iface->name, iface);
 
-   if (!obj->idler_iface_changed)
-     obj->idler_iface_changed = ecore_idler_add(_object_manager_changes_process,
+   if (!obj->idle_enterer_iface_changed)
+     obj->idle_enterer_iface_changed = ecore_idle_enterer_add(_object_manager_changes_process,
                                                 obj);
    obj->iface_added = eina_list_append(obj->iface_added, iface);
 
@@ -1019,7 +1019,7 @@ eldbus_service_interface_fallback_register2(Eldbus_Connection *conn, const char
 }
 
 static Eina_Bool
-_idler_propschanged(void *data)
+_idle_enterer_propschanged(void *data)
 {
    Eldbus_Service_Interface *iface = data;
    Eldbus_Message *msg;
@@ -1027,7 +1027,7 @@ _idler_propschanged(void *data)
    Eina_Hash *added = NULL;
    Property *prop;
 
-   iface->idler_propschanged = NULL;
+   iface->idle_enterer_propschanged = NULL;
 
    added = eina_hash_string_small_new(NULL);
    msg = eldbus_message_signal_new(iface->obj->path, properties_iface->name,
@@ -1131,10 +1131,10 @@ _interface_free(Eldbus_Service_Interface *interface)
    /**
     * flush props changes before remove interface
     */
-   if (interface->idler_propschanged)
+   if (interface->idle_enterer_propschanged)
      {
-        ecore_idler_del(interface->idler_propschanged);
-        _idler_propschanged(interface);
+        ecore_idle_enterer_del(interface->idle_enterer_propschanged);
+        _idle_enterer_propschanged(interface);
      }
 
    eina_hash_free(interface->methods);
@@ -1154,17 +1154,17 @@ _interface_free(Eldbus_Service_Interface *interface)
         /* Adding and removing the interface in the same main loop iteration.
          * Let's not send any signal */
         obj->iface_added = eina_list_remove_list(obj->iface_added, l);
-        if (!obj->iface_added && !obj->iface_removed && obj->idler_iface_changed)
+        if (!obj->iface_added && !obj->iface_removed && obj->idle_enterer_iface_changed)
           {
-             ecore_idler_del(obj->idler_iface_changed);
-             obj->idler_iface_changed = NULL;
+             ecore_idle_enterer_del(obj->idle_enterer_iface_changed);
+             obj->idle_enterer_iface_changed = NULL;
           }
      }
    else
      {
-        if (!obj->idler_iface_changed)
+        if (!obj->idle_enterer_iface_changed)
           {
-             obj->idler_iface_changed = ecore_idler_add(
+             obj->idle_enterer_iface_changed = ecore_idle_enterer_add(
                 _object_manager_changes_process, obj);
           }
 
@@ -1191,9 +1191,9 @@ static void _children_ifaces_add_removed_flush(Eldbus_Service_Object *obj)
           _children_ifaces_add_removed_flush(children);
      }
 
-   if (obj->idler_iface_changed)
+   if (obj->idle_enterer_iface_changed)
      {
-        ecore_idler_del(obj->idler_iface_changed);
+        ecore_idle_enterer_del(obj->idle_enterer_iface_changed);
         _object_manager_changes_process(obj);
      }
 }
@@ -1224,9 +1224,9 @@ _object_free(Eldbus_Service_Object *obj)
     * Flush our iface_add/removed if this object are
     * children of some other path with ObjectManager
     */
-   if (obj->idler_iface_changed)
+   if (obj->idle_enterer_iface_changed)
      {
-        ecore_idler_del(obj->idler_iface_changed);
+        ecore_idle_enterer_del(obj->idle_enterer_iface_changed);
         _object_manager_changes_process(obj);
      }
 
@@ -1485,8 +1485,8 @@ eldbus_service_property_changed(const Eldbus_Service_Interface *interface, const
    prop = eina_hash_find(iface->properties, name);
    EINA_SAFETY_ON_NULL_RETURN_VAL(prop, EINA_FALSE);
 
-   if (!iface->idler_propschanged)
-     iface->idler_propschanged = ecore_idler_add(_idler_propschanged, iface);
+   if (!iface->idle_enterer_propschanged)
+     iface->idle_enterer_propschanged = ecore_idle_enterer_add(_idle_enterer_propschanged, iface);
    if (!iface->props_changed)
      iface->props_changed = eina_array_new(1);
 
@@ -1510,8 +1510,8 @@ eldbus_service_property_invalidate_set(const Eldbus_Service_Interface *interface
 
    prop->is_invalidate = is_invalidate;
 
-   if (!iface->idler_propschanged)
-     iface->idler_propschanged = ecore_idler_add(_idler_propschanged, iface);
+   if (!iface->idle_enterer_propschanged)
+     iface->idle_enterer_propschanged = ecore_idle_enterer_add(_idle_enterer_propschanged, iface);
 
    if (is_invalidate)
      {
@@ -1549,8 +1549,8 @@ eldbus_service_object_manager_attach(Eldbus_Service_Interface *iface)
     * with path equal to our path rather than from the previous
     * ObjectManager
     */
-   if (obj->idler_iface_changed)
-     ecore_idler_del(obj->idler_iface_changed);
+   if (obj->idle_enterer_iface_changed)
+     ecore_idle_enterer_del(obj->idle_enterer_iface_changed);
    _object_manager_changes_process(obj);
 
    obj->objmanager = objmanager;