[lxc-devel] [lxc/master] replace read & write syscalls with nointr functions

2xsec on Github lxc-bot at linuxcontainers.org
Thu Nov 8 10:03:24 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 377 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20181108/59fee41b/attachment.bin>
-------------- next part --------------
From 89882306f94fed5c053d4f74ee8379f64c3babcb Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Thu, 8 Nov 2018 19:00:19 +0900
Subject: [PATCH 1/2] caps: replace read with lxc_read_nointr

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/lxc/caps.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/lxc/caps.c b/src/lxc/caps.c
index 2578d3ba4..86baee261 100644
--- a/src/lxc/caps.c
+++ b/src/lxc/caps.c
@@ -33,6 +33,7 @@
 
 #include "caps.h"
 #include "config.h"
+#include "file_utils.h"
 #include "log.h"
 #include "macro.h"
 
@@ -299,11 +300,8 @@ static long int _real_caps_last_cap(void)
 		char *ptr;
 		char buf[INTTYPE_TO_STRLEN(int)] = {0};
 
-	again:
-		n = read(fd, buf, STRARRAYLEN(buf));
-		if (n < 0 && errno == EINTR) {
-			goto again;
-		} else if (n >= 0) {
+		n = lxc_read_nointr(fd, buf, STRARRAYLEN(buf));
+		if (n >= 0) {
 			errno = 0;
 			result = strtol(buf, &ptr, 10);
 			if (!ptr || (*ptr != '\0' && *ptr != '\n') || errno != 0)

From 809d44495ac1aa217830405fb7d2ee7a50dc1a14 Mon Sep 17 00:00:00 2001
From: 2xsec <dh48.jeong at samsung.com>
Date: Thu, 8 Nov 2018 19:01:03 +0900
Subject: [PATCH 2/2] log: replace write with lxc_write_nointr

Signed-off-by: 2xsec <dh48.jeong at samsung.com>
---
 src/lxc/log.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/lxc/log.c b/src/lxc/log.c
index 998f6517a..1e0cc6a67 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -41,6 +41,7 @@
 
 #include "caps.h"
 #include "config.h"
+#include "file_utils.h"
 #include "log.h"
 #include "lxccontainer.h"
 #include "utils.h"
@@ -360,12 +361,7 @@ static int log_append_logfile(const struct lxc_log_appender *appender,
 
 	buffer[n] = '\n';
 
-again:
-	ret = write(fd_to_use, buffer, n + 1);
-	if (ret < 0 && errno == EINTR)
-		goto again;
-
-	return ret;
+	return lxc_write_nointr(fd_to_use, buffer, n + 1);
 }
 
 #if HAVE_DLOG


More information about the lxc-devel mailing list