[PATCH] iscsi: clean up pthread properly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is for the pthread branch.

=
From: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
Subject: [PATCH] iscsi: clean up pthread properly

Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
 usr/iscsi/iscsid.h |    1 +
 usr/iscsi/target.c |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/usr/iscsi/iscsid.h b/usr/iscsi/iscsid.h
index 8158e63..91e40d6 100644
--- a/usr/iscsi/iscsid.h
+++ b/usr/iscsi/iscsid.h
@@ -249,6 +249,7 @@ struct iscsi_target {
 	struct list_head events_list;
 
 	struct bs_finish bsfin;
+	int stop_pthread;
 };
 
 enum task_flags {
diff --git a/usr/iscsi/target.c b/usr/iscsi/target.c
index a32667c..3b3eecc 100644
--- a/usr/iscsi/target.c
+++ b/usr/iscsi/target.c
@@ -255,6 +255,15 @@ void iscsi_target_destroy(int tid)
 	}
 
 	list_del(&target->tlist);
+
+	if (target->bsfin.thread) {
+		target->stop_pthread = 1;
+		pthread_kill(target->bsfin.thread, SIGUSR2);
+
+		pthread_join(target->bsfin.thread, NULL);
+		pthread_mutex_destroy(&target->bsfin.finished_lock);
+	}
+
 	close(target->efd);
 	free(target);
 	isns_target_deregister(tgt_targetname(tid));
@@ -291,7 +300,10 @@ retry:
 		}
 	}
 
-	goto retry;
+	if (!t->stop_pthread)
+		goto retry;
+
+	pthread_exit(NULL);
 }
 
 int iscsi_target_create(struct target *t)
-- 
1.6.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux