Skip to contentSkip to conversation

rsockets: Support calling listen multiple times on same rsocket

PATCH In review [email protected] 2 participants 2 messages Sep 4, 2014 – Sep 5, 2014 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rsockets: Support calling listen multiple times on same rsocket

From: Sean Hefty <[email protected]>

Standard sockets allows an application to call listen() multiple times on the same socket without error. This allows a multi-threaded app to call listen from all threads.

rsockets will fail the second listen call. Modify the behavior to match standard sockets.

Problem reported by: Sreedhar Kodali <[email protected]>

---
 src/rsocket.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
src/rsocket.c +8 -3
index 00d9a18..4833810 100644
@@ -1174,9 +1174,14 @@ int rlisten(int socket, int backlog)
 	rs = idm_lookup(&idm, socket);
 	if (!rs)
 		return ERR(EBADF);
-	ret = rdma_listen(rs->cm_id, backlog);
-	if (!ret)
-		rs->state = rs_listening;
+
+	if (rs->state != rs_listening) {
+		ret = rdma_listen(rs->cm_id, backlog);
+		if (!ret)
+			rs->state = rs_listening;
+	} else {
+		ret = 0;
+	}
 	return ret;
 }
 
Signature · 6 lines
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 1409855909-28819-1-git-send-email-sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org

#2 lore raw
Quoted 27 lines · On 2014-09-05 00:08, [email protected] wrote:

From: Sean Hefty <[email protected]>

Standard sockets allows an application to call listen() multiple times on the same socket without error. This allows a multi-threaded app to call listen from all threads.

rsockets will fail the second listen call. Modify the behavior to match standard sockets.

Problem reported by: Sreedhar Kodali <[email protected]>

---
 src/rsocket.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
src/rsocket.c +0 -3
index 00d9a18..4833810 100644
@@ -1174,9 +1174,14 @@ int rlisten(int socket, int backlog)
 	rs = idm_lookup(&idm, socket);
 	if (!rs)
 		return ERR(EBADF);
-	ret = rdma_listen(rs->cm_id, backlog);
-	if (!ret)
-		rs->state = rs_listening;

src/rsocket.c int rlisten(int socket, int backlog) · line 1186

Quoted 10 lines
src/rsocket.c +8 -0
+
+	if (rs->state != rs_listening) {
+		ret = rdma_listen(rs->cm_id, backlog);
+		if (!ret)
+			rs->state = rs_listening;
+	} else {
+		ret = 0;
+	}
 	return ret;
 }

Hi Sean,

This patch is working fine.

Thank You.

- Sreedhar

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html