In sonewconn(), set the new socket's state to show the protocol-provided
connection status before inserting the new socket into the listen socket's accept queue, or there might be a race in which another thread wakes up when the accept lock is released, and sees the socket before its state is set correctly. The wakeup still occurs after the accept lock is released. There have been no diagnoses of this bug in real-world systems (as yet). MFC after: 3 days
This commit is contained in:
parent
cd4209c59e
commit
630d43c2be
@ -249,6 +249,7 @@ sonewconn(head, connstatus)
|
||||
sodealloc(so);
|
||||
return ((struct socket *)0);
|
||||
}
|
||||
so->so_state |= connstatus;
|
||||
ACCEPT_LOCK();
|
||||
if (connstatus) {
|
||||
TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
|
||||
@ -279,7 +280,6 @@ sonewconn(head, connstatus)
|
||||
}
|
||||
ACCEPT_UNLOCK();
|
||||
if (connstatus) {
|
||||
so->so_state |= connstatus;
|
||||
sorwakeup(head);
|
||||
wakeup_one(&head->so_timeo);
|
||||
}
|
||||
|
@ -249,6 +249,7 @@ sonewconn(head, connstatus)
|
||||
sodealloc(so);
|
||||
return ((struct socket *)0);
|
||||
}
|
||||
so->so_state |= connstatus;
|
||||
ACCEPT_LOCK();
|
||||
if (connstatus) {
|
||||
TAILQ_INSERT_TAIL(&head->so_comp, so, so_list);
|
||||
@ -279,7 +280,6 @@ sonewconn(head, connstatus)
|
||||
}
|
||||
ACCEPT_UNLOCK();
|
||||
if (connstatus) {
|
||||
so->so_state |= connstatus;
|
||||
sorwakeup(head);
|
||||
wakeup_one(&head->so_timeo);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user