diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2012-04-02 17:26:05 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-04-20 10:55:14 -0400 |
commit | 9d7d4458d94d0aac0a7edf999368eb18f89cb76a (patch) | |
tree | b443c2ed560bc5f61cae78e94ceeb795fa1f83b4 /src/monitor/monitor_netlink.c | |
parent | 9959c512ac3ba36f7a0db7614f0357ce0bae748f (diff) | |
download | sssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.gz sssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.tar.xz sssd-9d7d4458d94d0aac0a7edf999368eb18f89cb76a.zip |
Convert read and write operations to sss_atomic_read
https://fedorahosted.org/sssd/ticket/1209
Diffstat (limited to 'src/monitor/monitor_netlink.c')
-rw-r--r-- | src/monitor/monitor_netlink.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 2fe380ac9..3842c4f16 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; } |