Add libmtp dump errorstack when operation failed 97/306197/3 accepted/tizen_unified_dev accepted/tizen/unified/20240219.160407 accepted/tizen/unified/dev/20240620.005344 accepted/tizen/unified/toolchain/20240311.065313 accepted/tizen/unified/x/20240220.150033
authorJihoon Jung <jh8801.jung@samsung.com>
Mon, 19 Feb 2024 01:18:59 +0000 (10:18 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Mon, 19 Feb 2024 01:31:37 +0000 (10:31 +0900)
- sync with product branch
- And, rollback unused multitaget implement

Change-Id: Ic66b22fdcdc288cf6a935c9b1bd9bccb34dbe258
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
packaging/mtp-initiator.service
packaging/mtp-initiator.spec
src/daemon/mtp_daemon.c
src/daemon/mtp_daemon_event.c
src/daemon/mtp_daemon_gdbus_manager.c

index b95953eab0f16ba1d569e2ad54bf33eab2693263..bb93ef3a5ce15b1e02463f7780d39c330974e9e8 100755 (executable)
@@ -10,6 +10,3 @@ SmackProcessLabel=System
 SupplementaryGroups=priv_mediastorage priv_externalstorage
 ExecStart=/usr/bin/mtp-initiator
 KillMode=process
-
-[Install]
-WantedBy=multi-user.target
index 64f12f16274476a5e9284ef1968f352976ab65ea..0d8184821a7a3e6f7d61e079e7c5e9afd933ea89 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mtp-initiator
 Summary:    mtp(media transfer protocol) initiator
-Version:    1.4.34
+Version:    1.4.37
 Release:    0
 Group:      Network & Connectivity/Other
 License:    Apache-2.0
@@ -93,16 +93,12 @@ cp -af ./lib/udev/rules.d/*.rules  %{buildroot}/%{_prefix}/lib/udev/rules.d/
 
 install -D -m 0644 packaging/mtp-initiator.service %{buildroot}/%{_unitdir}/mtp-initiator.service
 
-mkdir -p %{buildroot}/%{_unitdir}/multi-user.target.wants
-ln -s ../%{name}.service %{buildroot}/%{_unitdir}/multi-user.target.wants/mtp-initiator.service
-
 %files
 %manifest %{name}.manifest
 %license LICENSE.APLv2
 %defattr(-,root,root,-)
 %{_bindir}/mtp-initiator
 %{_unitdir}/mtp-initiator.service
-%{_unitdir}/multi-user.target.wants/mtp-initiator.service
 %{_prefix}/lib/udev/rules.d/99-mtp.rules
 %config %{_sysconfdir}/dbus-1/system.d/org.tizen.mtp.conf
 %if 0%{?gtests:1}
index 1a898e27fee13f6d6749d2f8b683b1daaf4321bc..49487975148008d5d8cb45fab5f3e3460dd8d6b2 100644 (file)
@@ -88,6 +88,11 @@ static mtp_error_e __daemon_deinitalize(mtp_context *mtp_ctx)
                MTP_LOGI("controller thread join end");
        }
 
+       if (mtp_ctx->usb_ctx != NULL) {
+               MTP_LOGI("usb interrupt event handler");
+               libusb_interrupt_event_handler(mtp_ctx->usb_ctx);
+       }
+
        if (mtp_ctx->usb_event_thread != NULL) {
                MTP_LOGI("usb event thread join start");
                g_thread_join(mtp_ctx->usb_event_thread);
@@ -124,6 +129,7 @@ static void __mtp_signal_handler(int signo)
 
        switch (signo) {
        case SIGTERM:
+               _mtp_ctx->is_running = false;
                g_main_loop_quit(_mtp_ctx->main_loop);
                MTP_LOGD("SIGTERM");
                break;
@@ -137,18 +143,6 @@ static void __mtp_signal_handler(int signo)
        return;
 }
 
-static bool __exists_mtp_devices(void)
-{
-       LIBMTP_raw_device_t *devices;
-       int num_of_devices = 0;
-
-       LIBMTP_Init();
-       LIBMTP_Detect_Raw_Devices(&devices, &num_of_devices);
-       free(devices);
-
-       return num_of_devices > 0 ? true : false;
-}
-
 int main(int argc, char *argv[])
 {
        mtp_context *mtp_ctx = NULL;
@@ -157,11 +151,6 @@ int main(int argc, char *argv[])
 
        MTP_LOGE("mtp initiator start");
 
-       if (__exists_mtp_devices() == false) {
-               MTP_LOGE("There are not mtp devices");
-               return 0;
-       }
-
        remove(MTP_DB_FILE);
 
        /* 1. signal registration */
@@ -205,7 +194,8 @@ EXIT:
        MTP_LOGI("mtp initiator exit process start"); //LCOV_EXCL_LINE
        if (mtp_ctx != NULL && mtp_ctx->device_list != NULL
                && mtp_ctx->device_list->threads != NULL) {
-               g_thread_pool_free(mtp_ctx->device_list->threads, true, true);
+               g_thread_pool_free(mtp_ctx->device_list->threads, true, false);
+               MTP_LOGI("g_thread_pool free successful");
        }
 
        /* LCOV_EXCL_START */
index 7121d8f209e788b2ef87c5dd475d542e8e3fd082..6ec47849d3220c47e49e2029919f04ef5a10fc16 100755 (executable)
@@ -236,6 +236,9 @@ static void* __event_thread(gpointer dev, gpointer data)
                                        mtp_daemon_db_update(device_id, param1, object_info, mtp_ctx);
                                else
                                        mtp_daemon_db_insert(device_id, object_info->StorageID, param1, object_info, mtp_ctx);
+                       } else {
+                               LIBMTP_Dump_Errorstack(device);
+                               LIBMTP_Clear_Errorstack(device);
                        }
 
                        g_free(object_info);
