Use M_NOWAIT instead of M_WAITOK to avoid race conditions.

MFC after:	1 month
This commit is contained in:
rpaulo 2010-04-09 12:06:19 +00:00
parent a5b2b30f95
commit 6e781e21db
2 changed files with 28 additions and 13 deletions

View File

@ -110,9 +110,12 @@ amrr_init(struct ieee80211vap *vap)
KASSERT(vap->iv_rs == NULL, ("%s called multiple times", __func__));
vap->iv_rs = malloc(sizeof(struct ieee80211_amrr), M_80211_RATECTL,
M_WAITOK|M_ZERO);
amrr = vap->iv_rs;
amrr = vap->iv_rs = malloc(sizeof(struct ieee80211_amrr),
M_80211_RATECTL, M_NOWAIT|M_ZERO);
if (amrr == NULL) {
if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n");
return;
}
amrr->amrr_min_success_threshold = IEEE80211_AMRR_MIN_SUCCESS_THRESHOLD;
amrr->amrr_max_success_threshold = IEEE80211_AMRR_MAX_SUCCESS_THRESHOLD;
amrr_setinterval(vap, 500 /* ms */);
@ -136,9 +139,13 @@ amrr_node_init(struct ieee80211_node *ni)
KASSERT(ni->ni_rctls == NULL, ("%s: ni_rctls already initialized",
__func__));
ni->ni_rctls = malloc(sizeof(struct ieee80211_amrr_node),
M_80211_RATECTL, M_WAITOK|M_ZERO);
amn = ni->ni_rctls;
ni->ni_rctls = amn = malloc(sizeof(struct ieee80211_amrr_node),
M_80211_RATECTL, M_NOWAIT|M_ZERO);
if (amn == NULL) {
if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl "
"structure\n");
return;
}
amn->amn_amrr = amrr;
amn->amn_success = 0;
amn->amn_recovery = 0;

View File

@ -128,9 +128,12 @@ rssadapt_init(struct ieee80211vap *vap)
KASSERT(vap->iv_rs == NULL, ("%s: iv_rs already initialized",
__func__));
rs = malloc(sizeof(struct ieee80211_rssadapt), M_80211_RATECTL,
M_WAITOK|M_ZERO);
vap->iv_rs = rs;
vap->iv_rs = rs = malloc(sizeof(struct ieee80211_rssadapt),
M_80211_RATECTL, M_NOWAIT|M_ZERO);
if (rs == NULL) {
if_printf(vap->iv_ifp, "couldn't alloc ratectl structure\n");
return;
}
rs->vap = vap;
rssadapt_setinterval(vap, 500 /* msecs */);
rssadapt_sysctlattach(vap, vap->iv_sysctl, vap->iv_oid);
@ -162,12 +165,17 @@ static void
rssadapt_node_init(struct ieee80211_node *ni)
{
struct ieee80211_rssadapt_node *ra;
struct ieee80211_rssadapt *rsa = ni->ni_vap->iv_rs;
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211_rssadapt *rsa = vap->iv_rs;
const struct ieee80211_rateset *rs = &ni->ni_rates;
ra = malloc(sizeof(struct ieee80211_rssadapt_node), M_80211_RATECTL,
M_WAITOK|M_ZERO);
ni->ni_rctls = ra;
ni->ni_rctls = ra = malloc(sizeof(struct ieee80211_rssadapt_node),
M_80211_RATECTL, M_NOWAIT|M_ZERO);
if (ra == NULL) {
if_printf(vap->iv_ifp, "couldn't alloc per-node ratectl "
"structure\n");
return;
}
ra->ra_rs = rsa;
ra->ra_rates = *rs;
rssadapt_updatestats(ra);