From 7d3c46ab4c339f80c43882895ddd4543a6aec864 Mon Sep 17 00:00:00 2001 From: rrs Date: Sat, 5 Jun 2010 21:17:23 +0000 Subject: This fixes a bug in the close up of a socket that had un-accepted assoc's. Basically the assoc (and inp) would get stuck and never get cleaned up. MFC after: 1 week --- sys/netinet/sctp_pcb.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index a89573a..cccd8c50 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -3164,8 +3164,17 @@ sctp_inpcb_free(struct sctp_inpcb *inp, int immediate, int from) nasoc = LIST_NEXT(asoc, sctp_tcblist); if (asoc->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { /* Skip guys being freed */ - /* asoc->sctp_socket = NULL; FIXME MT */ cnt_in_sd++; + if (asoc->asoc.state & SCTP_STATE_IN_ACCEPT_QUEUE) { + /* + * Special case - we did not start a + * kill timer on the asoc due to it + * was not closed. So go ahead and + * start it now. + */ + asoc->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE; + sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, asoc, NULL); + } SCTP_TCB_UNLOCK(asoc); continue; } @@ -4590,8 +4599,12 @@ sctp_free_assoc(struct sctp_inpcb *inp, struct sctp_tcb *stcb, int from_inpcbfre * Someone holds a reference OR the socket is unaccepted * yet. */ - if (stcb->asoc.refcnt) + if ((stcb->asoc.refcnt) || + (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || + (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) { + stcb->asoc.state &= ~SCTP_STATE_IN_ACCEPT_QUEUE; sctp_timer_start(SCTP_TIMER_TYPE_ASOCKILL, inp, stcb, NULL); + } SCTP_TCB_UNLOCK(stcb); if ((inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_ALLGONE) || (inp->sctp_flags & SCTP_PCB_FLAGS_SOCKET_GONE)) -- cgit v1.1