memcached: Check for closed connection to avoid deadloop
authorPavel Rochnyack <pavel2000@ngs.ru>
Sun, 10 Dec 2017 20:24:33 +0000 (03:24 +0700)
committerPavel Rochnyack <pavel2000@ngs.ru>
Sun, 10 Dec 2017 20:28:49 +0000 (03:28 +0700)
Check for 'recv(...) == 0' condition was missing.

src/memcached.c

index 1cd5a30..d2827a4 100644 (file)
@@ -291,6 +291,12 @@ static int memcached_query_daemon(char *buffer, size_t buffer_size,
       close(st->fd);
       st->fd = -1;
       return -1;
+    } else if (status == 0) {
+      ERROR("memcached plugin: Instance \"%s\": Connection closed by peer",
+            st->name);
+      close(st->fd);
+      st->fd = -1;
+      return -1;
     }
 
     buffer_fill += (size_t)status;