Fix the crash bug.
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 8 Jun 2012 12:35:30 +0000 (21:35 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Fri, 8 Jun 2012 12:35:30 +0000 (21:35 +0900)
While the master tries to activate instances of liveboxes
The slave is crashed without dead callback invocation (via AUL).
(or timing issue that the provider receives connection failed event first)

In this case,
activate_cb function of instance will be called with "result = NULL".
Then the activate_cb function will try to delete it. (just decrease the
refcnt)

But if the instance is referenced by the other functions,
(such as other requests resize, clicked, etc ...)
The refcnt will not reached to the ZERO even if the activate_cb was
called, so the instance will be kept in alive.

Now the problem is raised.
After executing above routines,
The data provider will forcely terminates the slave to recover this unexpected problem.
(because of the timing issue (or AUL missed send dead event).
--> Data provider just think that the current slave is not terminated but it
couldn't managed request correctly so it will terminates the problem
slave, to recover this problem, it will terminates the slave forcely.

Then the slave deactivate callback will be called and tries to delete
the instances which are recorded as a fault package,
because of the instance refcnt is not reached to ZERO, slave deactivate
callback will destroy thes instances again even if it is already cared
by previous routines.

After processing this routines again, the refcnt will be tained.
So who really references this instance will not be guaranted about this instance.

So, to fix this, I just separate the case of switch statement in the
slave_deactivated_cb.
I prevent decreasing when the state of an instance is "INST_DESTROYED".
(INST_DESTROYED means already someone cares this instance,
so don't try to destroy again from any other stages)

Change-Id: I7b41bcb69ecf8f0f0a82536ab9af57faf0d3b42a

src/package.c
src/slave_rpc.c

index d2a4525..cd2fa21 100644 (file)
@@ -151,11 +151,17 @@ static int slave_deactivated_cb(struct slave_node *slave, void *data)
                                break;
                        case INST_REQUEST_TO_DEACTIVATE:
                        case INST_ACTIVATED:
-                       default:
                                instance_broadcast_deleted_event(inst);
                                instance_deactivated(inst);
                                instance_destroy(inst);
                                break;
+                       case INST_DEACTIVATED:
+                       case INST_DESTROY:
+                       case INST_DESTROYED:
+                       default:
+                               DbgPrint("Package is already destroyed: %s\n",
+                                                       package_name(instance_package(inst)));
+                               break;
                        }
                }
        } else {
index bab35bd..ae73e62 100644 (file)
@@ -151,13 +151,15 @@ static void slave_async_cb(GDBusProxy *proxy, GAsyncResult *result, void *data)
                char *filename;
                char *cmd;
 
+               cmd = packet->cmd ? packet->cmd : "";
+
                if (err) {
-                       ErrPrint("Error: %s\n", err->message);
+                       ErrPrint("package[%s], cmd[%s]: %s\n", packet->pkgname, cmd, err->message);
                        g_error_free(err);
                }
 
                if (packet->ret_cb)
-                       packet->ret_cb(packet->slave, packet->cmd, NULL, packet->cbdata);
+                       packet->ret_cb(packet->slave, cmd, NULL, packet->cbdata);
 
                if (!fault_is_occured() && packet->pkgname) {
                        /*!
@@ -168,7 +170,6 @@ static void slave_async_cb(GDBusProxy *proxy, GAsyncResult *result, void *data)
                         * To fix that case, mark the fault again from here.
                         */
                        filename = packet->filename ? packet->filename : "";
-                       cmd = packet->cmd ? packet->cmd : "";
                        fault_func_call(packet->slave, packet->pkgname, filename, cmd);
                }
 
@@ -413,8 +414,10 @@ int slave_rpc_sync_request(struct slave_node *slave,
        result = g_dbus_proxy_call_sync(rpc->proxy, cmd, param,
                                G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, &err);
        if (!result) {
+               cmd = cmd ? cmd : "";
+
                if (err) {
-                       ErrPrint("Error: %s\n", err->message);
+                       ErrPrint("Package[%s], cmd[%s]: %s\n", pkgname, cmd, err->message);
                        g_error_free(err);
                }
 
@@ -427,7 +430,6 @@ int slave_rpc_sync_request(struct slave_node *slave,
                         * To fix that case, mark the fault again from here.
                         */
                        filename = filename ? filename : "";
-                       cmd = cmd ? cmd : "";
                        fault_func_call(slave, pkgname, filename, cmd);
                }