Found a better solution for implementing ieee80211_node_dectestref().
Now the reference count get accessed only once, leading to true atomarity. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34823 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
210124c810
commit
485da29cbc
@ -397,8 +397,6 @@ ieee80211_getmgtframe(uint8_t** frm, int headroom, int pktlen)
|
||||
/*
|
||||
* Decrements the reference-counter and
|
||||
* tests whether it became zero.
|
||||
* NB: The negation of atomic_add is not atomar. Must work until sth. better is
|
||||
* found.
|
||||
*
|
||||
* @return 1 reference-counter became zero
|
||||
* @return 0 reference-counter didn't became zero
|
||||
@ -406,9 +404,8 @@ ieee80211_getmgtframe(uint8_t** frm, int headroom, int pktlen)
|
||||
int
|
||||
ieee80211_node_dectestref(struct ieee80211_node* ni)
|
||||
{
|
||||
// XXX need equivalent of atomic_dec_and_test
|
||||
atomic_add((vint32*)&ni->ni_refcnt, -1);
|
||||
return !atomic_add((vint32*)&ni->ni_refcnt, 0);
|
||||
// atomic_add returns old value
|
||||
return 1 == atomic_add((vint32*)&ni->ni_refcnt, -1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user