1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

pyrpc: Allow control of RPC timeout for IRPC

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2016-07-09 16:36:52 +12:00 committed by Garming Sam
parent cea4a4b9b2
commit 2d3fdc0a45
3 changed files with 12 additions and 2 deletions

View 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'''

View 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));
}

View 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;
}