Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 31825
b: refs/heads/master
c: a09785a
h: refs/heads/master
i:
  31823: b86668e
v: v3
  • Loading branch information
Ingo Molnar authored and Linus Torvalds committed Jul 3, 2006
1 parent 5c4ead9 commit 9515066
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da21f24dd73954c2ed0cd39a698e2c9916c05d71
refs/heads/master: a09785a2414afb261d9f719d544742af4300df22
3 changes: 3 additions & 0 deletions trunk/include/net/af_unix.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ struct unix_skb_parms {
#define unix_state_rlock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_runlock(s) spin_unlock(&unix_sk(s)->lock)
#define unix_state_wlock(s) spin_lock(&unix_sk(s)->lock)
#define unix_state_wlock_nested(s) \
spin_lock_nested(&unix_sk(s)->lock, \
SINGLE_DEPTH_NESTING)
#define unix_state_wunlock(s) spin_unlock(&unix_sk(s)->lock)

#ifdef __KERNEL__
Expand Down
12 changes: 11 additions & 1 deletion trunk/net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ static struct proto unix_proto = {
.obj_size = sizeof(struct unix_sock),
};

/*
* AF_UNIX sockets do not interact with hardware, hence they
* dont trigger interrupts - so it's safe for them to have
* bh-unsafe locking for their sk_receive_queue.lock. Split off
* this special lock-class by reinitializing the spinlock key:
*/
static struct lock_class_key af_unix_sk_receive_queue_lock_key;

static struct sock * unix_create1(struct socket *sock)
{
struct sock *sk = NULL;
Expand All @@ -580,6 +588,8 @@ static struct sock * unix_create1(struct socket *sock)
atomic_inc(&unix_nr_socks);

sock_init_data(sock,sk);
lockdep_set_class(&sk->sk_receive_queue.lock,
&af_unix_sk_receive_queue_lock_key);

sk->sk_write_space = unix_write_space;
sk->sk_max_ack_backlog = sysctl_unix_max_dgram_qlen;
Expand Down Expand Up @@ -1045,7 +1055,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr,
goto out_unlock;
}

unix_state_wlock(sk);
unix_state_wlock_nested(sk);

if (sk->sk_state != st) {
unix_state_wunlock(sk);
Expand Down

0 comments on commit 9515066

Please sign in to comment.