Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Mar 2018 05:25:38 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r331607 - projects/bsd_rdma_4_9_stable_11/sys/dev/cxgbe/iw_cxgbe
Message-ID:  <201803270525.w2R5PcNA089382@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: np
Date: Tue Mar 27 05:25:38 2018
New Revision: 331607
URL: https://svnweb.freebsd.org/changeset/base/331607

Log:
  Make a private copy of dequeue_socket from existing iwcm in 11 and use
  it instead of solisten_dequeue, which exists only in FreeBSD 12+.

Modified:
  projects/bsd_rdma_4_9_stable_11/sys/dev/cxgbe/iw_cxgbe/cm.c

Modified: projects/bsd_rdma_4_9_stable_11/sys/dev/cxgbe/iw_cxgbe/cm.c
==============================================================================
--- projects/bsd_rdma_4_9_stable_11/sys/dev/cxgbe/iw_cxgbe/cm.c	Tue Mar 27 03:37:04 2018	(r331606)
+++ projects/bsd_rdma_4_9_stable_11/sys/dev/cxgbe/iw_cxgbe/cm.c	Tue Mar 27 05:25:38 2018	(r331607)
@@ -1090,6 +1090,40 @@ terminate(struct sge_iq *iq, const struct rss_header *
 	return 0;
 }
 
+static struct socket *
+dequeue_socket(struct socket *head)
+{
+	struct socket *so;
+	struct sockaddr_in *remote;
+
+	ACCEPT_LOCK();
+	so = TAILQ_FIRST(&head->so_comp);
+	if (!so) {
+		ACCEPT_UNLOCK();
+		return NULL;
+	}
+
+	SOCK_LOCK(so);
+	/*
+	 * Before changing the flags on the socket, we have to bump the
+	 * reference count.  Otherwise, if the protocol calls sofree(),
+	 * the socket will be released due to a zero refcount.
+	 */
+	soref(so);
+	TAILQ_REMOVE(&head->so_comp, so, so_list);
+	head->so_qlen--;
+	so->so_qstate &= ~SQ_COMP;
+	so->so_head = NULL;
+	so->so_state |= SS_NBIO;
+	SOCK_UNLOCK(so);
+	ACCEPT_UNLOCK();
+	remote = NULL;
+	soaccept(so, (struct sockaddr **)&remote);
+
+	free(remote, M_SONAME);
+	return so;
+}
+
 static void
 process_socket_event(struct c4iw_ep *ep)
 {
@@ -1113,28 +1147,11 @@ process_socket_event(struct c4iw_ep *ep)
 
 	if (state == LISTEN) {
 		struct c4iw_listen_ep *lep = (struct c4iw_listen_ep *)ep;
-		struct socket *listen_so = so, *new_so = NULL;
-		int error = 0;
+		struct socket *new_so;
 
-		SOLISTEN_LOCK(listen_so);
-		do {
-			error = solisten_dequeue(listen_so, &new_so,
-						SOCK_NONBLOCK);
-			if (error) {
-				CTR4(KTR_IW_CXGBE, "%s: lep %p listen_so %p "
-					"error %d", __func__, lep, listen_so,
-					error);
-				return;
-			}
+		while ((new_so = dequeue_socket(so)) != NULL) {
 			process_newconn(lep, new_so);
-
-			/* solisten_dequeue() unlocks while return, so aquire
-			 * lock again for sol_qlen and also for next iteration.
-			 */
-			SOLISTEN_LOCK(listen_so);
-		} while (listen_so->sol_qlen);
-		SOLISTEN_UNLOCK(listen_so);
-
+		}
 		return;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803270525.w2R5PcNA089382>