Index: uipc_usrreq.c =================================================================== RCS file: /zoo/cvsup/FreeBSD-CVS/src/sys/kern/uipc_usrreq.c,v retrieving revision 1.182 diff -u -r1.182 uipc_usrreq.c --- uipc_usrreq.c 26 Jul 2006 19:16:34 -0000 1.182 +++ uipc_usrreq.c 31 Jul 2006 17:51:45 -0000 @@ -605,7 +605,18 @@ break; } } + /* + * Because connect() and send() are non-atomic in a sendto() + * with a target address, it's possible that the socket will + * have disconnected before the send() can run. In that case + * return the slightly counter-intuitive but otherwise + * correct error that the socket is not connected. + */ unp2 = unp->unp_conn; + if (unp2 == NULL) { + error = ENOTCONN; + break; + } so2 = unp2->unp_socket; if (unp->unp_addr != NULL) from = (struct sockaddr *)unp->unp_addr; @@ -650,9 +661,18 @@ error = EPIPE; break; } + /* + * Because connect() and send() are non-atomic in a sendto() + * with a target address, it's possible that the socket will + * have disconnected before the send() can run. In that case + * return the slightly counter-intuitive but otherwise + * correct error that the socket is not connected. + */ unp2 = unp->unp_conn; - if (unp2 == NULL) - panic("uipc_send connected but no connection?"); + if (unp2 == NULL) { + error = ENOTCONN; + break; + } so2 = unp2->unp_socket; SOCKBUF_LOCK(&so2->so_rcv); if (unp2->unp_flags & UNP_WANTCRED) {