aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/unpcb.h
diff options
context:
space:
mode:
authorRobert Watson <rwatson@FreeBSD.org>2006-07-23 12:01:14 +0000
committerRobert Watson <rwatson@FreeBSD.org>2006-07-23 12:01:14 +0000
commit4f1f0ef52332b4ce86d34972ba18e46160daa138 (patch)
tree2e8d96c645965a865992e54516f33e3476f75575 /sys/sys/unpcb.h
parentdd47f5ca9cca52027757b7dceaa74f9c6510081a (diff)
downloadsrc-4f1f0ef52332b4ce86d34972ba18e46160daa138.tar.gz
src-4f1f0ef52332b4ce86d34972ba18e46160daa138.zip
Add two new unpcb flags, UNP_BINDING and UNP_CONNECTING, which will be
used to mark UNIX domain sockets as being in the process of binding or connecting. Use these to prevent simultaneous bind or connect operations by multiple threads or processes on the same socket at the same time, which closes race conditions present in the UNIX domain socket implementation since inception.
Notes
Notes: svn path=/head/; revision=160590
Diffstat (limited to 'sys/sys/unpcb.h')
-rw-r--r--sys/sys/unpcb.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h
index a1186dedbae2..b910f035acd9 100644
--- a/sys/sys/unpcb.h
+++ b/sys/sys/unpcb.h
@@ -98,6 +98,14 @@ struct unpcb {
#define UNP_WANTCRED 0x004 /* credentials wanted */
#define UNP_CONNWAIT 0x008 /* connect blocks until accepted */
+/*
+ * These flags are used to handle non-atomicity in connect() and bind()
+ * operations on a socket: in particular, to avoid races between multiple
+ * threads or processes operating simultaneously on the same socket.
+ */
+#define UNP_CONNECTING 0x010 /* Currently connecting. */
+#define UNP_BINDING 0x020 /* Currently binding. */
+
#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
/* Hack alert -- this structure depends on <sys/socketvar.h>. */