Fix for possible requirsive target_mutex taking
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Wed, 17 Mar 2010 19:41:16 +0000 (19:41 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Wed, 17 Mar 2010 19:41:16 +0000 (19:41 +0000)
git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1554 d57e44dd-8a1f-0410-8b47-8ef2f437770f

iscsi-scst/kernel/target.c

index b72fbd9..807d834 100644 (file)
@@ -350,11 +350,11 @@ void target_del_all(void)
                list_for_each_entry_safe(target, t, &target_list,
                                         target_list_entry) {
                        mutex_lock(&target->target_mutex);
+
                        if (!list_empty(&target->session_list)) {
                                target_del_all_sess(target,
                                        ISCSI_CONN_ACTIVE_CLOSE |
                                        ISCSI_CONN_DELETING);
-                               mutex_unlock(&target->target_mutex);
                        } else if (!first) {
                                TRACE_MGMT_DBG("Deleting target %p", target);
                                list_del(&target->target_list_entry);
@@ -363,6 +363,8 @@ void target_del_all(void)
                                target_destroy(target);
                                continue;
                        }
+
+                       mutex_unlock(&target->target_mutex);
                }
                mutex_unlock(&target_mgmt_mutex);
                msleep(100);