pyrpc: Allow control of RPC timeout for IRPC
authorAndrew Bartlett <abartlet@samba.org>
Sat, 9 Jul 2016 04:36:52 +0000 (16:36 +1200)
committerGarming Sam <garming@samba.org>
Tue, 12 Jul 2016 21:24:13 +0000 (23:24 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/netcmd/drs.py
source4/lib/messaging/pymessaging.c
source4/librpc/rpc/pyrpc_util.c

index cbd1672a9f4d8a6eed58b8fe2632056faeb019b8..35a5bfd93357ab58ed2bbf2ed6b4185a544ffdd0 100644 (file)
@@ -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'''
index 0eca13996322fb1d8bc7039734aa82ef41c82009..cef0703dc33e749a860c7db567543ac40b507eb9 100644 (file)
@@ -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));
 }
index b74eb4c944e1532c1270dbd7195c3cbac8d74746..a9807a891ba1ea895890b2ab51a5056f970f2aec 100644 (file)
@@ -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;
 }