diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-06-12 02:42:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:18:00 -0500 |
commit | ee30cf3b1df749241b8ed479d7b3558af81b27bf (patch) | |
tree | 36d1660d356b36d353937fd5b867b6e04bccd7a7 /source4/librpc/rpc/dcerpc.c | |
parent | d1e8e62a56a9e25f00868f287c8c4fe83f79dba9 (diff) | |
download | samba-ee30cf3b1df749241b8ed479d7b3558af81b27bf.tar.gz samba-ee30cf3b1df749241b8ed479d7b3558af81b27bf.tar.bz2 samba-ee30cf3b1df749241b8ed479d7b3558af81b27bf.zip |
r7497: add timeouts to all rpc requests. The default timeout is 60
seconds. This should prevent the problem I am seeing on a solaris box
where a rpc request gets stuck forever
(This used to be commit c24ab34813d675b9b81f3062fb6f30aae5697805)
Diffstat (limited to 'source4/librpc/rpc/dcerpc.c')
-rw-r--r-- | source4/librpc/rpc/dcerpc.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source4/librpc/rpc/dcerpc.c b/source4/librpc/rpc/dcerpc.c index 284a3c8841..fa7fe728d4 100644 --- a/source4/librpc/rpc/dcerpc.c +++ b/source4/librpc/rpc/dcerpc.c @@ -110,6 +110,7 @@ struct dcerpc_pipe *dcerpc_pipe_init(TALLOC_CTX *mem_ctx) p->last_fault_code = 0; p->context_id = 0; + p->request_timeout = DCERPC_REQUEST_TIMEOUT; ZERO_STRUCT(p->syntax); ZERO_STRUCT(p->transfer_syntax); @@ -521,6 +522,17 @@ static void full_request_recv(struct dcerpc_connection *c, DATA_BLOB *blob, } /* + handle timeouts of full dcerpc requests +*/ +static void dcerpc_full_timeout_handler(struct event_context *ev, struct timed_event *te, + struct timeval t, void *private) +{ + struct full_request_state *state = talloc_get_type(private, + struct full_request_state); + state->status = NT_STATUS_IO_TIMEOUT; +} + +/* perform a single pdu synchronous request - used for the bind code this cannot be mixed with normal async requests */ @@ -547,6 +559,10 @@ static NTSTATUS full_request(struct dcerpc_connection *c, return status; } + event_add_timed(c->transport.event_context(c), state, + timeval_current_ofs(DCERPC_REQUEST_TIMEOUT, 0), + dcerpc_full_timeout_handler, state); + while (NT_STATUS_IS_OK(state->status) && state->reply_blob) { struct event_context *ctx = c->transport.event_context(c); if (event_loop_once(ctx) != 0) { @@ -830,6 +846,26 @@ static void dcerpc_request_recv_data(struct dcerpc_connection *c, } } +/* + handle timeouts of individual dcerpc requests +*/ +static void dcerpc_timeout_handler(struct event_context *ev, struct timed_event *te, + struct timeval t, void *private) +{ + struct rpc_request *req = talloc_get_type(private, struct rpc_request); + + if (req->state != RPC_REQUEST_PENDING) { + return; + } + + req->status = NT_STATUS_IO_TIMEOUT; + req->state = RPC_REQUEST_DONE; + DLIST_REMOVE(req->p->conn->pending, req); + if (req->async.callback) { + req->async.callback(req); + } +} + /* make sure requests are cleaned up @@ -932,6 +968,12 @@ struct rpc_request *dcerpc_request_send(struct dcerpc_pipe *p, remaining -= chunk; } + if (p->request_timeout) { + event_add_timed(dcerpc_event_context(p), req, + timeval_current_ofs(p->request_timeout, 0), + dcerpc_timeout_handler, req); + } + talloc_set_destructor(req, dcerpc_req_destructor); return req; |