From 332eeb8bc152a7ba10c81c92cd8aec21733692c3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Jul 2014 12:35:39 +0000 Subject: [PATCH] ctdbd_conn: Only poll if there's a timeout At this point the ctdb socket is blocking, so we can save a syscall when we wait indefinitely anyway. Signed-off-by: Volker Lendecke Reviewed-by: Michael Adam Autobuild-User(master): Michael Adam Autobuild-Date(master): Wed Aug 6 18:01:54 CEST 2014 on sn-devel-104 --- source3/lib/ctdbd_conn.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index 29482a0e79b..3e5e838bd61 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -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)); -- 2.11.4.GIT