aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/af_unix.h
diff options
context:
space:
mode:
authorMiklos Szeredi <mszeredi@suse.cz>2007-07-11 17:22:39 -0400
committerDavid S. Miller <davem@davemloft.net>2007-07-11 17:22:39 -0400
commit1fd05ba5a2f2aa8e7b9b52ef55df850e2e7d54c9 (patch)
tree3403194403ab25f1f7a360a002adf63be2b4e9b0 /include/net/af_unix.h
parent99d24edeb6abc6ca3a0d0fbdb83c664c04403c8c (diff)
[AF_UNIX]: Rewrite garbage collector, fixes race.
Throw out the old mark & sweep garbage collector and put in a refcounting cycle detecting one. The old one had a race with recvmsg, that resulted in false positives and hence data loss. The old algorithm operated on all unix sockets in the system, so any additional locking would have meant performance problems for all users of these. The new algorithm instead only operates on "in flight" sockets, which are very rare, and the additional locking for these doesn't negatively impact the vast majority of users. In fact it's probable, that there weren't *any* heavy senders of sockets over sockets, otherwise the above race would have been discovered long ago. The patch works OK with the app that exposed the race with the old code. The garbage collection has also been verified to work in a few simple cases. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/af_unix.h')
-rw-r--r--include/net/af_unix.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/net/af_unix.h b/include/net/af_unix.h
index 65f49fd7deff..6de1e9e35c73 100644
--- a/include/net/af_unix.h
+++ b/include/net/af_unix.h
@@ -79,9 +79,10 @@ struct unix_sock {
79 struct mutex readlock; 79 struct mutex readlock;
80 struct sock *peer; 80 struct sock *peer;
81 struct sock *other; 81 struct sock *other;
82 struct sock *gc_tree; 82 struct list_head link;
83 atomic_t inflight; 83 atomic_t inflight;
84 spinlock_t lock; 84 spinlock_t lock;
85 unsigned int gc_candidate : 1;
85 wait_queue_head_t peer_wait; 86 wait_queue_head_t peer_wait;
86}; 87};
87#define unix_sk(__sk) ((struct unix_sock *)__sk) 88#define unix_sk(__sk) ((struct unix_sock *)__sk)