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>
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;
}