patch-2.6.6-vs1.9.0
[linux-2.6.git] / include / net / af_unix.h
index be877d7..b47489b 100644 (file)
@@ -11,9 +11,9 @@ extern rwlock_t unix_table_lock;
 
 extern atomic_t unix_tot_inflight;
 
-static inline struct sock *first_unix_socket(int *i)
+static inline struct sock *next_unix_socket_table(int *i)
 {
-       for (*i = 0; *i <= UNIX_HASH_SIZE; (*i)++) {
+       for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
                if (!hlist_empty(&unix_socket_table[*i]))
                        return __sk_head(&unix_socket_table[*i]);
        }
@@ -22,16 +22,19 @@ static inline struct sock *first_unix_socket(int *i)
 
 static inline struct sock *next_unix_socket(int *i, struct sock *s)
 {
-       struct sock *next = sk_next(s);
-       /* More in this chain? */
-       if (next)
-               return next;
-       /* Look for next non-empty chain. */
-       for ((*i)++; *i <= UNIX_HASH_SIZE; (*i)++) {
-               if (!hlist_empty(&unix_socket_table[*i]))
-                       return __sk_head(&unix_socket_table[*i]);
-       }
-       return NULL;
+       do {
+               if (s)
+                       s = sk_next(s);
+               if (!s)
+                       s = next_unix_socket_table(i);
+       } while (s && !vx_check(s->sk_xid, VX_IDENT|VX_WATCH));
+       return s;
+}
+
+static inline struct sock *first_unix_socket(int *i)
+{
+       *i = 0;
+       return next_unix_socket(i, NULL);
 }
 
 #define forall_unix_sockets(i, s) \