Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jul 2006 18:05:25 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 102012 for review
Message-ID:  <200607201805.k6KI5PFA033008@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=102012

Change 102012 by jhb@jhb_mutex on 2006/07/20 18:05:24

	Avoid locking pain and suffering by copying the sockaddr_un found
	in svr4_find_socket() to a caller supplied sockaddr_un.

Affected files ...

.. //depot/projects/smpng/sys/compat/svr4/svr4_socket.c#14 edit
.. //depot/projects/smpng/sys/compat/svr4/svr4_socket.h#8 edit
.. //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#36 edit
.. //depot/projects/smpng/sys/notes#84 edit

Differences ...

==== //depot/projects/smpng/sys/compat/svr4/svr4_socket.c#14 (text+ko) ====

@@ -80,12 +80,13 @@
 static struct mtx svr4_head_lock;
 MTX_SYSINIT(svr4_head_lock, &svr4_head_lock, "svr4_head", MTX_DEF);
 
-struct sockaddr_un *
-svr4_find_socket(td, fp, dev, ino)
+int
+svr4_find_socket(td, fp, dev, ino, saun)
 	struct thread *td;
 	struct file *fp;
 	dev_t dev;
 	ino_t ino;
+	struct sockaddr_un *saun;
 {
 	struct svr4_sockcache_entry *e;
 	void *cookie = ((struct socket *)fp->f_data)->so_emuldata;
@@ -100,13 +101,14 @@
 #endif
 			e->cookie = cookie;
 			DPRINTF(("%s\n", e->sock.sun_path));
+			*saun = e->sock;
 			mtx_unlock(&svr4_head_lock);
-			return &e->sock;
+			return (0);
 		}
 
 	mtx_unlock(&svr4_head_lock);
 	DPRINTF(("not found\n"));
-	return NULL;
+	return (ENOENT);
 }
 
 int

==== //depot/projects/smpng/sys/compat/svr4/svr4_socket.h#8 (text+ko) ====

@@ -48,9 +48,9 @@
         u_char         sin_zero[8];
 };
 
-struct sockaddr_un *svr4_find_socket(struct thread *, struct file *,
-    dev_t, ino_t);
-void svr4_delete_socket(struct proc *, struct file *);
-int svr4_add_socket(struct thread *, const char *, struct stat *);
+int	svr4_find_socket(struct thread *, struct file *, dev_t, ino_t,
+    struct sockaddr_un *);
+void	svr4_delete_socket(struct proc *, struct file *);
+int	svr4_add_socket(struct thread *, const char *, struct stat *);
 
 #endif /* _SVR4_SOCKET_H_ */

==== //depot/projects/smpng/sys/compat/svr4/svr4_stream.c#36 (text+ko) ====

@@ -1554,13 +1554,11 @@
 			/* 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;

==== //depot/projects/smpng/sys/notes#84 (text+ko) ====

@@ -89,7 +89,7 @@
 	    should already have f_ops set correctly and if we can just
 	    allocate so_emuldata directly in streamsopen()
 	  - XXX: svr4_add_socket() can add duplicates?
-	  - change svr4_find_socket() to copy the sockaddr out to a
+	  + change svr4_find_socket() to copy the sockaddr out to a
 	    passed in sockaddr_un and return bool
 	- svr4_sys_ioctl()
 	- svr4_sys_getmsg()



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200607201805.k6KI5PFA033008>