summaryrefslogtreecommitdiffstats
path: root/sys/sys/unpcb.h
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2006-07-23 12:01:14 +0000
committerrwatson <rwatson@FreeBSD.org>2006-07-23 12:01:14 +0000
commitc6cb3a55828b25caf156e4335b7848b73a3d119b (patch)
tree2e8d96c645965a865992e54516f33e3476f75575 /sys/sys/unpcb.h
parente5969e57e6ebe4c8ef48d5ce25cbe3abfd15413e (diff)
downloadFreeBSD-src-c6cb3a55828b25caf156e4335b7848b73a3d119b.zip
FreeBSD-src-c6cb3a55828b25caf156e4335b7848b73a3d119b.tar.gz
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.
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 a1186de..b910f03 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>. */
OpenPOWER on IntegriCloud