From: Andrew Bartlett Date: Sat, 9 Jul 2016 04:36:52 +0000 (+1200) Subject: pyrpc: Allow control of RPC timeout for IRPC X-Git-Tag: tdb-1.3.10~415 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d3fdc0a45b7acae64b90ab701fcec170c4da07d;p=thirdparty%2Fsamba.git pyrpc: Allow control of RPC timeout for IRPC Signed-off-by: Andrew Bartlett Reviewed-by: Garming Sam --- diff --git a/python/samba/netcmd/drs.py b/python/samba/netcmd/drs.py index cbd1672a9f4..35a5bfd9335 100644 --- a/python/samba/netcmd/drs.py +++ b/python/samba/netcmd/drs.py @@ -34,6 +34,7 @@ from samba import drs_utils, nttime2string, dsdb from samba.dcerpc import drsuapi, misc import common from samba.join import join_clone +from samba.messaging import IRPC_CALL_TIMEOUT_INF def drsuapi_connect(ctx): '''make a DRSUAPI connection to the server''' diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 0eca1399632..cef0703dc33 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -399,4 +399,6 @@ void initmessaging(void) Py_INCREF((PyObject *)&imessaging_Type); PyModule_AddObject(mod, "Messaging", (PyObject *)&imessaging_Type); + PyModule_AddObject(mod, "IRPC_CALL_TIMEOUT", PyInt_FromLong(IRPC_CALL_TIMEOUT)); + PyModule_AddObject(mod, "IRPC_CALL_TIMEOUT_INF", PyInt_FromLong(IRPC_CALL_TIMEOUT_INF)); } diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c index b74eb4c944e..a9807a891ba 100644 --- a/source4/librpc/rpc/pyrpc_util.c +++ b/source4/librpc/rpc/pyrpc_util.c @@ -99,11 +99,12 @@ PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, Py const char *binding_string; PyObject *py_lp_ctx = Py_None, *py_credentials = Py_None, *py_basis = Py_None; NTSTATUS status; + unsigned int timeout = (unsigned int)-1; const char *kwnames[] = { - "binding", "lp_ctx", "credentials", "basis_connection", NULL + "binding", "lp_ctx", "credentials", "timeout", "basis_connection", NULL }; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|OOO:samr", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials, &py_basis)) { + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|OOIO:samr", discard_const_p(char *, kwnames), &binding_string, &py_lp_ctx, &py_credentials, &timeout, &py_basis)) { return NULL; } @@ -231,6 +232,12 @@ PyObject *py_dcerpc_interface_init_helper(PyTypeObject *type, PyObject *args, Py ret->pipe->conn->flags |= DCERPC_NDR_REF_ALLOC; ret->binding_handle = ret->pipe->binding_handle; } + + /* reset timeout for the handle */ + if (timeout != ((unsigned int)-1)) { + dcerpc_binding_handle_set_timeout(ret->binding_handle, timeout); + } + return (PyObject *)ret; }