]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/search.c
pool privileged connections (ITS#4791)
[openldap] / servers / slapd / back-ldap / search.c
index ff79c320eff2dc8d031f1601d70eb8bce27351b6..c7a20541665543a6ed945e288fde2b43b08900ea 100644 (file)
@@ -143,7 +143,7 @@ ldap_back_search(
 {
        ldapinfo_t      *li = (ldapinfo_t *) op->o_bd->be_private;
 
-       ldapconn_t      *lc;
+       ldapconn_t      *lc = NULL;
        struct timeval  tv;
        time_t          stoptime = (time_t)(-1);
        LDAPMessage     *res,
@@ -152,6 +152,7 @@ ldap_back_search(
                        msgid; 
        struct berval   match = BER_BVNULL,
                        filter = BER_BVNULL;
+       int             free_filter = 0;
        int             i;
        char            **attrs = NULL;
        int             freetext = 0;
@@ -160,8 +161,7 @@ ldap_back_search(
        /* FIXME: shouldn't this be null? */
        const char      *save_matched = rs->sr_matched;
 
-       lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
-       if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
+       if ( !ldap_back_dobind( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                return rs->sr_err;
        }
 
@@ -240,6 +240,7 @@ retry:
 
                case LDAP_FILTER_ERROR:
                        if ( ldap_back_munge_filter( op, &filter ) ) {
+                               free_filter = 1;
                                goto retry;
                        }
 
@@ -499,7 +500,7 @@ finish:;
                rs->sr_matched = save_matched;
        }
 
-       if ( !BER_BVISNULL( &filter ) && filter.bv_val != op->ors_filterstr.bv_val ) {
+       if ( free_filter ) {
                op->o_tmpfree( filter.bv_val, op->o_tmpmemctx );
        }
 
@@ -719,7 +720,7 @@ ldap_back_entry_get(
 {
        ldapinfo_t      *li = (ldapinfo_t *) op->o_bd->be_private;
 
-       ldapconn_t      *lc;
+       ldapconn_t      *lc = NULL;
        int             rc = 1,
                        do_not_cache;
        struct berval   bdn;
@@ -736,8 +737,7 @@ ldap_back_entry_get(
        /* Tell getconn this is a privileged op */
        do_not_cache = op->o_do_not_cache;
        op->o_do_not_cache = 1;
-       lc = ldap_back_getconn( op, &rs, LDAP_BACK_DONTSEND );
-       if ( !lc || !ldap_back_dobind( lc, op, &rs, LDAP_BACK_DONTSEND ) ) {
+       if ( !ldap_back_dobind( &lc, op, &rs, LDAP_BACK_DONTSEND ) ) {
                op->o_do_not_cache = do_not_cache;
                return rs.sr_err;
        }