summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2010-04-06 14:14:53 +0200
committerKarolin Seeger <kseeger@samba.org>2010-05-06 14:08:36 +0200
commit9d874a827227a1327bb7695648e140229ad20522 (patch)
tree77084a7363b13d7a85c05005d230b38d06c4063d
parentdb29ba6c5e6ede7bd94368f2cc66ac0647b86d6a (diff)
downloadsamba-9d874a827227a1327bb7695648e140229ad20522.tar.gz
s3: Fix infinite loop in NCACN_IP_TCP asa there is no timeout. Assume lsa_pipe_tcp is ok but network is down, then send request is ok, but select() on writeable fds loops forever since there is no response.
Signed-off-by: Bo Yang <boyang@samba.org> (cherry picked from commit 36493bf2f6634b84c57107bcb86bcbf3e82e80fc) (similar to commit b58b359881c91ec382cfa1d6ba3007b8354b29cb) Signed-off-by: Stefan Metzmacher <metze@samba.org> (cherry picked from commit 6166e1809516e6ab5911b56b20a4128b088828cf)
-rw-r--r--source3/rpc_client/rpc_transport_sock.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source3/rpc_client/rpc_transport_sock.c b/source3/rpc_client/rpc_transport_sock.c
index d61f4e9ab81..2cc66946902 100644
--- a/source3/rpc_client/rpc_transport_sock.c
+++ b/source3/rpc_client/rpc_transport_sock.c
@@ -24,6 +24,7 @@
struct rpc_transport_sock_state {
int fd;
+ int timeout;
};
static int rpc_transport_sock_state_destructor(struct rpc_transport_sock_state *s)
@@ -52,6 +53,7 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
struct async_req *result;
struct tevent_req *subreq;
struct rpc_sock_read_state *state;
+ struct timeval endtime;
if (!async_req_setup(mem_ctx, &result, &state,
struct rpc_sock_read_state)) {
@@ -64,10 +66,16 @@ static struct async_req *rpc_sock_read_send(TALLOC_CTX *mem_ctx,
return result;
}
state->transp = sock_transp;
+ endtime = timeval_current_ofs(0, sock_transp->timeout * 1000);
subreq = async_recv_send(state, ev, sock_transp->fd, data, size, 0);
if (subreq == NULL) {
goto fail;
}
+
+ if (!tevent_req_set_endtime(subreq, ev, endtime)) {
+ goto fail;
+ }
+
tevent_req_set_callback(subreq, rpc_sock_read_done, result);
return result;
fail:
@@ -131,6 +139,7 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
struct async_req *result;
struct tevent_req *subreq;
struct rpc_sock_write_state *state;
+ struct timeval endtime;
if (!async_req_setup(mem_ctx, &result, &state,
struct rpc_sock_write_state)) {
@@ -143,10 +152,16 @@ static struct async_req *rpc_sock_write_send(TALLOC_CTX *mem_ctx,
return result;
}
state->transp = sock_transp;
+ endtime = timeval_current_ofs(0, sock_transp->timeout * 1000);
subreq = async_send_send(state, ev, sock_transp->fd, data, size, 0);
if (subreq == NULL) {
goto fail;
}
+
+ if (!tevent_req_set_endtime(subreq, ev, endtime)) {
+ goto fail;
+ }
+
tevent_req_set_callback(subreq, rpc_sock_write_done, result);
return result;
fail:
@@ -211,6 +226,7 @@ NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
result->priv = state;
state->fd = fd;
+ state->timeout = 10000; /* 10 seconds. */
talloc_set_destructor(state, rpc_transport_sock_state_destructor);
result->trans_send = NULL;