Skip to content

Commit

Permalink
more fine-grained GIL releasing in function l_ldap_result4()
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Sep 7, 2017
1 parent fae6038 commit c469bb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Released 2.4.44 2017-09-xx
Changes since 2.4.43:

Modules/
*
* more fine-grained GIL releasing in function l_ldap_result4()

Lib/
*
Expand Down Expand Up @@ -1510,4 +1510,4 @@ Released 2.0.0pre02 2002-02-01
----------------------------------------------------------------
Released 1.10alpha3 2000-09-19

$Id: CHANGES,v 1.464 2017/09/07 09:01:01 stroeder Exp $
$Id: CHANGES,v 1.465 2017/09/07 09:03:00 stroeder Exp $
10 changes: 7 additions & 3 deletions Modules/LDAPObject.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* See https://www.python-ldap.org/ for details.
* $Id: LDAPObject.c,v 1.96 2017/08/15 16:21:59 stroeder Exp $ */
* $Id: LDAPObject.c,v 1.97 2017/09/07 09:03:00 stroeder Exp $ */

#include "common.h"
#include "patchlevel.h"
Expand Down Expand Up @@ -1024,7 +1024,6 @@ l_ldap_result4( LDAPObject* self, PyObject *args )
int result = LDAP_SUCCESS;
char **refs = NULL;
LDAPControl **serverctrls = 0;
LDAP_BEGIN_ALLOW_THREADS( self );
if (res_type == LDAP_RES_SEARCH_ENTRY) {
/* LDAPmessage_to_python will parse entries and read the controls for each entry */
} else if (res_type == LDAP_RES_SEARCH_REFERENCE) {
Expand All @@ -1035,18 +1034,21 @@ l_ldap_result4( LDAPObject* self, PyObject *args )
int rc;
if (res_type == LDAP_RES_EXTENDED) {
struct berval *retdata = 0;
LDAP_BEGIN_ALLOW_THREADS( self );
rc = ldap_parse_extended_result( self->ldap, msg, &retoid, &retdata, 0 );
LDAP_END_ALLOW_THREADS( self );
/* handle error rc!=0 here? */
if (rc == LDAP_SUCCESS) {
valuestr = LDAPberval_to_object(retdata);
}
ber_bvfree( retdata );
}

LDAP_BEGIN_ALLOW_THREADS( self );
rc = ldap_parse_result( self->ldap, msg, &result, NULL, NULL, &refs,
&serverctrls, 0 );
LDAP_END_ALLOW_THREADS( self );
}
LDAP_END_ALLOW_THREADS( self );

if (result != LDAP_SUCCESS) { /* result error */
char *e, err[1024];
Expand All @@ -1061,7 +1063,9 @@ l_ldap_result4( LDAPObject* self, PyObject *args )

if (!(pyctrls = LDAPControls_to_List(serverctrls))) {
int err = LDAP_NO_MEMORY;
LDAP_BEGIN_ALLOW_THREADS( self );
ldap_set_option(self->ldap, LDAP_OPT_ERROR_NUMBER, &err);
LDAP_END_ALLOW_THREADS( self );
ldap_msgfree(msg);
return LDAPerror(self->ldap, "LDAPControls_to_List");
}
Expand Down

0 comments on commit c469bb7

Please sign in to comment.