Unverified Commit 891a355f by Christian Brauner Committed by GitHub

Merge pull request #2720 from 2xsec/bugfix

replace read & write syscalls with nointr functions
parents 30acf282 809d4449
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "caps.h" #include "caps.h"
#include "config.h" #include "config.h"
#include "file_utils.h"
#include "log.h" #include "log.h"
#include "macro.h" #include "macro.h"
...@@ -299,11 +300,8 @@ static long int _real_caps_last_cap(void) ...@@ -299,11 +300,8 @@ static long int _real_caps_last_cap(void)
char *ptr; char *ptr;
char buf[INTTYPE_TO_STRLEN(int)] = {0}; char buf[INTTYPE_TO_STRLEN(int)] = {0};
again: n = lxc_read_nointr(fd, buf, STRARRAYLEN(buf));
n = read(fd, buf, STRARRAYLEN(buf)); if (n >= 0) {
if (n < 0 && errno == EINTR) {
goto again;
} else if (n >= 0) {
errno = 0; errno = 0;
result = strtol(buf, &ptr, 10); result = strtol(buf, &ptr, 10);
if (!ptr || (*ptr != '\0' && *ptr != '\n') || errno != 0) if (!ptr || (*ptr != '\0' && *ptr != '\n') || errno != 0)
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "caps.h" #include "caps.h"
#include "config.h" #include "config.h"
#include "file_utils.h"
#include "log.h" #include "log.h"
#include "lxccontainer.h" #include "lxccontainer.h"
#include "utils.h" #include "utils.h"
...@@ -360,12 +361,7 @@ static int log_append_logfile(const struct lxc_log_appender *appender, ...@@ -360,12 +361,7 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
buffer[n] = '\n'; buffer[n] = '\n';
again: return lxc_write_nointr(fd_to_use, buffer, n + 1);
ret = write(fd_to_use, buffer, n + 1);
if (ret < 0 && errno == EINTR)
goto again;
return ret;
} }
#if HAVE_DLOG #if HAVE_DLOG
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment