Blob Blame History Raw
From: Chris Leech <cleech@redhat.com>
Subject: Fix iscsiuio segfault when shutting down.

Bugzilla: ZZZ
Upstream Status:
Build Info: XXX
Tested:

commit 2bdcae8a9969295183377342cfe218d1c5d263db
Author: Lee Duncan <lduncan@suse.com>
Date:   Thu May 31 08:42:58 2018 -0700

    Fix iscsiuio segfault when shutting down.
    
    If iscsiuio is stopped when first starting up, it can easily
    hit a window where pthread_cancel() is called before pthread_create()
    finishesx The problem was found by kiyo@jp.fujitsu.com, who also
    proposed the fix.
---
 iscsiuio/src/unix/iscsid_ipc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
index d4322350fcf6..2acac485af72 100644
--- a/iscsiuio/src/unix/iscsid_ipc.c
+++ b/iscsiuio/src/unix/iscsid_ipc.c
@@ -1245,7 +1245,8 @@ void iscsid_cleanup()
 {
 	int rc;
 
-	if (iscsid_opts.fd != INVALID_FD) {
+	if (iscsid_opts.fd != INVALID_FD &&
+	    iscsid_opts.thread != INVALID_THREAD) {
 		rc = pthread_cancel(iscsid_opts.thread);
 		if (rc != 0) {
 			LOG_ERR("Could not cancel iscsid listening thread: %s",