[sheepdog] [PATCH 4/6] lib: use wrappers for handling EMFILE
Hitoshi Mitake
mitake.hitoshi at gmail.com
Tue Aug 13 18:27:39 CEST 2013
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
lib/event.c | 2 +-
lib/logger.c | 2 +-
lib/net.c | 2 +-
lib/util.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/event.c b/lib/event.c
index d949d68..5c2d669 100644
--- a/lib/event.c
+++ b/lib/event.c
@@ -42,7 +42,7 @@ void add_timer(struct timer *t, unsigned int mseconds)
struct itimerspec it;
int tfd;
- tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
+ tfd = xtimerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (tfd < 0) {
sd_err("timerfd_create: %m");
return;
diff --git a/lib/logger.c b/lib/logger.c
index b7dbd2f..65f3102 100644
--- a/lib/logger.c
+++ b/lib/logger.c
@@ -428,7 +428,7 @@ static void rotate_log(void)
tm.tm_mday, tm.tm_hour, tm.tm_min);
rename(log_nowname, old_logfile);
}
- new_fd = open(log_nowname, O_RDWR | O_CREAT | O_APPEND, 0644);
+ new_fd = xopen(log_nowname, O_RDWR | O_CREAT | O_APPEND, 0644);
if (new_fd < 0) {
syslog(LOG_ERR, "failed to create new log file\n");
exit(1);
diff --git a/lib/net.c b/lib/net.c
index 82b6e3a..cff985c 100644
--- a/lib/net.c
+++ b/lib/net.c
@@ -136,7 +136,7 @@ int create_listen_ports(const char *bindaddr, int port,
}
for (res = res0; res; res = res->ai_next) {
- fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+ fd = xsocket(res->ai_family, res->ai_socktype, res->ai_protocol);
if (fd < 0)
continue;
diff --git a/lib/util.c b/lib/util.c
index b88f297..5e9d6ca 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -567,7 +567,7 @@ int atomic_create_and_write(const char *path, char *buf, size_t len,
snprintf(tmp_path, PATH_MAX, "%s.tmp", path);
again:
- fd = open(tmp_path, O_WRONLY | O_CREAT | O_SYNC | O_EXCL, sd_def_fmode);
+ fd = xopen(tmp_path, O_WRONLY | O_CREAT | O_SYNC | O_EXCL, sd_def_fmode);
if (fd < 0) {
if (errno == EEXIST) {
if (force_create) {
--
1.8.1.2
More information about the sheepdog
mailing list