Skip to content

Commit

Permalink
libganglia: avoid slurpfile failure path on EOF
Browse files Browse the repository at this point in the history
when read returns 0 (for example in EOF), this error path shouldn't be
followed or it could lead to a bogus failure message and the unlikely
possibility that an stale errno might be EINTR and therefore trigger
a busy loop.

Reported-By: Kostas Georgiou <k.georgiou@atreides.org.uk>
  • Loading branch information
carenas committed Feb 28, 2011
1 parent 2289689 commit 52a7dfe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion monitor-core/lib/file.c
Expand Up @@ -122,7 +122,7 @@ slurpfile (char * filename, char **buffer, int buflen)

read:
read_len = read(fd, db, buflen);
if (read_len <= 0)
if (read_len < 0)
{
if (errno == EINTR)
goto read;
Expand Down

0 comments on commit 52a7dfe

Please sign in to comment.