]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
IB/sdp: handle shutdown recv on listening socket
authorAmiram Perlmutter <amip@mellanox.co.il>
Thu, 18 Jan 2007 16:50:30 +0000 (18:50 +0200)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:04:02 +0000 (05:04 -0700)
Signed-off-by: Amiram Perlmutter <amip@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp_main.c

index ef8e2eb737fa3f9e64ffe77a54b964f83f5e3a99..87ae56bf569cea17fd697972d08bd5ac053a6da2 100644 (file)
@@ -490,10 +490,33 @@ static int sdp_disconnect(struct sock *sk, int flags)
 {
        struct sdp_sock *ssk = sdp_sk(sk);
        int rc = 0;
+       int old_state = sk->sk_state;
+       struct sdp_sock *s, *t;
+       struct rdma_cm_id *id = ssk->id;
+
        sdp_dbg(sk, "%s\n", __func__);
        if (ssk->id)
                rc = rdma_disconnect(ssk->id);
-       return rc;
+
+       if (old_state != TCP_LISTEN)
+               return rc;
+
+       sdp_set_state(sk, TCP_CLOSE);
+       ssk->id = NULL;
+       release_sock(sk); /* release socket since locking semantics is parent
+                            inside child */
+       rdma_destroy_id(ssk->id);
+
+       list_for_each_entry_safe(s, t, &ssk->backlog_queue, backlog_queue) {
+               sk_common_release(&s->isk.sk);
+       }
+       list_for_each_entry_safe(s, t, &ssk->accept_queue, accept_queue) {
+               sk_common_release(&s->isk.sk);
+       }
+
+       lock_sock(sk);
+
+       return 0;
 }
 
 /* Like inet_csk_wait_for_connect */