|
@@ -692,6 +692,7 @@ static int unix_autobind(struct socket *sock)
|
|
|
static u32 ordernum = 1;
|
|
|
struct unix_address *addr;
|
|
|
int err;
|
|
|
+ unsigned int retries = 0;
|
|
|
|
|
|
mutex_lock(&u->readlock);
|
|
|
|
|
@@ -717,9 +718,17 @@ retry:
|
|
|
if (__unix_find_socket_byname(net, addr->name, addr->len, sock->type,
|
|
|
addr->hash)) {
|
|
|
spin_unlock(&unix_table_lock);
|
|
|
- /* Sanity yield. It is unusual case, but yet... */
|
|
|
- if (!(ordernum&0xFF))
|
|
|
- yield();
|
|
|
+ /*
|
|
|
+ * __unix_find_socket_byname() may take long time if many names
|
|
|
+ * are already in use.
|
|
|
+ */
|
|
|
+ cond_resched();
|
|
|
+ /* Give up if all names seems to be in use. */
|
|
|
+ if (retries++ == 0xFFFFF) {
|
|
|
+ err = -ENOSPC;
|
|
|
+ kfree(addr);
|
|
|
+ goto out;
|
|
|
+ }
|
|
|
goto retry;
|
|
|
}
|
|
|
addr->hash ^= sk->sk_type;
|