ctdbd_conn: Only poll if there's a timeout
authorVolker Lendecke <vl@samba.org>
Mon, 21 Jul 2014 12:35:39 +0000 (12:35 +0000)
committerMichael Adam <obnox@samba.org>
Wed, 6 Aug 2014 16:01:53 +0000 (18:01 +0200)
At this point the ctdb socket is blocking, so we can save a syscall when
we wait indefinitely anyway.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Aug  6 18:01:54 CEST 2014 on sn-devel-104

source3/lib/ctdbd_conn.c

index 29482a0e79b729207a1e828c9cd68585cba4f108..3e5e838bd61dc987a675fc4859a001db268ad42f 100644 (file)
@@ -324,15 +324,17 @@ static NTSTATUS ctdb_read_packet(int fd, TALLOC_CTX *mem_ctx,
                timeout = -1;
        }
 
-       ret = poll_one_fd(fd, POLLIN, timeout, &revents);
-       if (ret == -1) {
-               return map_nt_error_from_unix(errno);
-       }
-       if (ret == 0) {
-               return NT_STATUS_IO_TIMEOUT;
-       }
-       if (ret != 1) {
-               return NT_STATUS_UNEXPECTED_IO_ERROR;
+       if (timeout != -1) {
+               ret = poll_one_fd(fd, POLLIN, timeout, &revents);
+               if (ret == -1) {
+                       return map_nt_error_from_unix(errno);
+               }
+               if (ret == 0) {
+                       return NT_STATUS_IO_TIMEOUT;
+               }
+               if (ret != 1) {
+                       return NT_STATUS_UNEXPECTED_IO_ERROR;
+               }
        }
 
        status = read_data(fd, (char *)&msglen, sizeof(msglen));