|
|
d087b3 |
From 2c50348a9f93ef81c30d898b5ab8f1e36b927003 Mon Sep 17 00:00:00 2001
|
|
|
d087b3 |
From: Chris Leech <cleech@redhat.com>
|
|
|
d087b3 |
Date: Thu, 18 Aug 2016 13:06:16 -0700
|
|
|
d087b3 |
Subject: [PATCH] Revert "ISCSIUIO: Fixed a pthread resc leak from excessive
|
|
|
d087b3 |
session recovery"
|
|
|
d087b3 |
|
|
|
d087b3 |
This reverts commit fabe160ee191fb57f826d991bcb433dd2467fdc9.
|
|
|
d087b3 |
---
|
|
|
d087b3 |
iscsiuio/RELEASE.TXT | 12 ------------
|
|
|
d087b3 |
iscsiuio/src/unix/iscsid_ipc.c | 26 +++++++++++++-------------
|
|
|
d087b3 |
iscsiuio/src/unix/main.c | 5 +----
|
|
|
d087b3 |
iscsiuio/src/unix/nic.c | 23 +++++++++++++++++++++--
|
|
|
d087b3 |
iscsiuio/src/unix/nic_utils.c | 5 +----
|
|
|
d087b3 |
5 files changed, 36 insertions(+), 35 deletions(-)
|
|
|
d087b3 |
|
|
|
d087b3 |
diff --git a/iscsiuio/RELEASE.TXT b/iscsiuio/RELEASE.TXT
|
|
|
d087b3 |
index 44d67f9..19ef717 100644
|
|
|
d087b3 |
--- a/iscsiuio/RELEASE.TXT
|
|
|
d087b3 |
+++ b/iscsiuio/RELEASE.TXT
|
|
|
d087b3 |
@@ -11,18 +11,6 @@
|
|
|
d087b3 |
Copyright (c) 2014, QLogic Corporation
|
|
|
d087b3 |
All rights reserved
|
|
|
d087b3 |
|
|
|
d087b3 |
-uIP v0.7.10.2 (Feb 12, 2014)
|
|
|
d087b3 |
-=======================================================
|
|
|
d087b3 |
- Fixes
|
|
|
d087b3 |
- -----
|
|
|
d087b3 |
- 1. Problem: Cont00072504 - ifconfig shows allocation failure after
|
|
|
d087b3 |
- up/down few hours with iSCSI + L2 traffic
|
|
|
d087b3 |
- Cause: A memory leak was discovered in the ongoing pthread creation
|
|
|
d087b3 |
- destruction code during the connection recovery process
|
|
|
d087b3 |
- Change: Fixed the pthread creation code
|
|
|
d087b3 |
- Impact: All
|
|
|
d087b3 |
-
|
|
|
d087b3 |
-
|
|
|
d087b3 |
uIP v0.7.8.2 (Dec 10, 2013)
|
|
|
d087b3 |
=======================================================
|
|
|
d087b3 |
Fixes
|
|
|
d087b3 |
diff --git a/iscsiuio/src/unix/iscsid_ipc.c b/iscsiuio/src/unix/iscsid_ipc.c
|
|
|
d087b3 |
index a2a59a8..7790dc5 100644
|
|
|
d087b3 |
--- a/iscsiuio/src/unix/iscsid_ipc.c
|
|
|
d087b3 |
+++ b/iscsiuio/src/unix/iscsid_ipc.c
|
|
|
d087b3 |
@@ -396,9 +396,9 @@ static int parse_iface(void *arg, int do_ping)
|
|
|
d087b3 |
char ipv6_buf_str[INET6_ADDRSTRLEN];
|
|
|
d087b3 |
int request_type = 0;
|
|
|
d087b3 |
struct iface_rec *rec;
|
|
|
d087b3 |
+ void *res;
|
|
|
d087b3 |
struct iface_rec_decode ird;
|
|
|
d087b3 |
struct in_addr src_match, dst_match;
|
|
|
d087b3 |
- pthread_attr_t attr;
|
|
|
d087b3 |
struct ping_conf *png_c;
|
|
|
d087b3 |
|
|
|
d087b3 |
data = (iscsid_uip_broadcast_t *) arg;
|
|
|
d087b3 |
@@ -665,9 +665,7 @@ static int parse_iface(void *arg, int do_ping)
|
|
|
d087b3 |
|
|
|
d087b3 |
nic_iface->flags |= NIC_IFACE_PATHREQ_WAIT1;
|
|
|
d087b3 |
if (nic->nl_process_thread == INVALID_THREAD) {
|
|
|
d087b3 |
- pthread_attr_init(&attr);
|
|
|
d087b3 |
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
|
d087b3 |
- rc = pthread_create(&nic->nl_process_thread, &attr,
|
|
|
d087b3 |
+ rc = pthread_create(&nic->nl_process_thread, NULL,
|
|
|
d087b3 |
nl_process_handle_thread, nic);
|
|
|
d087b3 |
if (rc != 0) {
|
|
|
d087b3 |
LOG_ERR(PFX "%s: Could not create NIC NL "
|
|
|
d087b3 |
@@ -818,16 +816,14 @@ enable_nic:
|
|
|
d087b3 |
case NIC_STOPPED:
|
|
|
d087b3 |
/* This thread will be thrown away when completed */
|
|
|
d087b3 |
if (nic->enable_thread != INVALID_THREAD) {
|
|
|
d087b3 |
- rc = pthread_cancel(nic->enable_thread);
|
|
|
d087b3 |
+ rc = pthread_join(nic->enable_thread, &res;;
|
|
|
d087b3 |
if (rc != 0) {
|
|
|
d087b3 |
- LOG_INFO(PFX "%s: failed to cancel enable NIC "
|
|
|
d087b3 |
+ LOG_INFO(PFX "%s: failed joining enable NIC "
|
|
|
d087b3 |
"thread\n", nic->log_name);
|
|
|
d087b3 |
goto eagain;
|
|
|
d087b3 |
}
|
|
|
d087b3 |
}
|
|
|
d087b3 |
- pthread_attr_init(&attr);
|
|
|
d087b3 |
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
|
d087b3 |
- rc = pthread_create(&nic->enable_thread, &attr,
|
|
|
d087b3 |
+ rc = pthread_create(&nic->enable_thread, NULL,
|
|
|
d087b3 |
enable_nic_thread, (void *)nic);
|
|
|
d087b3 |
if (rc != 0)
|
|
|
d087b3 |
LOG_WARN(PFX "%s: failed starting enable NIC thread\n",
|
|
|
d087b3 |
@@ -1169,12 +1165,9 @@ error:
|
|
|
d087b3 |
*/
|
|
|
d087b3 |
int iscsid_start()
|
|
|
d087b3 |
{
|
|
|
d087b3 |
- pthread_attr_t attr;
|
|
|
d087b3 |
int rc;
|
|
|
d087b3 |
|
|
|
d087b3 |
- pthread_attr_init(&attr);
|
|
|
d087b3 |
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
|
d087b3 |
- rc = pthread_create(&iscsid_opts.thread, &attr, iscsid_loop, NULL);
|
|
|
d087b3 |
+ rc = pthread_create(&iscsid_opts.thread, NULL, iscsid_loop, NULL);
|
|
|
d087b3 |
if (rc != 0) {
|
|
|
d087b3 |
LOG_ERR(PFX "Could not start iscsid listening thread rc=%d",
|
|
|
d087b3 |
rc);
|
|
|
d087b3 |
@@ -1197,6 +1190,7 @@ error:
|
|
|
d087b3 |
void iscsid_cleanup()
|
|
|
d087b3 |
{
|
|
|
d087b3 |
int rc;
|
|
|
d087b3 |
+ void *res;
|
|
|
d087b3 |
|
|
|
d087b3 |
if (iscsid_opts.fd != INVALID_FD) {
|
|
|
d087b3 |
rc = pthread_cancel(iscsid_opts.thread);
|
|
|
d087b3 |
@@ -1204,6 +1198,12 @@ void iscsid_cleanup()
|
|
|
d087b3 |
LOG_ERR("Could not cancel iscsid listening thread: %s",
|
|
|
d087b3 |
strerror(rc));
|
|
|
d087b3 |
}
|
|
|
d087b3 |
+
|
|
|
d087b3 |
+ rc = pthread_join(iscsid_opts.thread, &res;;
|
|
|
d087b3 |
+ if (rc != 0) {
|
|
|
d087b3 |
+ LOG_ERR("Could not wait for the iscsid listening "
|
|
|
d087b3 |
+ "thread: %s", strerror(rc));
|
|
|
d087b3 |
+ }
|
|
|
d087b3 |
}
|
|
|
d087b3 |
|
|
|
d087b3 |
LOG_INFO(PFX "iscsid listening thread has shutdown");
|
|
|
d087b3 |
diff --git a/iscsiuio/src/unix/main.c b/iscsiuio/src/unix/main.c
|
|
|
d087b3 |
index c1a72d8..bbf8f9c 100644
|
|
|
d087b3 |
--- a/iscsiuio/src/unix/main.c
|
|
|
d087b3 |
+++ b/iscsiuio/src/unix/main.c
|
|
|
d087b3 |
@@ -236,7 +236,6 @@ int main(int argc, char *argv[])
|
|
|
d087b3 |
int fd;
|
|
|
d087b3 |
int foreground = 0;
|
|
|
d087b3 |
pid_t pid;
|
|
|
d087b3 |
- pthread_attr_t attr;
|
|
|
d087b3 |
|
|
|
d087b3 |
/* Record the start time for the user space daemon */
|
|
|
d087b3 |
opt.start_time = time(NULL);
|
|
|
d087b3 |
@@ -366,9 +365,7 @@ int main(int argc, char *argv[])
|
|
|
d087b3 |
rc = pthread_sigmask(SIG_SETMASK, &set, NULL);
|
|
|
d087b3 |
|
|
|
d087b3 |
/* Spin off the signal handling thread */
|
|
|
d087b3 |
- pthread_attr_init(&attr);
|
|
|
d087b3 |
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
|
d087b3 |
- rc = pthread_create(&signal_thread, &attr, signal_handle_thread, NULL);
|
|
|
d087b3 |
+ rc = pthread_create(&signal_thread, NULL, signal_handle_thread, NULL);
|
|
|
d087b3 |
if (rc != 0)
|
|
|
d087b3 |
LOG_ERR("Could not create signal handling thread");
|
|
|
d087b3 |
|
|
|
d087b3 |
diff --git a/iscsiuio/src/unix/nic.c b/iscsiuio/src/unix/nic.c
|
|
|
d087b3 |
index 74b7c5e..0d4965d 100644
|
|
|
d087b3 |
--- a/iscsiuio/src/unix/nic.c
|
|
|
d087b3 |
+++ b/iscsiuio/src/unix/nic.c
|
|
|
d087b3 |
@@ -465,6 +465,7 @@ int nic_remove(nic_t *nic)
|
|
|
d087b3 |
int rc;
|
|
|
d087b3 |
nic_t *prev, *current;
|
|
|
d087b3 |
struct stat file_stat;
|
|
|
d087b3 |
+ void *res;
|
|
|
d087b3 |
nic_interface_t *nic_iface, *next_nic_iface, *vlan_iface;
|
|
|
d087b3 |
|
|
|
d087b3 |
pthread_mutex_lock(&nic->nic_mutex);
|
|
|
d087b3 |
@@ -487,6 +488,12 @@ int nic_remove(nic_t *nic)
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: Couldn't send cancel to nic enable "
|
|
|
d087b3 |
"thread", nic->log_name);
|
|
|
d087b3 |
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Waiting to join nic enable thread",
|
|
|
d087b3 |
+ nic->log_name);
|
|
|
d087b3 |
+ rc = pthread_join(nic->enable_thread, &res;;
|
|
|
d087b3 |
+ if (rc != 0)
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Couldn't join to canceled enable "
|
|
|
d087b3 |
+ "nic thread", nic->log_name);
|
|
|
d087b3 |
nic->enable_thread = INVALID_THREAD;
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: nic enable thread cleaned", nic->log_name);
|
|
|
d087b3 |
} else {
|
|
|
d087b3 |
@@ -502,6 +509,11 @@ int nic_remove(nic_t *nic)
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: Couldn't send cancel to nic",
|
|
|
d087b3 |
nic->log_name);
|
|
|
d087b3 |
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Waiting to join nic thread", nic->log_name);
|
|
|
d087b3 |
+ rc = pthread_join(nic->thread, &res;;
|
|
|
d087b3 |
+ if (rc != 0)
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Couldn't join to canceled nic "
|
|
|
d087b3 |
+ "thread", nic->log_name);
|
|
|
d087b3 |
nic->thread = INVALID_THREAD;
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: nic thread cleaned", nic->log_name);
|
|
|
d087b3 |
} else {
|
|
|
d087b3 |
@@ -516,6 +528,12 @@ int nic_remove(nic_t *nic)
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: Couldn't send cancel to nic nl "
|
|
|
d087b3 |
"thread", nic->log_name);
|
|
|
d087b3 |
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Waiting to join nic nl thread",
|
|
|
d087b3 |
+ nic->log_name);
|
|
|
d087b3 |
+ rc = pthread_join(nic->nl_process_thread, &res;;
|
|
|
d087b3 |
+ if (rc != 0)
|
|
|
d087b3 |
+ LOG_DEBUG(PFX "%s: Couldn't join to canceled nic nl "
|
|
|
d087b3 |
+ "thread", nic->log_name);
|
|
|
d087b3 |
nic->nl_process_thread = INVALID_THREAD;
|
|
|
d087b3 |
LOG_DEBUG(PFX "%s: nic nl thread cleaned", nic->log_name);
|
|
|
d087b3 |
} else {
|
|
|
d087b3 |
@@ -1236,6 +1254,7 @@ static int do_acquisition(nic_t *nic, nic_interface_t *nic_iface,
|
|
|
d087b3 |
{
|
|
|
d087b3 |
struct in_addr addr;
|
|
|
d087b3 |
struct in6_addr addr6;
|
|
|
d087b3 |
+ void *res;
|
|
|
d087b3 |
char buf[INET6_ADDRSTRLEN];
|
|
|
d087b3 |
int rc = -1;
|
|
|
d087b3 |
|
|
|
d087b3 |
@@ -1309,9 +1328,9 @@ static int do_acquisition(nic_t *nic, nic_interface_t *nic_iface,
|
|
|
d087b3 |
if (nic->enable_thread == INVALID_THREAD)
|
|
|
d087b3 |
goto dhcp_err;
|
|
|
d087b3 |
|
|
|
d087b3 |
- rc = pthread_cancel(nic->enable_thread);
|
|
|
d087b3 |
+ rc = pthread_join(nic->enable_thread, &res;;
|
|
|
d087b3 |
if (rc != 0)
|
|
|
d087b3 |
- LOG_ERR(PFX "%s: Couldn't cancel "
|
|
|
d087b3 |
+ LOG_ERR(PFX "%s: Couldn't join to canceled "
|
|
|
d087b3 |
"enable nic thread", nic->log_name);
|
|
|
d087b3 |
dhcp_err:
|
|
|
d087b3 |
pthread_mutex_lock(&nic->nic_mutex);
|
|
|
d087b3 |
diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c
|
|
|
d087b3 |
index 0daffd2..cbed986 100644
|
|
|
d087b3 |
--- a/iscsiuio/src/unix/nic_utils.c
|
|
|
d087b3 |
+++ b/iscsiuio/src/unix/nic_utils.c
|
|
|
d087b3 |
@@ -893,7 +893,6 @@ error:
|
|
|
d087b3 |
|
|
|
d087b3 |
void prepare_nic_thread(nic_t *nic)
|
|
|
d087b3 |
{
|
|
|
d087b3 |
- pthread_attr_t attr;
|
|
|
d087b3 |
int rc;
|
|
|
d087b3 |
|
|
|
d087b3 |
pthread_mutex_lock(&nic->nic_mutex);
|
|
|
d087b3 |
@@ -904,9 +903,7 @@ void prepare_nic_thread(nic_t *nic)
|
|
|
d087b3 |
LOG_INFO(PFX "%s: spinning up thread for nic", nic->log_name);
|
|
|
d087b3 |
|
|
|
d087b3 |
/* Try to spin up the nic thread */
|
|
|
d087b3 |
- pthread_attr_init(&attr);
|
|
|
d087b3 |
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
|
|
d087b3 |
- rc = pthread_create(&nic->thread, &attr, nic_loop, nic);
|
|
|
d087b3 |
+ rc = pthread_create(&nic->thread, NULL, nic_loop, nic);
|
|
|
d087b3 |
if (rc != 0) {
|
|
|
d087b3 |
LOG_ERR(PFX "%s: Couldn't create thread for nic",
|
|
|
d087b3 |
nic->log_name);
|
|
|
d087b3 |
--
|
|
|
d087b3 |
2.5.5
|
|
|
d087b3 |
|