From: Tim Beale Date: Mon, 3 Dec 2018 23:32:58 +0000 (+1300) Subject: s3:pylibsmb: .get_oplock_break API is dependent on multi_threaded=True X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=aaf7aaa6e26c62c62650dc01fff902d3a949a315;p=metze%2Fsamba%2Fwip.git s3:pylibsmb: .get_oplock_break API is dependent on multi_threaded=True The .get_oplock_break is dependent on the pthread code, which is only used when creating a SMB connection with multi_threaded=True. Add an explicit error to the .get_oplock_break() if someone tries to use it in non-multithreaded mode. Initializing self->oplock_waiter in non-multithreaded mode is similarly redundant if the API can never be used. Pair-Programmed-With: Stefan Metzmacher BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett --- diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index e4552a2d68a2..19587a8f0741 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -526,6 +526,13 @@ static int py_cli_state_init(struct py_cli_state *self, PyObject *args, self->is_smb1 = true; } + /* + * Oplocks require a multi threaded connection + */ + if (self->thread_state == NULL) { + return 0; + } + self->oplock_waiter = cli_smb_oplock_break_waiter_send( self->ev, self->ev, self->cli); if (self->oplock_waiter == NULL) { @@ -585,6 +592,13 @@ static PyObject *py_cli_get_oplock_break(struct py_cli_state *self, return NULL; } + if (self->thread_state == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "get_oplock_break() only possible on " + "a multi_threaded connection"); + return NULL; + } + if (self->oplock_cond != NULL) { errno = EBUSY; PyErr_SetFromErrno(PyExc_RuntimeError);