summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarian Csontos <mcsontos@redhat.com>2012-08-01 16:06:32 +0200
committerMarian Csontos <mcsontos@redhat.com>2012-08-02 16:50:37 +0200
commit49ae67cba364e7fba0d0715c4350f28239d42a68 (patch)
tree807a792a0e8a40a010fd17b3ab340d5eba26a418
parent9952331d5d58a4cc2580eddec34defa9cfe141c9 (diff)
downloadlvm2-49ae67cba364e7fba0d0715c4350f28239d42a68.tar.gz
lvm2-49ae67cba364e7fba0d0715c4350f28239d42a68.tar.xz
lvm2-49ae67cba364e7fba0d0715c4350f28239d42a68.zip
lvmetad: Skip redundant checks on no input
-rw-r--r--libdaemon/client/daemon-shared.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/libdaemon/client/daemon-shared.c b/libdaemon/client/daemon-shared.c
index 33ff48f7..f90deb4b 100644
--- a/libdaemon/client/daemon-shared.c
+++ b/libdaemon/client/daemon-shared.c
@@ -38,27 +38,26 @@ int read_buffer(int fd, char **buffer) {
while (1) {
int result = read(fd, (*buffer) + bytes, buffersize - bytes);
- if (result > 0)
+ if (result > 0) {
bytes += result;
+ if (!strncmp((*buffer) + bytes - 4, "\n##\n", 4)) {
+ *(*buffer + bytes - 4) = 0;
+ break; /* success, we have the full message now */
+ }
+ if (bytes == buffersize) {
+ buffersize += 1024;
+ if (!(new = realloc(*buffer, buffersize + 1)))
+ goto fail;
+ *buffer = new;
+ }
+ continue;
+ }
if (result == 0) {
errno = ECONNRESET;
goto fail; /* we should never encounter EOF here */
}
if (result < 0 && errno != EAGAIN && errno != EWOULDBLOCK)
goto fail;
-
- if (!strncmp((*buffer) + bytes - 4, "\n##\n", 4)) {
- *(*buffer + bytes - 4) = 0;
- break; /* success, we have the full message now */
- }
-
- if (bytes == buffersize) {
- buffersize += 1024;
- if (!(new = realloc(*buffer, buffersize + 1)))
- goto fail;
-
- *buffer = new;
- }
/* TODO call select here if we encountered EAGAIN/EWOULDBLOCK */
}
return 1;