if (ret < 0)
_E("Failed to get internal storage number.");
}
-
-static void block_exit(void *data)
+static void terminate_threads(void)
{
dd_list *elem, *elem_next;
char *temp;
- int ret, i;
+ int i, count;
+ const int WAIT_TIME = 10;
+
+ for (i = 0; i < THREAD_MAX; i++) {
+ if (th_manager[i].start_th) {
+ count = 0;
+ while ((th_manager[i].op_len != 0) && (count < WAIT_TIME)) {
+ _I("Thread(%d) job is not finished. Wait a second.", th_manager[i].thread_id);
+ usleep(200*1000);
+ count++;
+ }
+ pthread_cancel(th_manager[i].th);
+ pthread_join(th_manager[i].th, NULL);
+ }
+ DD_LIST_FOREACH_SAFE(th_manager[i].th_node_list, elem, elem_next, temp) {
+ DD_LIST_REMOVE(th_manager[i].th_node_list, temp);
+ free(temp);
+ }
+ }
+}
+
+static void block_exit(void *data)
+{
+ int ret;
udev_exit(NULL);
/* remove remaining blocks */
remove_whole_block_device();
- for (i = 0; i < THREAD_MAX; i++) {
- if (th_manager[i].start_th)
- pthread_cancel(th_manager[i].th);
- DD_LIST_FOREACH_SAFE(th_manager[i].th_node_list, elem, elem_next, temp) {
- DD_LIST_REMOVE(th_manager[i].th_node_list, temp);
- free(temp);
- }
- }
+ terminate_threads();
/* exit pipe */
pipe_exit();
if (module->plugin && module->plugin->exit)
module->plugin->exit(NULL);
storaged_close_module(module->plugin);
+ _I("%s closed", module->so_name);
free(module->name);
free(module->so_name);
free(module);