summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a824bd2)
raw | patch | inline | side by side (parent: a824bd2)
author | Florian Forster <octo@huhu.verplant.org> | |
Tue, 19 Aug 2008 19:48:45 +0000 (21:48 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 19 Aug 2008 19:48:45 +0000 (21:48 +0200) |
Not sure if this fixes the reported bug, but it might.. Feedback would be
welcome.
References: #26
welcome.
References: #26
src/memcached.c | patch | blob | history |
diff --git a/src/memcached.c b/src/memcached.c
index c830598d273c89dca7631c38bc8614a2a81caa72..f65f0dad7e6a3db891d907d9add4003c08496db4 100644 (file)
--- a/src/memcached.c
+++ b/src/memcached.c
{
struct pollfd p;
- int n;
+ int timeout;
+ int status;
+ memset (&p, 0, sizeof (p));
p.fd = fd;
- p.events = POLLIN|POLLERR|POLLHUP;
+ p.events = POLLIN | POLLERR | POLLHUP;
p.revents = 0;
- n = poll(&p, 1, 3);
-
- if (n <= 0) {
- ERROR ("memcached: poll() failed or timed out");
- return -1;
+ status = poll (&p, /* nfds = */ 1, /* timeout = */ interval_g);
+ if (status <= 0)
+ {
+ if (status == 0)
+ {
+ ERROR ("memcached: poll(2) timed out after %i seconds.", interval_g);
+ }
+ else
+ {
+ char errbuf[1024];
+ ERROR ("memcached: poll(2) failed: %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ }
+ shutdown (fd, SHUT_RDWR);
+ close (fd);
+ return (-1);
}
}