summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/ctdbd_conn.c15
-rw-r--r--source3/lib/packet.c10
2 files changed, 21 insertions, 4 deletions
diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c
index ffd79c9fe1..84bba3bea3 100644
--- a/source3/lib/ctdbd_conn.c
+++ b/source3/lib/ctdbd_conn.c
@@ -275,6 +275,17 @@ static struct messaging_rec *ctdb_pull_messaging_rec(TALLOC_CTX *mem_ctx,
return result;
}
+static NTSTATUS ctdb_packet_fd_read_sync(struct packet_context *ctx)
+{
+ struct timeval timeout;
+ struct timeval *ptimeout;
+
+ timeout = timeval_set(lp_ctdb_timeout(), 0);
+ ptimeout = (timeout.tv_sec != 0) ? &timeout : NULL;
+
+ return packet_fd_read_sync(ctx, ptimeout);
+}
+
/*
* Read a full ctdbd request. If we have a messaging context, defer incoming
* messages that might come in between.
@@ -289,7 +300,7 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid,
again:
- status = packet_fd_read_sync(conn->pkt);
+ status = ctdb_packet_fd_read_sync(conn->pkt);
if (NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_BUSY)) {
/* EAGAIN */
@@ -1156,7 +1167,7 @@ NTSTATUS ctdbd_traverse(uint32 db_id,
break;
}
- status = packet_fd_read_sync(conn->pkt);
+ status = ctdb_packet_fd_read_sync(conn->pkt);
if (NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
/*
diff --git a/source3/lib/packet.c b/source3/lib/packet.c
index ef28bf9f62..c131b973bc 100644
--- a/source3/lib/packet.c
+++ b/source3/lib/packet.c
@@ -101,7 +101,8 @@ NTSTATUS packet_fd_read(struct packet_context *ctx)
return NT_STATUS_OK;
}
-NTSTATUS packet_fd_read_sync(struct packet_context *ctx)
+NTSTATUS packet_fd_read_sync(struct packet_context *ctx,
+ struct timeval *timeout)
{
int res;
fd_set r_fds;
@@ -109,7 +110,12 @@ NTSTATUS packet_fd_read_sync(struct packet_context *ctx)
FD_ZERO(&r_fds);
FD_SET(ctx->fd, &r_fds);
- res = sys_select(ctx->fd+1, &r_fds, NULL, NULL, NULL);
+ res = sys_select(ctx->fd+1, &r_fds, NULL, NULL, timeout);
+
+ if (res == 0) {
+ DEBUG(10, ("select timed out\n"));
+ return NT_STATUS_IO_TIMEOUT;
+ }
if (res == -1) {
DEBUG(10, ("select returned %s\n", strerror(errno)));