]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: fix for stopping tx timer/tasklet when socket state is TCP_CLOSE
authorEldad Zinger <eldadz@mellanox.co.il>
Thu, 5 Aug 2010 05:39:58 +0000 (08:39 +0300)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:05:16 +0000 (05:05 -0700)
Signed-off-by: Eldad Zinger <eldadz@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp.h
drivers/infiniband/ulp/sdp/sdp_tx.c

index 2fc4f8f61830bbf20f17dd2faa2750eef3b9c0e1..080fcb749dee3d92709e6cacc52666c735c22924 100644 (file)
@@ -508,16 +508,14 @@ static inline int _sdp_exch_state(const char *func, int line, struct sock *sk,
                        from_states);
        }
 
-       if (TCP_CLOSE == state)
-               del_timer(&sdp_sk(sk)->tx_ring.timer);
-       /* TODO: make sure that no one will set that timer when status is
-        * TCP_CLOSE */
-
        old = sk->sk_state;
        sk->sk_state = state;
 
        spin_unlock_irqrestore(&sdp_sk(sk)->lock, flags);
 
+       if (TCP_CLOSE == state)
+               del_timer_sync(&sdp_sk(sk)->tx_ring.timer);
+
        return old;
 }
 #define sdp_exch_state(sk, from_states, state) \
index b08d1bd9ea2338317458d3782f42210908821d9e..e542e226cd1861d504b39f807e88c1f14789adb7 100644 (file)
@@ -50,8 +50,10 @@ int sdp_xmit_poll(struct sdp_sock *ssk, int force)
 
        /* If we don't have a pending timer, set one up to catch our recent
           post in case the interface becomes idle */
-       if (likely(ssk->qp_active) && !timer_pending(&ssk->tx_ring.timer))
+       if (likely(ssk->qp_active && ssk->isk.sk.sk_state != TCP_CLOSE) &&
+                       !timer_pending(&ssk->tx_ring.timer)) {
                mod_timer(&ssk->tx_ring.timer, jiffies + SDP_TX_POLL_TIMEOUT);
+       }
 
        ssk->tx_compl_pending = 0;
 
@@ -367,7 +369,7 @@ static void sdp_poll_tx_timeout(unsigned long data)
        if (sock_owned_by_user(sk)) {
                sdp_prf(&ssk->isk.sk, NULL, "TX comp: socket is busy");
 
-               if (sdp_tx_handler_select(ssk)) {
+               if (sdp_tx_handler_select(ssk) && sk->sk_state != TCP_CLOSE) {
                        sdp_prf1(sk, NULL, "schedule a timer");
                        mod_timer(&ssk->tx_ring.timer, jiffies + SDP_TX_POLL_TIMEOUT);
                }
@@ -376,10 +378,8 @@ static void sdp_poll_tx_timeout(unsigned long data)
                goto out;
        }
 
-       if (unlikely(sk->sk_state == TCP_CLOSE)) {
-               sdp_warn(sk, "Socket is closed\n");
+       if (unlikely(sk->sk_state == TCP_CLOSE))
                goto out;
-       }
 
        wc_processed = sdp_process_tx_cq(ssk);
        if (!wc_processed)
@@ -394,9 +394,8 @@ static void sdp_poll_tx_timeout(unsigned long data)
        /* If there are still packets in flight and the timer has not already
         * been scheduled by the Tx routine then schedule it here to guarantee
         * completion processing of these packets */
-       if (inflight) { /* TODO: make sure socket is not closed */
+       if (inflight)
                mod_timer(&ssk->tx_ring.timer, jiffies + SDP_TX_POLL_TIMEOUT);
-       }
 
 out:
        if (ssk->tx_ring.rdma_inflight && ssk->tx_ring.rdma_inflight->busy) {
@@ -419,12 +418,10 @@ static void sdp_tx_irq(struct ib_cq *cq, void *cq_context)
 
        ssk->tx_compl_pending = 1;
 
-       if (sdp_tx_handler_select(ssk)) {
+       if (sdp_tx_handler_select(ssk) && likely(ssk->qp_active &&
+                               sk->sk_state != TCP_CLOSE)) {
                sdp_prf1(sk, NULL, "poll and post from tasklet");
-               if (likely(ssk->qp_active)) {
-                       mod_timer(&ssk->tx_ring.timer,
-                                       jiffies + SDP_TX_POLL_TIMEOUT);
-               }
+               mod_timer(&ssk->tx_ring.timer, jiffies + SDP_TX_POLL_TIMEOUT);
                tasklet_schedule(&ssk->tx_ring.tasklet);
        }
 }