From 9d7d4458d94d0aac0a7edf999368eb18f89cb76a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 2 Apr 2012 17:26:05 -0400 Subject: Convert read and write operations to sss_atomic_read https://fedorahosted.org/sssd/ticket/1209 --- src/monitor/monitor_netlink.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'src/monitor/monitor_netlink.c') diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 2fe380ac..3842c4f1 100644 --- a/src/monitor/monitor_netlink.c +++ b/src/monitor/monitor_netlink.c @@ -153,19 +153,17 @@ static bool has_ethernet_encapsulation(const char *sysfs_path) } memset(buf, 0, BUFSIZE); - while ((ret = read(fd, buf, BUFSIZE)) != 0) { - if (ret == -1) { - ret = errno; - if (ret == EINTR || ret == EAGAIN) { - continue; - } - DEBUG(SSSDBG_OP_FAILURE, - ("read failed [%d][%s].\n", ret, strerror(ret))); - close(fd); - return false; - } + errno = 0; + ret = sss_atomic_read_s(fd, buf, BUFSIZE); + if (ret == -1) { + ret = errno; + DEBUG(SSSDBG_OP_FAILURE, + ("read failed [%d][%s].\n", ret, strerror(ret))); + close(fd); + return false; } close(fd); + buf[BUFSIZE-1] = '\0'; return strncmp(buf, "1\n", BUFSIZE) == 0; } -- cgit