Some people (one of whom is a client) expects all threads to wake up
when the master closes the UDP socket they are listening on (as per
Solaris). Working around this in userspace proves to be a complete
PITA.
shutdown(fd) does the job on connected sockets, but POSIX specifies
that it must return ENOTCONN if it's not connected. This patch makes
it tickle POLLHUP anyway. Normally doesn't matter, but this way you
can emulate other platforms' threads behavior by doing:
int my_close(int fd)
{
struct stat st;
if (fstat(fd, &st) == 0 && S_ISSOCK(st.st_mode))
shutdown(fd, 2);
return close(fd);
}
Thoughts?
Rusty.
diff -urN -X /tmp/kerndiff.IDDSS7 --minimal
linux-2.4.0-test10-4/net/ipv4/af_inet.c
working-2.4.0-test10-4/net/ipv4/af_inet.c
--- linux-2.4.0-test10-4/net/ipv4/af_inet.c Thu Oct 19 14:08:34 2000
+++ working-2.4.0-test10-4/net/ipv4/af_inet.c Thu Oct 19 18:03:23 2000
@@ -753,13 +753,14 @@
}
switch (sk->state) {
- default:
+ case TCP_CLOSE:
+ err = -ENOTCONN;
+ /* Hack to wake up other listeners, who can poll for
+ POLLHUP, even on eg. unconnected UDP sockets -- RR */
+ default:
sk->shutdown |= how;
if (sk->prot->shutdown)
sk->prot->shutdown(sk, how);
- break;
- case TCP_CLOSE:
- err = -ENOTCONN;
break;
/* Remaining two branches are temporary solution for missing
--
Hacking time.
|