Message ID | 201009040931.o849VstI061086@www262.sakura.ne.jp |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
Le samedi 04 septembre 2010 à 18:31 +0900, Tetsuo Handa a écrit : > + cond_resched(); > + /* Give up if all names seems to be in use. */ > + if (retries++ == 0xFFFFF) { > + err = -ENOMEM; > + kfree(addr); > + goto out; > + } > goto retry; > } > addr->hash ^= sk->sk_type; Yes, but please use a different error code, its not ENOMEM... maybe EBUSY or ENOSPC ... -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 4414a18..1ef37ca 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -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 = -ENOMEM; + kfree(addr); + goto out; + } goto retry; } addr->hash ^= sk->sk_type;