]> git.sur5r.net Git - openldap/commitdiff
don't risk leaving around client library error codes; try to return additional inform...
authorPierangelo Masarati <ando@openldap.org>
Tue, 22 Jun 2010 23:26:06 +0000 (23:26 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 22 Jun 2010 23:26:06 +0000 (23:26 +0000)
servers/slapd/back-meta/bind.c
servers/slapd/back-meta/conn.c
servers/slapd/back-meta/search.c

index 5c56ec427429b9af72f475fdc99d04026e3d9387..7c89bee1898bf2287c22f68dfee07c9d638f6663 100644 (file)
@@ -425,6 +425,7 @@ retry:;
                        if ( rc != LDAP_SUCCESS ) {
                                rs->sr_err = rc;
                        }
+                       rs->sr_err = slap_map_api2result( rs );
                        break;
                }
        }
@@ -1042,10 +1043,12 @@ retry:;
                                rc = ldap_parse_result( msc->msc_ld, res, &rs->sr_err,
                                                &matched, &text, &refs, &ctrls, 1 );
                                res = NULL;
-                               rs->sr_text = text;
-                               if ( rc != LDAP_SUCCESS ) {
+                               if ( rc == LDAP_SUCCESS ) {
+                                       rs->sr_text = text;
+                               } else {
                                        rs->sr_err = rc;
                                }
+                               rs->sr_err = slap_map_api2result( rs );
 
                                /* RFC 4511: referrals can only appear
                                 * if result code is LDAP_REFERRAL */
index 7fa6ce65b95bba29003f7a24c3ba4fc200112ccd..ca5b7932c380ff1f616ccb30411261273ccb40d5 100644 (file)
@@ -485,6 +485,7 @@ retry:;
                                        if ( rs->sr_err == LDAP_SUCCESS ) {
                                                rs->sr_err = err;
                                        }
+                                       rs->sr_err = slap_map_api2result( rs );
                                        
                                        /* FIXME: in case a referral 
                                         * is returned, should we try
index c328c57a73845bae79b9671a2e4fe4a1e110f64a..740266c7fc14c0126a072c191ea2c324726e42b4 100644 (file)
@@ -387,10 +387,8 @@ meta_search_dobind_result(
                NULL, NULL, NULL, NULL, 0 );
        if ( rc != LDAP_SUCCESS ) {
                candidates[ candidate ].sr_err = rc;
-
-       } else {
-               rc = slap_map_api2result( &candidates[ candidate ] );
        }
+       rc = slap_map_api2result( &candidates[ candidate ] );
 
        ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
        LDAP_BACK_CONN_BINDING_CLEAR( msc );
@@ -688,6 +686,7 @@ meta_back_search( Operation *op, SlapReply *rs )
        int             is_ok = 0;
        void            *savepriv;
        SlapReply       *candidates = NULL;
+       int             do_taint = 0;
 
        /*
         * controls are set in ldap_back_dobind()
@@ -1292,11 +1291,12 @@ really_bad:;
                                                msg,
                                                &candidates[ i ].sr_err,
                                                (char **)&candidates[ i ].sr_matched,
-                                               NULL /* (char **)&candidates[ i ].sr_text */ ,
+                                               (char **)&candidates[ i ].sr_text,
                                                &references,
                                                NULL /* &candidates[ i ].sr_ctrls (unused) */ ,
                                                0 );
                                        if ( rs->sr_err != LDAP_SUCCESS ) {
+                                               candidates[ i ].sr_err = rs->sr_err;
                                                sres = slap_map_api2result( &candidates[ i ] );
                                                candidates[ i ].sr_type = REP_RESULT;
                                                ldap_msgfree( res );
@@ -1438,9 +1438,12 @@ really_bad:;
                                                if ( rs->sr_nentries == op->ors_slimit
                                                        || META_BACK_ONERR_STOP( mi ) )
                                                {
+                                                       char *save_text = rs->sr_text;
                                                        savepriv = op->o_private;
                                                        op->o_private = (void *)i;
+                                                       rs->sr_text = candidates[ i ].sr_text;
                                                        send_ldap_result( op, rs );
+                                                       rs->sr_text = save_text;
                                                        op->o_private = savepriv;
                                                        ldap_msgfree( res );
                                                        res = NULL;
@@ -1451,9 +1454,12 @@ really_bad:;
                                        default:
                                                candidates[ i ].sr_err = rs->sr_err;
                                                if ( META_BACK_ONERR_STOP( mi ) ) {
+                                                       char *save_text = rs->sr_text;
                                                        savepriv = op->o_private;
                                                        op->o_private = (void *)i;
+                                                       rs->sr_text = candidates[ i ].sr_text;
                                                        send_ldap_result( op, rs );
+                                                       rs->sr_text = save_text;
                                                        op->o_private = savepriv;
                                                        ldap_msgfree( res );
                                                        res = NULL;
@@ -1801,12 +1807,17 @@ finish:;
                        && op->o_time > mc->mc_conns[ i ].msc_time )
                {
                        /* don't let anyone else use this expired connection */
-                       LDAP_BACK_CONN_TAINTED_SET( mc );
+                       do_taint++;
                }
        }
 
        if ( mc ) {
-               meta_back_release_conn( mi, mc );
+               ldap_pvt_thread_mutex_lock( &mi->mi_conninfo.lai_mutex );
+               if ( do_taint ) {
+                       LDAP_BACK_CONN_TAINTED_SET( mc );
+               }
+               meta_back_release_conn_lock( mi, mc, 0 );
+               ldap_pvt_thread_mutex_unlock( &mi->mi_conninfo.lai_mutex );
        }
 
        return rs->sr_err;