summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/uipc_socket.c')
-rw-r--r--sys/kern/uipc_socket.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 1efa8c531b3c..77a43317e64f 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)uipc_socket.c 8.3 (Berkeley) 4/15/94
- * $Id: uipc_socket.c,v 1.50 1999/01/20 17:31:54 fenner Exp $
+ * $Id: uipc_socket.c,v 1.51 1999/01/20 17:45:22 fenner Exp $
*/
#include <sys/param.h>
@@ -193,7 +193,12 @@ sofree(so)
TAILQ_REMOVE(&head->so_incomp, so, so_list);
head->so_incqlen--;
} else if (so->so_state & SS_COMP) {
- TAILQ_REMOVE(&head->so_comp, so, so_list);
+ /*
+ * We must not decommission a socket that's
+ * on the accept(2) queue. If we do, then
+ * accept(2) may hang after select(2) indicated
+ * that the listening socket was ready.
+ */
} else {
panic("sofree: not queued");
}
@@ -228,6 +233,7 @@ soclose(so)
}
for (sp = so->so_comp.tqh_first; sp != NULL; sp = sonext) {
sonext = sp->so_list.tqe_next;
+ TAILQ_REMOVE(&so->so_comp, sp, so_list);
(void) soabort(sp);
}
}
@@ -288,7 +294,13 @@ soaccept(so, nam)
if ((so->so_state & SS_NOFDREF) == 0)
panic("soaccept: !NOFDREF");
so->so_state &= ~SS_NOFDREF;
- error = (*so->so_proto->pr_usrreqs->pru_accept)(so, nam);
+ if ((so->so_state & SS_ISDISCONNECTED) == 0)
+ error = (*so->so_proto->pr_usrreqs->pru_accept)(so, nam);
+ else {
+ if (nam)
+ *nam = 0;
+ error = 0;
+ }
splx(s);
return (error);
}