block: Do not use dbus method call on block thread 77/117577/7
authorpr.jung <pr.jung@samsung.com>
Mon, 6 Mar 2017 12:33:56 +0000 (21:33 +0900)
committerpr.jung <pr.jung@samsung.com>
Wed, 8 Mar 2017 05:09:08 +0000 (14:09 +0900)
- When deviced use dbus method call on block thread,
there will be ecore_timer_add call from outside of the main loop thread.

Change-Id: I707dd9fe0d894d696d075591dc22895d9d3ba95d
Signed-off-by: pr.jung <pr.jung@samsung.com>
src/block/block.c

index 0a998c4..01d0352 100644 (file)
@@ -880,6 +880,17 @@ static char *get_operation_char(enum block_dev_operation op,
        return name;
 }
 
+static void create_external_apps_directory(void)
+{
+       int ret;
+
+       ret = dbus_method_async(PKGDIR_BUS_NAME, PKGDIR_PATH,
+                       PKGDIR_INTERFACE, "CreateExternalDirsForAllPkgs",
+                       NULL, NULL);
+       if (ret)
+               _E("Fail to create external directory");
+}
+
 static int pipe_trigger(enum block_dev_operation op,
                struct block_device *bdev, int result)
 {
@@ -935,6 +946,11 @@ static Eina_Bool pipe_cb(void *data, Ecore_Fd_Handler *fdh)
                }
                goto out;
        }
+       if (pdata.op == BLOCK_DEV_MOUNT &&
+               pdata.bdev->data->state == BLOCK_MOUNT &&
+               pdata.bdev->data->block_type == BLOCK_MMC_DEV &&
+               pdata.bdev->data->primary)
+               create_external_apps_directory();
 
        /* Broadcast to mmc and usb storage module */
        broadcast_block_info(pdata.op, pdata.bdev->data, pdata.result);
@@ -1133,12 +1149,9 @@ out:
 
 static int mount_start(struct block_device *bdev)
 {
-       DBusMessage *msg;
-       DBusError err;
        struct block_data *data;
-       int r;
        int ret;
-       bool ret_val;
+       int r;
 
        assert(bdev);
        assert(bdev->data);
@@ -1162,25 +1175,10 @@ static int mount_start(struct block_device *bdev)
        data->state = BLOCK_MOUNT;
 
        if (data->block_type == BLOCK_MMC_DEV) {
+               /* app2ext_migrate_legacy_all has dbus method call to deviced */
                ret = app2ext_migrate_legacy_all();
                if (ret < 0)
                        _E("app2ext failed");
-
-               msg = dbus_method_sync_with_reply(PKGDIR_BUS_NAME, PKGDIR_PATH,
-                               PKGDIR_INTERFACE, "CreateExternalDirsForAllPkgs",
-                               NULL, NULL);
-               if (!msg) {
-                       _E("Fail to create external directory");
-                       goto out;
-               }
-
-               dbus_error_init(&err);
-
-               ret = dbus_message_get_args(msg, &err, DBUS_TYPE_BOOLEAN, &ret_val, DBUS_TYPE_INVALID);
-               if (!ret) {
-                       _E("no message : [%s:%s]", err.name, err.message);
-                       dbus_error_free(&err);
-               }
        }
 
 out:
@@ -1263,11 +1261,6 @@ static int block_unmount(struct block_device *bdev,
        if (bdev->on_private_op == REQ_NORMAL)
                signal_device_blocked(bdev);
 
-       /* Need to disble app2ext whenever unmounting mmc */
-       if (data->block_type == BLOCK_MMC_DEV && data->primary)
-               if (app2ext_disable_all_external_pkgs() < 0)
-                       _E("app2ext_disable_all_external_pkgs() failed");
-
        /* it must called before unmounting mmc */
        r = mmc_check_and_unmount(data->mount_point);
        if (!r)
@@ -1315,11 +1308,6 @@ static int block_unmount(struct block_device *bdev,
                time.tv_nsec = 500 * NANO_SECOND_MULTIPLIER;
                nanosleep(&time, NULL);
 
-               /* Need to disble app2ext whenever unmounting mmc */
-               if (data->block_type == BLOCK_MMC_DEV && data->primary)
-                       if (app2ext_disable_all_external_pkgs() < 0)
-                               _E("app2ext_disable_all_external_pkgs() failed");
-
                print_open_files(data->mount_point);
 
                r = mmc_check_and_unmount(data->mount_point);
@@ -1978,6 +1966,15 @@ static int add_operation(struct block_device *bdev,
        pthread_mutex_unlock(&(th_manager[thread_id].mutex));
        /* UNLOCK */
 
+       /* Need to disble app2ext whenever unmounting mmc */
+       if (op->op == BLOCK_DEV_UNMOUNT &&
+               bdev->data->state == BLOCK_MOUNT &&
+               bdev->data->block_type == BLOCK_MMC_DEV &&
+               bdev->data->primary)
+               if (app2ext_disable_all_external_pkgs() < 0)
+                       _E("app2ext_disable_all_external_pkgs() failed");
+
+
        if (start_th) {
                _D("Start New thread for block device");
                th_manager[thread_id].start_th = false;