Do not remove sockets from the accept(2) queue on close.

This commit is contained in:
mycroft 1999-01-20 09:15:41 +00:00
parent 774097a310
commit 430ecf369d
3 changed files with 25 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_socket.c,v 1.40 1998/12/16 00:26:10 thorpej Exp $ */
/* $NetBSD: uipc_socket.c,v 1.41 1999/01/20 09:15:41 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@ -162,13 +162,13 @@ sofree(so)
register struct socket *so;
{
if (so->so_pcb || (so->so_state & SS_NOFDREF) == 0)
/*
* We must not decommission a socket that's on the accept(2) queue.
* If we do, then accept(2) may hang even after select(2) indicated
* that the listening socket was ready.
*/
if (so->so_pcb || so->so_head || (so->so_state & SS_NOFDREF) == 0)
return;
if (so->so_head) {
if (!soqremque(so, 0) && !soqremque(so, 1))
panic("sofree dq");
so->so_head = 0;
}
sbrelease(&so->so_snd);
sorflush(so);
pool_put(&socket_pool, so);
@ -183,14 +183,19 @@ int
soclose(so)
register struct socket *so;
{
struct socket *so2;
int s = splsoftnet(); /* conservative */
int error = 0;
if (so->so_options & SO_ACCEPTCONN) {
while (so->so_q0.tqh_first)
(void) soabort(so->so_q0.tqh_first);
while (so->so_q.tqh_first)
(void) soabort(so->so_q.tqh_first);
while ((so2 = so->so_q0.tqh_first) != 0) {
so2->so_head = 0;
(void) soabort(so2);
}
while ((so2 = so->so_q.tqh_first) != 0) {
so2->so_head = 0;
(void) soabort(so2);
}
}
if (so->so_pcb == 0)
goto discard;
@ -253,8 +258,11 @@ soaccept(so, nam)
if ((so->so_state & SS_NOFDREF) == 0)
panic("soaccept: !NOFDREF");
so->so_state &= ~SS_NOFDREF;
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT, (struct mbuf *)0,
nam, (struct mbuf *)0, (struct proc *)0);
if ((so->so_state & SS_ISDISCONNECTED) == 0)
error = (*so->so_proto->pr_usrreq)(so, PRU_ACCEPT,
(struct mbuf *)0, nam, (struct mbuf *)0, (struct proc *)0);
else
error = 0;
splx(s);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uipc_socket2.c,v 1.26 1998/08/04 04:03:17 perry Exp $ */
/* $NetBSD: uipc_socket2.c,v 1.27 1999/01/20 09:15:41 mycroft Exp $ */
/*
* Copyright (c) 1982, 1986, 1988, 1990, 1993
@ -134,7 +134,7 @@ soisdisconnected(so)
{
so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING);
so->so_state |= (SS_CANTRCVMORE|SS_CANTSENDMORE);
so->so_state |= (SS_CANTRCVMORE|SS_CANTSENDMORE|SS_ISDISCONNECTED);
wakeup((caddr_t)&so->so_timeo);
sowwakeup(so);
sorwakeup(so);

View File

@ -1,4 +1,4 @@
/* $NetBSD: socketvar.h,v 1.32 1998/12/16 00:24:10 thorpej Exp $ */
/* $NetBSD: socketvar.h,v 1.33 1999/01/20 09:15:42 mycroft Exp $ */
/*-
* Copyright (c) 1982, 1986, 1990, 1993
@ -128,6 +128,7 @@ struct socket {
#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */
#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */
#define SS_RCVATMARK 0x040 /* at mark on input */
#define SS_ISDISCONNECTED 0x800 /* socket disconnected from peer */
#define SS_NBIO 0x080 /* non-blocking ops */
#define SS_ASYNC 0x100 /* async i/o notify */