index 8b08ebb5eaee01152996a72446352e7303b193f9..d2136a9b2e9163c2f62fbba0c266a89a5803cc21 100755 (executable)
@@ -211,6 +211,8 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
 
                if (object_info == NULL) {
                        MTP_LOGE("object info is NULL");
+                       LIBMTP_Dump_Errorstack(device);
+                       LIBMTP_Clear_Errorstack(device);
                        result = MTP_ERROR_PLUGIN_FAIL;
                        goto END;
                }
@@ -228,8 +230,12 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
                (uint32_t)format, (uint32_t)parent_object_handle,
                (uint32_t **)&object_list, (uint32_t *)&total_object_num);
 
-       if (ret < 0)
+       if (ret < 0) {
                MTP_LOGE("LIBMTP_Get_Object_Handles is failed : %d", ret);
+               LIBMTP_Dump_Errorstack(device);
+               LIBMTP_Clear_Errorstack(device);
+               goto END;
+       }
 
        mtp_daemon_db_begin(param->mtp_ctx);
 
@@ -239,8 +245,12 @@ static void __manager_get_object_handles_thread_func(gpointer user_data)
                if (mtp_daemon_db_is_exist(device_id, mtp_storage, object_list[slot], param->mtp_ctx) == false) {
                        object_info = LIBMTP_Get_Object_Info(device, (uint32_t)object_list[slot]);
 
-                       if (object_info != NULL)
+                       if (object_info != NULL) {
                                mtp_daemon_db_insert(device_id, mtp_storage, object_list[slot], object_info, param->mtp_ctx);
+                       } else {
+                               LIBMTP_Dump_Errorstack(device);
+                               LIBMTP_Clear_Errorstack(device);
+                       }
                } else {
                        object_info = mtp_daemon_db_get_object_info(device_id, object_list[slot], param->mtp_ctx);
                }
@@ -332,6 +342,8 @@ static void __manager_get_object_thread_func(gpointer user_data)
                        if (ret != 0) {
                                /* LCOV_EXCL_START */
                                MTP_LOGE("get descriptor fail - ret: %d", ret);
+                               LIBMTP_Dump_Errorstack(device);
+                               LIBMTP_Clear_Errorstack(device);
                                result = MTP_ERROR_PLUGIN_FAIL;
                                /* LCOV_EXCL_STOP */
                        }
@@ -414,6 +426,8 @@ static void __manager_get_partial_object_thread_func(gpointer user_data)
                                /* LCOV_EXCL_STOP */
                        } else {
                                MTP_LOGE("get partial object fail - ret: %d", ret);
+                               LIBMTP_Dump_Errorstack(device);
+                               LIBMTP_Clear_Errorstack(device);
                                result = MTP_ERROR_PLUGIN_FAIL;
                        }
 
@@ -484,17 +498,19 @@ static void __manager_get_thumbnail_thread_func(gpointer user_data)
                        result = MTP_ERROR_IO_ERROR;
                        /* LCOV_EXCL_STOP */
                } else {
-                       ret = LIBMTP_Get_Thumbnail_From_Exif_Data(device, object_handle, &thumb_data, &thumb_size);
-                       if (ret != 0)
-                               ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
+                       MTP_LOGI("get thumbnail start. object_handle : %d, dest_path : %s", object_handle, dest_path);
+                       ret = LIBMTP_Get_Thumbnail(device, object_handle, &thumb_data, &thumb_size);
 
                        if (ret == 0) {
+                               MTP_LOGI("get thumbnail end. thumb_size : %d", thumb_size);
                                ret = write(fd, thumb_data, thumb_size);
                                if (ret == 0)
                                        result = MTP_ERROR_OUT_OF_MEMORY;
                        } else {
                                /* LCOV_EXCL_START */
                                MTP_LOGE("get thumbnail fail - ret: %d", ret);
+                               LIBMTP_Dump_Errorstack(device);
+                               LIBMTP_Clear_Errorstack(device);
                                result = MTP_ERROR_PLUGIN_FAIL;
                                /* LCOV_EXCL_STOP */
                        }
@@ -550,8 +566,11 @@ static void __manager_delete_object_thread_func(gpointer user_data)
                object_handle = param->param2;
 
                ret = LIBMTP_Delete_Object(device, object_handle);
-               if (ret != 0)
+               if (ret != 0) {
+                       LIBMTP_Dump_Errorstack(device);
+                       LIBMTP_Clear_Errorstack(device);
                        result = MTP_ERROR_PLUGIN_FAIL;
+               }
        } else {
                /* LCOV_EXCL_START */
                MTP_LOGE("No MTP device");