Signed-off-by: Ed Maste <ema...@adaranet.com>
---
As suggested by Ben Pfaff in the 'Threaded userspace datapath' thread.
This looks like a useful utility function refactoring, independent of
any outcome of that discussion.

 lib/fatal-signal.c | 4 +---
 lib/process.c      | 4 +---
 lib/signals.c      | 4 +---
 lib/socket-util.c  | 7 +++++++
 lib/socket-util.h  | 1 +
 5 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c
index 21ebb5a..7cfbd05 100644
--- a/lib/fatal-signal.c
+++ b/lib/fatal-signal.c
@@ -74,9 +74,7 @@ fatal_signal_init(void)

         inited = true;

-        xpipe(signal_fds);
-        xset_nonblocking(signal_fds[0]);
-        xset_nonblocking(signal_fds[1]);
+        xpipe_nonblocking(signal_fds);

         sigemptyset(&fatal_signal_set);
         for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
diff --git a/lib/process.c b/lib/process.c
index 91dfc06..9f5c35f 100644
--- a/lib/process.c
+++ b/lib/process.c
@@ -82,9 +82,7 @@ process_init(void)
     inited = true;

     /* Create notification pipe. */
-    xpipe(fds);
-    xset_nonblocking(fds[0]);
-    xset_nonblocking(fds[1]);
+    xpipe_nonblocking(fds);

     /* Set up child termination signal handler. */
     memset(&sa, 0, sizeof sa);
diff --git a/lib/signals.c b/lib/signals.c
index b712f7e..152afcf 100644
--- a/lib/signals.c
+++ b/lib/signals.c
@@ -63,9 +63,7 @@ signal_init(void)
     static bool inited;
     if (!inited) {
         inited = true;
-        xpipe(fds);
-        xset_nonblocking(fds[0]);
-        xset_nonblocking(fds[1]);
+        xpipe_nonblocking(fds);
     }
 }

diff --git a/lib/socket-util.c b/lib/socket-util.c
index e32c03d..f8b44cc 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -894,6 +894,14 @@ xpipe(int fds[2])
 }

 void
+xpipe_nonblocking(int fds[2])
+{
+    xpipe(fds);
+    xset_nonblocking(fds[0]);
+    xset_nonblocking(fds[1]);
+}
+
+void
 xsocketpair(int domain, int type, int protocol, int fds[2])
 {
     if (socketpair(domain, type, protocol, fds)) {
diff --git a/lib/socket-util.h b/lib/socket-util.h
index bacb236..a00b32e 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -64,6 +64,7 @@ int fsync_parent_dir(const char *file_name);
 int get_mtime(const char *file_name, struct timespec *mtime);

 void xpipe(int fds[2]);
+void xpipe_nonblocking(int fds[2]);

 char *describe_fd(int fd);

--
1.7.11.5

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to