summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2013-10-29 14:07:42 +0000
committertrasz <trasz@FreeBSD.org>2013-10-29 14:07:42 +0000
commit2d60d1851a80cfae2603a0ed8a5b19372d8b77ba (patch)
tree0847c1c37243b207414d4c006854ab6ca2ac5f65
parentc259ad5c52d8c181fa6db5c04f87dc66435b54a5 (diff)
downloadFreeBSD-src-2d60d1851a80cfae2603a0ed8a5b19372d8b77ba.zip
FreeBSD-src-2d60d1851a80cfae2603a0ed8a5b19372d8b77ba.tar.gz
MFC r257061:
Don't spin with mutex hold when there is not enough room in the send socket buffer. While here, make the code flow somewhat nicer. Thanks to mav@ for tracking it down. Approved by: re (glebius)
-rw-r--r--sys/dev/iscsi/icl.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/sys/dev/iscsi/icl.c b/sys/dev/iscsi/icl.c
index cf58dfd..f29f0d2 100644
--- a/sys/dev/iscsi/icl.c
+++ b/sys/dev/iscsi/icl.c
@@ -723,11 +723,7 @@ icl_receive_thread(void *arg)
for (;;) {
if (ic->ic_disconnecting) {
//ICL_DEBUG("terminating");
- ICL_CONN_LOCK(ic);
- ic->ic_receive_running = false;
- ICL_CONN_UNLOCK(ic);
- kthread_exit();
- return;
+ break;
}
SOCKBUF_LOCK(&so->so_rcv);
@@ -740,6 +736,11 @@ icl_receive_thread(void *arg)
icl_conn_receive_pdus(ic, available);
}
+
+ ICL_CONN_LOCK(ic);
+ ic->ic_receive_running = false;
+ ICL_CONN_UNLOCK(ic);
+ kthread_exit();
}
static int
@@ -879,22 +880,19 @@ icl_send_thread(void *arg)
ICL_CONN_LOCK(ic);
ic->ic_send_running = true;
- ICL_CONN_UNLOCK(ic);
for (;;) {
- ICL_CONN_LOCK(ic);
if (ic->ic_disconnecting) {
//ICL_DEBUG("terminating");
- ic->ic_send_running = false;
- ICL_CONN_UNLOCK(ic);
- kthread_exit();
- return;
+ break;
}
- if (TAILQ_EMPTY(&ic->ic_to_send))
- cv_wait(&ic->ic_send_cv, &ic->ic_lock);
icl_conn_send_pdus(ic);
- ICL_CONN_UNLOCK(ic);
+ cv_wait(&ic->ic_send_cv, &ic->ic_lock);
}
+
+ ic->ic_send_running = false;
+ ICL_CONN_UNLOCK(ic);
+ kthread_exit();
}
static int
OpenPOWER on IntegriCloud