summaryrefslogtreecommitdiffstats
path: root/sys/compat/svr4/svr4_stream.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-07-21 20:40:13 +0000
committerjhb <jhb@FreeBSD.org>2006-07-21 20:40:13 +0000
commit8a1f79ab85c00574b27570ea0a8fc13018f8d7f4 (patch)
tree4e40399b541abc00aa6ef6725ce6c658473c296f /sys/compat/svr4/svr4_stream.c
parent6370253bdc1d9199f89dc3a29376633daec69c12 (diff)
downloadFreeBSD-src-8a1f79ab85c00574b27570ea0a8fc13018f8d7f4.zip
FreeBSD-src-8a1f79ab85c00574b27570ea0a8fc13018f8d7f4.tar.gz
Clean up the svr4 socket cache and streams code some to make it more easily
locked. - Move all the svr4 socket cache code into svr4_socket.c, specifically move svr4_delete_socket() over from streams.c. Make the socket cache entry structure and svr4_head private to svr4_socket.c as a result. - Add a mutex to protect the svr4 socket cache. - Change svr4_find_socket() to copy the sockaddr_un struct into a caller-supplied sockaddr_un rather than giving the caller a pointer to our internal one. This removes the one case where code outside of svr4_socket.c could access data in the cache. - Add an eventhandler for process_exit and process_exec to purge the cache of any entries for the exiting or execing process. - Add methods to init and destroy the socket cache and call them from the svr4 ABI module's event handler. - Conditionally grab Giant around socreate() in streamsopen(). - Use fdclose() instead of inlining it in streamsopen() when handling socreate() failure. - Only allocate a stream structure and attach it to a socket in streamsopen(). Previously, if a svr4 program performed a stream operation on an arbitrary socket not opened via the streams device, we would attach streams state data to it and change f_ops of the associated struct file while it was in use. The latter was especially not safe, and if a program wants a stream object it should open it via the streams device anyway. - Don't bother locking so_emuldata in the streams code now that we only touch it right after creating a socket (in streamsopen()) or when tearing it down when the file is closed. - Remove D_NEEDGIANT from the streams device as it is no longer needed.
Diffstat (limited to 'sys/compat/svr4/svr4_stream.c')
-rw-r--r--sys/compat/svr4/svr4_stream.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
index 2d10cc9..5efb3b8 100644
--- a/sys/compat/svr4/svr4_stream.c
+++ b/sys/compat/svr4/svr4_stream.c
@@ -1554,13 +1554,11 @@ svr4_do_putmsg(td, uap, fp)
/* Maybe we've been given a device/inode pair */
dev_t *dev = SVR4_ADDROF(&sc);
ino_t *ino = (ino_t *) &dev[1];
- sa = (struct sockaddr *)
- svr4_find_socket(td, fp, *dev, *ino);
- if (sa == NULL) {
- sa = (struct sockaddr *)&saun;
+ if (svr4_find_socket(td, fp, *dev, *ino, &saun) != 0) {
/* I guess we have it by name */
netaddr_to_sockaddr_un(&saun, &sc);
}
+ sa = (struct sockaddr *)&saun;
sasize = sizeof(saun);
}
break;
OpenPOWER on IntegriCloud