Temporary workaround to refcount bugs exposed by r2792
[madwifi/.git] / net80211 / ieee80211_node.c
index 98f8f1d90579489e571b2413330d6c3a2c8cfdce..339fdc021fb480393ac2a22571d9d42a5f05b6c5 100644 (file)
@@ -733,10 +733,29 @@ ieee80211_node_table_init(struct ieee80211com *ic, struct ieee80211_node_table *
 }
 
 static __inline void _node_table_join(struct ieee80211_node_table *nt, struct ieee80211_node *ni) {
+       struct ieee80211_node *tni = NULL;
        IEEE80211_NODE_TABLE_LOCK_ASSERT(nt);
 
        ni->ni_table = nt;
-       TAILQ_INSERT_TAIL(&nt->nt_node, ieee80211_ref_node(ni), ni_list);
+       tni = ieee80211_ref_node(ni);
+       /* MT: BEGIN HACK 
+         * XXX: r2792 fixed a bug where ieee80211_ref_node was being
+        * invoked five times on ni because it was passed to TAILQ_INSERT_TAIL
+         * which happens to evaluate it's value five times.  This fixed a problem
+         * where we were gaining four extra references, but unfortunately exposed
+         * other bugs which cause kernel panics.  I am working on a fix for this as part
+         * of ticket #1621.  In the meantime, adding these references back is 'wrong'
+         * but better than getting five new critical defects per day while debugging.
+         */
+       ieee80211_ref_node(ni);ieee80211_ref_node(ni); 
+       ieee80211_ref_node(ni);ieee80211_ref_node(ni); 
+       /*
+        * END HACK
+         */
+
+       TAILQ_INSERT_TAIL(&nt->nt_node, tni, ni_list);
+       tni = NULL;
+       
        LIST_INSERT_HEAD(&nt->nt_hash[IEEE80211_NODE_HASH(ni->ni_macaddr)], ni, ni_hash);
 }