diff mbox series

[rdma-core,3/5] rsockets: Add locks around CM state processing

Message ID 1828884A29C6694DAF28B7E6B8A82373B3E1F90E@ORSMSX109.amr.corp.intel.com (mailing list archive)
State Not Applicable
Headers show
Series None | expand

Commit Message

Hefty, Sean April 19, 2019, 6:05 p.m. UTC
In rs_do_connect(), we drive the connection state of an rsocket.
Because applications may call rpoll() from multiple thread, it's
possible for multiple threads to try driving the rsocket connection
state.  Use the rsocket slock to serialize their access.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
---
 librdmacm/rsocket.c |    2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c
index cee3bd01..9ac881bc 100644
--- a/librdmacm/rsocket.c
+++ b/librdmacm/rsocket.c
@@ -1327,6 +1327,7 @@  static int rs_do_connect(struct rsocket *rs)
 	struct rs_conn_data *creq, *cresp;
 	int to, ret;
 
+	fastlock_acquire(&rs->slock);
 	switch (rs->state) {
 	case rs_init:
 	case rs_bound:
@@ -1437,6 +1438,7 @@  connected:
 			rs->err = errno;
 		}
 	}
+	fastlock_release(&rs->slock);
 	return ret;
 }