Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202966
b: refs/heads/master
c: 5f2f892
h: refs/heads/master
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 16, 2010
1 parent 0091748 commit d5b13a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d5f31fbfd8fa3836a918592032853c41d1797c3d
refs/heads/master: 5f2f89209500623ccb4713ec4af7de86fd30a9e4
10 changes: 8 additions & 2 deletions trunk/net/ipv4/inetpeer.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ static struct inet_peer *lookup_rcu_bh(__be32 daddr)

while (u != peer_avl_empty) {
if (daddr == u->v4daddr) {
if (unlikely(!atomic_inc_not_zero(&u->refcnt)))
/* Before taking a reference, check if this entry was
* deleted, unlink_from_pool() sets refcnt=-1 to make
* distinction between an unused entry (refcnt=0) and
* a freed one.
*/
if (unlikely(!atomic_add_unless(&u->refcnt, 1, -1)))
u = NULL;
return u;
}
Expand Down Expand Up @@ -322,8 +327,9 @@ static void unlink_from_pool(struct inet_peer *p)
* in cleanup() function to prevent sudden disappearing. If we can
* atomically (because of lockless readers) take this last reference,
* it's safe to remove the node and free it later.
* We use refcnt=-1 to alert lockless readers this entry is deleted.
*/
if (atomic_cmpxchg(&p->refcnt, 1, 0) == 1) {
if (atomic_cmpxchg(&p->refcnt, 1, -1) == 1) {
struct inet_peer **stack[PEER_MAXDEPTH];
struct inet_peer ***stackptr, ***delp;
if (lookup(p->v4daddr, stack) != p)
Expand Down

0 comments on commit d5b13a8

Please sign in to comment.