svn commit: samba r7497 - in branches/SAMBA_4_0/source/librpc/rpc: .

tridge at samba.org tridge at samba.org
Sun Jun 12 02:42:40 GMT 2005


Author: tridge
Date: 2005-06-12 02:42:40 +0000 (Sun, 12 Jun 2005)
New Revision: 7497

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7497

Log:
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

Modified:
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
   branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c


Changeset:
Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2005-06-12 02:18:25 UTC (rev 7496)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.c	2005-06-12 02:42:40 UTC (rev 7497)
@@ -110,6 +110,7 @@
 
 	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 @@
 }
 
 /*
+  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 @@
 		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,7 +846,27 @@
 	}
 }
 
+/*
+  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 @@
 		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;

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h	2005-06-12 02:18:25 UTC (rev 7496)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc.h	2005-06-12 02:42:40 UTC (rev 7497)
@@ -94,9 +94,15 @@
 
 	/* the last fault code from a DCERPC fault */
 	uint32_t last_fault_code;
+
+	/* timeout for individual rpc requests, in seconds */
+	uint_t request_timeout;
 };
 
+/* default timeout for all rpc requests, in seconds */
+#define DCERPC_REQUEST_TIMEOUT 60
 
+
 /* dcerpc pipe flags */
 #define DCERPC_DEBUG_PRINT_IN          (1<<0)
 #define DCERPC_DEBUG_PRINT_OUT         (1<<1)

Modified: branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c
===================================================================
--- branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-06-12 02:18:25 UTC (rev 7496)
+++ branches/SAMBA_4_0/source/librpc/rpc/dcerpc_util.c	2005-06-12 02:42:40 UTC (rev 7497)
@@ -1343,6 +1343,7 @@
 		return NT_STATUS_NO_MEMORY;
 	}
 	p2->conn = talloc_reference(p2, p->conn);
+	p2->request_timeout = p->request_timeout;
 
 	p2->context_id = ++p->conn->next_context_id;
 



More information about the samba-cvs mailing list