Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 166629
b: refs/heads/master
c: d99927f
h: refs/heads/master
i:
  166627: ff6f9f7
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Sep 30, 2009
1 parent 81b7c50 commit a4305e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 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: b7058842c940ad2c08dd829b21e5c92ebe3b8758
refs/heads/master: d99927f4d93f36553699573b279e0ff98ad7dea6
19 changes: 12 additions & 7 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,17 +1228,22 @@ void __init sk_init(void)
void sock_wfree(struct sk_buff *skb)
{
struct sock *sk = skb->sk;
int res;
unsigned int len = skb->truesize;

/* In case it might be waiting for more memory. */
res = atomic_sub_return(skb->truesize, &sk->sk_wmem_alloc);
if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE))
if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE)) {
/*
* Keep a reference on sk_wmem_alloc, this will be released
* after sk_write_space() call
*/
atomic_sub(len - 1, &sk->sk_wmem_alloc);
sk->sk_write_space(sk);
len = 1;
}
/*
* if sk_wmem_alloc reached 0, we are last user and should
* free this sock, as sk_free() call could not do it.
* if sk_wmem_alloc reaches 0, we must finish what sk_free()
* could not do because of in-flight packets
*/
if (res == 0)
if (atomic_sub_and_test(len, &sk->sk_wmem_alloc))
__sk_free(sk);
}
EXPORT_SYMBOL(sock_wfree);
Expand Down

0 comments on commit a4305e7

Please sign in to comment.