The tw_pcbrele() function does not need the global timewait lock.

Submitted by:	Julien Charbon
Suggested by:	glebius
This commit is contained in:
John Baldwin 2014-04-11 19:17:45 +00:00
parent f567f56ebf
commit 2ffb755cec

View File

@ -133,23 +133,18 @@ tw_pcbref(struct tcptw *tw)
} }
/* /*
* Drop a refcount on an tw elevated using tw_pcbref(). Return * Drop a refcount on an tw elevated using tw_pcbref().
* the tw lock released.
*/ */
static int static int
tw_pcbrele(struct tcptw *tw) tw_pcbrele(struct tcptw *tw)
{ {
TW_WLOCK_ASSERT(V_tw_lock);
KASSERT(tw->tw_refcount > 0, ("%s: refcount 0", __func__)); KASSERT(tw->tw_refcount > 0, ("%s: refcount 0", __func__));
if (!refcount_release(&tw->tw_refcount)) { if (!refcount_release(&tw->tw_refcount))
TW_WUNLOCK(V_tw_lock);
return (0); return (0);
}
uma_zfree(V_tcptw_zone, tw); uma_zfree(V_tcptw_zone, tw);
TW_WUNLOCK(V_tw_lock);
return (1); return (1);
} }
@ -682,13 +677,10 @@ tcp_tw_2msl_stop(struct tcptw *tw, int reuse)
TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl); TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl);
crfree(tw->tw_cred); crfree(tw->tw_cred);
tw->tw_cred = NULL; tw->tw_cred = NULL;
if (!reuse) {
tw_pcbrele(tw);
return;
}
TW_WUNLOCK(V_tw_lock); TW_WUNLOCK(V_tw_lock);
if (!reuse)
tw_pcbrele(tw);
} }
struct tcptw * struct tcptw *
@ -730,7 +722,6 @@ tcp_tw_2msl_scan(void)
/* Close timewait state */ /* Close timewait state */
if (INP_INFO_TRY_WLOCK(&V_tcbinfo)) { if (INP_INFO_TRY_WLOCK(&V_tcbinfo)) {
TW_WLOCK(V_tw_lock);
if (tw_pcbrele(tw)) { if (tw_pcbrele(tw)) {
INP_INFO_WUNLOCK(&V_tcbinfo); INP_INFO_WUNLOCK(&V_tcbinfo);
continue; continue;
@ -744,7 +735,6 @@ tcp_tw_2msl_scan(void)
INP_INFO_WUNLOCK(&V_tcbinfo); INP_INFO_WUNLOCK(&V_tcbinfo);
} else { } else {
/* INP_INFO lock is busy, continue later */ /* INP_INFO lock is busy, continue later */
TW_WLOCK(V_tw_lock);
tw_pcbrele(tw); tw_pcbrele(tw);
break; break;
} }