--- linux/net/unix/af_unix.c.orig Sat Mar 4 10:08:02 2000 +++ linux/net/unix/af_unix.c Sat Mar 4 16:11:39 2000 @@ -337,7 +337,6 @@ /* Clear state */ unix_state_wlock(sk); - sock_orphan(sk); sk->shutdown = SHUTDOWN_MASK; dentry = sk->protinfo.af_unix.dentry; sk->protinfo.af_unix.dentry=NULL; @@ -356,12 +355,18 @@ if (!skb_queue_empty(&sk->receive_queue) || embrion) skpair->err = ECONNRESET; unix_state_wunlock(skpair); - sk->state_change(skpair); - sock_wake_async(sk->socket,1,POLL_HUP); + if (skpair->err) { + skpair->error_report(skpair); + } else { + skpair->state_change(skpair); + sock_wake_async(skpair->socket,1,POLL_HUP); + } } sock_put(skpair); /* It may now die */ unix_peer(sk) = NULL; } + + sock_orphan(sk); /* Try to flush out this socket. Throw out buffers at least */