svn commit: r257339 - stable/10/sys/dev/iscsi

Edward Tomasz Napierala trasz at FreeBSD.org
Tue Oct 29 14:07:42 UTC 2013


Author: trasz
Date: Tue Oct 29 14:07:42 2013
New Revision: 257339
URL: http://svnweb.freebsd.org/changeset/base/257339

Log:
  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)

Modified:
  stable/10/sys/dev/iscsi/icl.c
Directory Properties:
  stable/10/sys/   (props changed)

Modified: stable/10/sys/dev/iscsi/icl.c
==============================================================================
--- stable/10/sys/dev/iscsi/icl.c	Tue Oct 29 14:07:31 2013	(r257338)
+++ stable/10/sys/dev/iscsi/icl.c	Tue Oct 29 14:07:42 2013	(r257339)
@@ -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


More information about the svn-src-all mailing list