diff options
Diffstat (limited to 'net/unix/garbage.c')
-rw-r--r-- | net/unix/garbage.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/net/unix/garbage.c b/net/unix/garbage.c index 6d4a9a8de5ef..19c17e4a0c8b 100644 --- a/net/unix/garbage.c +++ b/net/unix/garbage.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/file.h> | 80 | #include <linux/file.h> |
81 | #include <linux/proc_fs.h> | 81 | #include <linux/proc_fs.h> |
82 | #include <linux/mutex.h> | 82 | #include <linux/mutex.h> |
83 | #include <linux/wait.h> | ||
83 | 84 | ||
84 | #include <net/sock.h> | 85 | #include <net/sock.h> |
85 | #include <net/af_unix.h> | 86 | #include <net/af_unix.h> |
@@ -91,6 +92,7 @@ | |||
91 | static LIST_HEAD(gc_inflight_list); | 92 | static LIST_HEAD(gc_inflight_list); |
92 | static LIST_HEAD(gc_candidates); | 93 | static LIST_HEAD(gc_candidates); |
93 | static DEFINE_SPINLOCK(unix_gc_lock); | 94 | static DEFINE_SPINLOCK(unix_gc_lock); |
95 | static DECLARE_WAIT_QUEUE_HEAD(unix_gc_wait); | ||
94 | 96 | ||
95 | unsigned int unix_tot_inflight; | 97 | unsigned int unix_tot_inflight; |
96 | 98 | ||
@@ -104,8 +106,8 @@ static struct sock *unix_get_socket(struct file *filp) | |||
104 | * Socket ? | 106 | * Socket ? |
105 | */ | 107 | */ |
106 | if (S_ISSOCK(inode->i_mode)) { | 108 | if (S_ISSOCK(inode->i_mode)) { |
107 | struct socket * sock = SOCKET_I(inode); | 109 | struct socket *sock = SOCKET_I(inode); |
108 | struct sock * s = sock->sk; | 110 | struct sock *s = sock->sk; |
109 | 111 | ||
110 | /* | 112 | /* |
111 | * PF_UNIX ? | 113 | * PF_UNIX ? |
@@ -124,7 +126,7 @@ static struct sock *unix_get_socket(struct file *filp) | |||
124 | void unix_inflight(struct file *fp) | 126 | void unix_inflight(struct file *fp) |
125 | { | 127 | { |
126 | struct sock *s = unix_get_socket(fp); | 128 | struct sock *s = unix_get_socket(fp); |
127 | if(s) { | 129 | if (s) { |
128 | struct unix_sock *u = unix_sk(s); | 130 | struct unix_sock *u = unix_sk(s); |
129 | spin_lock(&unix_gc_lock); | 131 | spin_lock(&unix_gc_lock); |
130 | if (atomic_long_inc_return(&u->inflight) == 1) { | 132 | if (atomic_long_inc_return(&u->inflight) == 1) { |
@@ -141,7 +143,7 @@ void unix_inflight(struct file *fp) | |||
141 | void unix_notinflight(struct file *fp) | 143 | void unix_notinflight(struct file *fp) |
142 | { | 144 | { |
143 | struct sock *s = unix_get_socket(fp); | 145 | struct sock *s = unix_get_socket(fp); |
144 | if(s) { | 146 | if (s) { |
145 | struct unix_sock *u = unix_sk(s); | 147 | struct unix_sock *u = unix_sk(s); |
146 | spin_lock(&unix_gc_lock); | 148 | spin_lock(&unix_gc_lock); |
147 | BUG_ON(list_empty(&u->link)); | 149 | BUG_ON(list_empty(&u->link)); |
@@ -154,7 +156,7 @@ void unix_notinflight(struct file *fp) | |||
154 | 156 | ||
155 | static inline struct sk_buff *sock_queue_head(struct sock *sk) | 157 | static inline struct sk_buff *sock_queue_head(struct sock *sk) |
156 | { | 158 | { |
157 | return (struct sk_buff *) &sk->sk_receive_queue; | 159 | return (struct sk_buff *)&sk->sk_receive_queue; |
158 | } | 160 | } |
159 | 161 | ||
160 | #define receive_queue_for_each_skb(sk, next, skb) \ | 162 | #define receive_queue_for_each_skb(sk, next, skb) \ |
@@ -266,12 +268,16 @@ static void inc_inflight_move_tail(struct unix_sock *u) | |||
266 | list_move_tail(&u->link, &gc_candidates); | 268 | list_move_tail(&u->link, &gc_candidates); |
267 | } | 269 | } |
268 | 270 | ||
269 | /* The external entry point: unix_gc() */ | 271 | static bool gc_in_progress = false; |
270 | 272 | ||
271 | void unix_gc(void) | 273 | void wait_for_unix_gc(void) |
272 | { | 274 | { |
273 | static bool gc_in_progress = false; | 275 | wait_event(unix_gc_wait, gc_in_progress == false); |
276 | } | ||
274 | 277 | ||
278 | /* The external entry point: unix_gc() */ | ||
279 | void unix_gc(void) | ||
280 | { | ||
275 | struct unix_sock *u; | 281 | struct unix_sock *u; |
276 | struct unix_sock *next; | 282 | struct unix_sock *next; |
277 | struct sk_buff_head hitlist; | 283 | struct sk_buff_head hitlist; |
@@ -364,7 +370,7 @@ void unix_gc(void) | |||
364 | */ | 370 | */ |
365 | skb_queue_head_init(&hitlist); | 371 | skb_queue_head_init(&hitlist); |
366 | list_for_each_entry(u, &gc_candidates, link) | 372 | list_for_each_entry(u, &gc_candidates, link) |
367 | scan_children(&u->sk, inc_inflight, &hitlist); | 373 | scan_children(&u->sk, inc_inflight, &hitlist); |
368 | 374 | ||
369 | spin_unlock(&unix_gc_lock); | 375 | spin_unlock(&unix_gc_lock); |
370 | 376 | ||
@@ -376,6 +382,7 @@ void unix_gc(void) | |||
376 | /* All candidates should have been detached by now. */ | 382 | /* All candidates should have been detached by now. */ |
377 | BUG_ON(!list_empty(&gc_candidates)); | 383 | BUG_ON(!list_empty(&gc_candidates)); |
378 | gc_in_progress = false; | 384 | gc_in_progress = false; |
385 | wake_up(&unix_gc_wait); | ||
379 | 386 | ||
380 | out: | 387 | out: |
381 | spin_unlock(&unix_gc_lock); | 388 | spin_unlock(&unix_gc_lock); |