[ovs-dev] [worker v2 02/14] socket-util: New function xset_nonblocking().
Ben Pfaff
blp at nicira.com
Wed Jun 27 18:25:18 UTC 2012
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
lib/fatal-signal.c | 4 ++--
lib/process.c | 6 +++---
lib/signals.c | 6 +++---
lib/socket-util.c | 8 ++++++++
lib/socket-util.h | 2 ++
5 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c
index 9130a23..21ebb5a 100644
--- a/lib/fatal-signal.c
+++ b/lib/fatal-signal.c
@@ -75,8 +75,8 @@ fatal_signal_init(void)
inited = true;
xpipe(signal_fds);
- set_nonblocking(signal_fds[0]);
- set_nonblocking(signal_fds[1]);
+ xset_nonblocking(signal_fds[0]);
+ xset_nonblocking(signal_fds[1]);
sigemptyset(&fatal_signal_set);
for (i = 0; i < ARRAY_SIZE(fatal_signals); i++) {
diff --git a/lib/process.c b/lib/process.c
index fcb869f..91dfc06 100644
--- a/lib/process.c
+++ b/lib/process.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -83,8 +83,8 @@ process_init(void)
/* Create notification pipe. */
xpipe(fds);
- set_nonblocking(fds[0]);
- set_nonblocking(fds[1]);
+ xset_nonblocking(fds[0]);
+ xset_nonblocking(fds[1]);
/* Set up child termination signal handler. */
memset(&sa, 0, sizeof sa);
diff --git a/lib/signals.c b/lib/signals.c
index 98fe23e..b712f7e 100644
--- a/lib/signals.c
+++ b/lib/signals.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2011 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,8 +64,8 @@ signal_init(void)
if (!inited) {
inited = true;
xpipe(fds);
- set_nonblocking(fds[0]);
- set_nonblocking(fds[1]);
+ xset_nonblocking(fds[0]);
+ xset_nonblocking(fds[1]);
}
}
diff --git a/lib/socket-util.c b/lib/socket-util.c
index 53d0fb6..939cd90 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -82,6 +82,14 @@ set_nonblocking(int fd)
}
}
+void
+xset_nonblocking(int fd)
+{
+ if (set_nonblocking(fd)) {
+ exit(EXIT_FAILURE);
+ }
+}
+
static int
set_dscp(int fd, uint8_t dscp)
{
diff --git a/lib/socket-util.h b/lib/socket-util.h
index 4a1df12..e2e0d9a 100644
--- a/lib/socket-util.h
+++ b/lib/socket-util.h
@@ -26,6 +26,8 @@
#include <netinet/ip.h>
int set_nonblocking(int fd);
+void xset_nonblocking(int fd);
+
int get_max_fds(void);
int lookup_ip(const char *host_name, struct in_addr *address);
--
1.7.2.5
More information about the dev
mailing list