Fix: bad check of accept() return value
authorDavid Goulet <dgoulet@efficios.com>
Thu, 20 Dec 2012 01:56:04 +0000 (20:56 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 20 Dec 2012 01:56:06 +0000 (20:56 -0500)
Also fix a missing ret = -1 assignment. Although, the chances are
unlikely to hit a positive ret value that does not match the structure
size, better safe than sorry.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/common/consumer.c

index 63c98350a4772435b50a84ae4b0ac25f4e4f3455..1045bfb46101d8a6bb63a8c91157f3ffbf5199a2 100644 (file)
@@ -1334,6 +1334,12 @@ static int write_relayd_metadata_id(int fd,
                        PERROR("write metadata stream id");
                }
                DBG3("Consumer failed to write relayd metadata id (errno: %d)", errno);
+               /*
+                * Set ret to a negative value because if ret != sizeof(hdr), we don't
+                * handle writting the missing part so report that as an error and
+                * don't lie to the caller.
+                */
+               ret = -1;
                goto end;
        }
        DBG("Metadata stream id %" PRIu64 " with padding %lu written before data",
@@ -2597,7 +2603,7 @@ void *consumer_thread_sessiond_poll(void *data)
 
        /* Blocking call, waiting for transmission */
        sock = lttcomm_accept_unix_sock(client_socket);
-       if (sock <= 0) {
+       if (sock < 0) {
                WARN("On accept");
                goto end;
        }
This page took 0.035441 seconds and 4 git commands to generate.