diff mbox

rsockets: Support calling listen multiple times on same rsocket

Message ID 1409855909-28819-1-git-send-email-sean.hefty@intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Hefty, Sean Sept. 4, 2014, 6:38 p.m. UTC
From: Sean Hefty <sean.hefty@intel.com>

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 <srkodali@linux.vnet.ibm.com>

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
---
 src/rsocket.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Comments

Sreedhar Kodali Sept. 5, 2014, 2:14 p.m. UTC | #1
On 2014-09-05 00:08, sean.hefty@intel.com wrote:
> From: Sean Hefty <sean.hefty@intel.com>
> 
> 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 <srkodali@linux.vnet.ibm.com>
> 
> Signed-off-by: Sean Hefty <sean.hefty@intel.com>
> ---
>  src/rsocket.c |   11 ++++++++---
>  1 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/src/rsocket.c b/src/rsocket.c
> index 00d9a18..4833810 100644
> --- a/src/rsocket.c
> +++ b/src/rsocket.c
> @@ -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;
>  }

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 majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/rsocket.c b/src/rsocket.c
index 00d9a18..4833810 100644
--- a/src/rsocket.c
+++ b/src/rsocket.c
@@ -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;
 }