From 06247775aa9c49ffce72827921eb45e2d04c6aa1 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 8 Jun 2010 15:47:34 -0400 Subject: Properly handle read() and write() throughout the SSSD We need to guarantee at all times that reads and writes complete successfully. This means that they must be checked for returning EINTR and EAGAIN, and all writes must be wrapped in a loop to ensure that they do not truncate their output. --- src/monitor/monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/monitor/monitor.c') diff --git a/src/monitor/monitor.c b/src/monitor/monitor.c index 8820d6952..e52d79349 100644 --- a/src/monitor/monitor.c +++ b/src/monitor/monitor.c @@ -1372,7 +1372,7 @@ static void process_config_file(struct tevent_context *ev, len = read(file_ctx->mt_ctx->inotify_fd, buf+total_len, event_size-total_len); if (len == -1) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; DEBUG(0, ("Critical error reading inotify file descriptor.\n")); goto done; } @@ -1393,7 +1393,7 @@ static void process_config_file(struct tevent_context *ev, while (total_len < in_event->len) { len = read(file_ctx->mt_ctx->inotify_fd, &name, in_event->len); if (len == -1) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; DEBUG(0, ("Critical error reading inotify file descriptor.\n")); goto done; } -- cgit