]> git.sur5r.net Git - openldap/commitdiff
use LDAP_SIZELIMIT_EXCEEDED; rework the return values of slap_send_search_entry(...
authorPierangelo Masarati <ando@openldap.org>
Fri, 25 Nov 2005 22:17:24 +0000 (22:17 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 25 Nov 2005 22:17:24 +0000 (22:17 +0000)
13 files changed:
servers/slapd/aci.c
servers/slapd/aclparse.c
servers/slapd/back-bdb/search.c
servers/slapd/back-ldap/search.c
servers/slapd/back-ldbm/search.c
servers/slapd/back-meta/search.c
servers/slapd/back-perl/search.c
servers/slapd/back-sql/search.c
servers/slapd/backglue.c
servers/slapd/bconfig.c
servers/slapd/overlays/retcode.c
servers/slapd/result.c
servers/slapd/slap.h

index 50bef60b754bf31c3d0458643b6c229601ca6794..70e749ef0a06b758d1b9fdbbf216593c632d138b 100644 (file)
@@ -696,7 +696,7 @@ aci_init( void )
                &rc, &text, LDAP_SCHEMA_ALLOW_ALL );
        if ( !at ) {
                Debug( LDAP_DEBUG_ANY,
-                       "%s AttributeType load failed: %s %s\n",
+                       "aci_init: AttributeType \"%s\" parse failed: %s %s\n",
                        aci_at.name, ldap_scherr2str( rc ), text );
                return rc;
        }
@@ -704,9 +704,9 @@ aci_init( void )
        rc = at_add( at, 0, &sat, &text );
        if ( rc != LDAP_SUCCESS ) {
                ldap_attributetype_free( at );
-               fprintf( stderr, "iMUX_monitor_schema_init: "
-                       "AttributeType load failed: %s %s\n",
-                       scherr2str( rc ), text );
+               Debug( LDAP_DEBUG_ANY,
+                       "aci_init: AttributeType \"%s\" load failed: %s %s\n",
+                       aci_at.name, scherr2str( rc ), text );
                return rc;
        }
        ldap_memfree( at );
@@ -715,7 +715,7 @@ aci_init( void )
                        aci_at.ad, &text );
        if ( rc != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_ANY,
-                       "unable to find AttributeDescription "
+                       "aci_init: unable to find AttributeDescription "
                        "\"%s\": %d (%s)\n",
                        aci_at.name, rc, text );
                return 1;
index 3cd2d5c9c9429ca4a8e985d3fb52f57722f4913a..5a666a4650eda5feed604bf3e49e88121cade0a3 100644 (file)
@@ -325,7 +325,7 @@ parse_acl(
        int             pos )
 {
        int             i;
-       char            *left, *right, *style, *next;
+       char            *left, *right, *style;
        struct berval   bv;
        AccessControl   *a;
        Access  *b;
@@ -776,8 +776,6 @@ parse_acl(
 
                                } else if ( strcasecmp( style, "level" ) == 0 )
                                {
-                                       char    *next;
-
                                        if ( lutil_atoi( &level, style_level ) != 0 ) {
                                                Debug( LDAP_DEBUG_ANY,
                                                        "%s: line %d: unable to parse level "
index 9b7a94f2f2ab2b2410c1462948ca329b3fc81192..e39c23daf936a4b45e73340ca72e600f92e5fb5b 100644 (file)
@@ -874,20 +874,20 @@ fetch_entry_retry:
 
                        if (e) {
                                /* safe default */
-                               int result = -1;
                                rs->sr_attrs = op->oq_search.rs_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_ctrls = NULL;
                                rs->sr_flags = 0;
                                rs->sr_err = LDAP_SUCCESS;
-                               result = send_search_entry( op, rs );
+                               rs->sr_err = send_search_entry( op, rs );
 
-                               switch ( result ) {
-                               case 0:         /* entry sent ok */
+                               switch ( rs->sr_err ) {
+                               case LDAP_SUCCESS:      /* entry sent ok */
                                        break;
-                               case 1:         /* entry not sent */
+                               default:                /* entry not sent */
                                        break;
-                               default:
+                               case LDAP_UNAVAILABLE:
+                               case LDAP_SIZELIMIT_EXCEEDED:
 #ifdef SLAP_ZONE_ALLOC
                                        slap_zn_runlock(bdb->bi_cache.c_zctx, e);
 #endif
@@ -895,16 +895,13 @@ fetch_entry_retry:
                                                &bdb->bi_cache, e, &lock);
                                        e = NULL;
                                        rs->sr_entry = NULL;
-                                       switch ( result ) {
-                                       case SLAPD_SEND_SIZELIMIT:
-                                               rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                                       if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
                                                rs->sr_ref = rs->sr_v2ref;
                                                send_ldap_result( op, rs );
                                                rs->sr_err = LDAP_SUCCESS;
-                                               break;
-                                       case -1:        /* connection closed */
+
+                                       } else {
                                                rs->sr_err = LDAP_OTHER;
-                                               break;
                                        }
                                        goto done;
                                }
index eb70948b443f353c8d0a94ed78c1fddb2269bd8d..1a30eb6960e81ca78596bff6596a93c6c5385bff 100644 (file)
@@ -286,7 +286,6 @@ retry:
                } else if ( rc == LDAP_RES_SEARCH_ENTRY ) {
                        Entry           ent = { 0 };
                        struct berval   bdn = BER_BVNULL;
-                       int             abort = 0;
 
                        do_retry = 0;
 
@@ -297,7 +296,7 @@ retry:
                                rs->sr_attrs = op->ors_attrs;
                                rs->sr_operational_attrs = NULL;
                                rs->sr_flags = 0;
-                               abort = send_search_entry( op, rs );
+                               rc = rs->sr_err = send_search_entry( op, rs );
                                if ( !BER_BVISNULL( &ent.e_name ) ) {
                                        assert( ent.e_name.bv_val != bdn.bv_val );
                                        free( ent.e_name.bv_val );
@@ -310,11 +309,12 @@ retry:
                                entry_clean( &ent );
                        }
                        ldap_msgfree( res );
-                       if ( abort ) {
-                               if ( abort == SLAPD_SEND_SIZELIMIT ) {
-                                       rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                       if ( rc != LDAP_SUCCESS ) {
+                               if ( rc == LDAP_UNAVAILABLE ) {
+                                       rc = rs->sr_err = LDAP_OTHER;
+                               } else {
+                                       ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
                                }
-                               ldap_abandon_ext( lc->lc_ld, msgid, NULL, NULL );
                                goto finish;
                        }
 
index 75aa5347f783a463b8bd5e99d275c146e862a794..633b7c23720fb16c712bf5254021a9e2d804e339 100644 (file)
@@ -432,20 +432,16 @@ searchit:
                        if ( scopeok ) {
                                if (e) {
                                        rs->sr_flags = 0;
-                                       result = send_search_entry( op, rs );
-
-                                       switch ( result ) {
-                                       case 0:         /* entry sent ok */
-                                               break;
-                                       case 1:         /* entry not sent */
-                                               break;
-                                       case -1:        /* connection closed */
+                                       rs->sr_err = send_search_entry( op, rs );
+
+                                       switch ( rs->sr_err ) {
+                                       case LDAP_UNAVAILABLE:  /* connection closed */
                                                cache_return_entry_r( &li->li_cache, e );
                                                rc = LDAP_SUCCESS;
                                                goto done;
-                                       case SLAPD_SEND_SIZELIMIT:
+                                       case LDAP_SIZELIMIT_EXCEEDED:
                                                cache_return_entry_r( &li->li_cache, e );
-                                               rc = rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                                               rc = rs->sr_err;
                                                rs->sr_entry = NULL;
                                                send_ldap_result( op, rs );
                                                rc = LDAP_SUCCESS;
index ae6e5c26160a904033076d5173b64d22332b7441..9f76beb98ecd3112a81cd620fad2c5c23102bd12 100644 (file)
@@ -456,20 +456,20 @@ really_bad:;
                                e = ldap_first_entry( msc->msc_ld, res );
                                savepriv = op->o_private;
                                op->o_private = (void *)i;
-                               rc = meta_send_entry( op, rs, mc, i, e );
+                               rs->sr_err = meta_send_entry( op, rs, mc, i, e );
                                ldap_msgfree( res );
                                res = NULL;
 
                                switch ( rc ) {
-                               case SLAPD_SEND_SIZELIMIT:
-                                       rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                               case LDAP_SIZELIMIT_EXCEEDED:
                                        savepriv = op->o_private;
                                        op->o_private = (void *)i;
                                        send_ldap_result( op, rs );
                                        op->o_private = savepriv;
+                                       rs->sr_err = LDAP_SUCCESS;
                                        goto finish;
 
-                               case -1:
+                               case LDAP_UNAVAILABLE:
                                        rs->sr_err = LDAP_OTHER;
                                        goto finish;
                                }
@@ -1156,20 +1156,11 @@ next_attr:;
        rs->sr_entry = &ent;
        rs->sr_attrs = op->ors_attrs;
        rs->sr_flags = 0;
-       switch ( send_search_entry( op, rs ) ) {
-       case 0:
-       case 1:
-               rc = LDAP_SUCCESS;
-               break;
-       case -1:
+       rc = send_search_entry( op, rs );
+       switch ( rc ) {
+       case LDAP_UNAVAILABLE:
                rc = LDAP_OTHER;
                break;
-       case SLAPD_SEND_SIZELIMIT:
-               rc = LDAP_SIZELIMIT_EXCEEDED;
-               break;
-       default:
-               /* trap other values when added... */
-               assert( 0 );
        }
        rs->sr_entry = NULL;
        rs->sr_attrs = NULL;
index 548a3148705df34761f46d4b72fd26971358c3b1..3709ac18d263171a113c721f08d9964e631e54d7 100644 (file)
@@ -89,11 +89,10 @@ perl_back_search(
                                                rs->sr_entry = e;
                                                rs->sr_attrs = op->ors_attrs;
                                                rs->sr_flags = REP_ENTRY_MODIFIABLE;
-                                               rc = send_search_entry( op, rs );
-                                               switch ( rc ) {
-                                               case SLAPD_SEND_SIZELIMIT:
+                                               rs->sr_err = LDAP_SUCCESS;
+                                               rs->sr_err = send_search_entry( op, rs );
+                                               if ( rs->sr_err == LDAP_SIZELIMIT_EXCEEDED ) {
                                                        rs->sr_entry = NULL;
-                                                       rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
                                                        goto done;
                                                }
                                        }
index 58e506d3e5e0a832ec636132e7a53c99252c8b1a..efc65072242036c9d72b457a9647cfc6b882bda1 100644 (file)
@@ -2325,13 +2325,13 @@ backsql_search( Operation *op, SlapReply *rs )
                        rs->sr_entry = e;
                        rs->sr_flags = ( e == &user_entry ) ? REP_ENTRY_MODIFIABLE : 0;
                        /* FIXME: need the whole entry (ITS#3480) */
-                       sres = send_search_entry( op, rs );
+                       rs->sr_err = send_search_entry( op, rs );
                        rs->sr_entry = NULL;
                        rs->sr_attrs = NULL;
                        rs->sr_operational_attrs = NULL;
 
-                       switch ( sres ) {
-                       case -1:
+                       switch ( rs->sr_err ) {
+                       case LDAP_UNAVAILABLE:
                                /*
                                 * FIXME: send_search_entry failed;
                                 * better stop
@@ -2340,8 +2340,7 @@ backsql_search( Operation *op, SlapReply *rs )
                                        "connection lost\n", 0, 0, 0 );
                                goto end_of_search;
 
-                       case SLAPD_SEND_SIZELIMIT:
-                               rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                       case LDAP_SIZELIMIT_EXCEEDED:
                                goto send_results;
                        }
                }
index e9c785f1a72919cfba6cb5c31bb1fcd75b94994b..649f7098e0c51a917ee36f25f4c05adca857f713 100644 (file)
@@ -234,7 +234,7 @@ glue_op_search ( Operation *op, SlapReply *rs )
        BackendInfo *bi0 = op->o_bd->bd_info;
        int i;
        long stoptime = 0;
-       glue_state gs = {0, 0, 0, NULL, 0, NULL};
+       glue_state gs = {0, 0, NULL, 0, NULL};
        slap_callback cb = { NULL, glue_op_response, NULL, NULL };
        int scope0, tlimit0;
        struct berval dn, ndn, *pdn;
index 52f4197ce43d053bca7ca14af4b9a749a8c00cc1..1bd756a045ad55dfe977e6ee41420f06ec3e2a69 100644 (file)
@@ -1489,7 +1489,6 @@ config_schema_dn(ConfigArgs *c) {
 static int
 config_sizelimit(ConfigArgs *c) {
        int i, rc = 0;
-       char *next;
        struct slap_limits_set *lim = &c->be->be_def_limit;
        if (c->op == SLAP_CONFIG_EMIT) {
                char buf[8192];
@@ -1541,7 +1540,6 @@ config_sizelimit(ConfigArgs *c) {
 static int
 config_timelimit(ConfigArgs *c) {
        int i, rc = 0;
-       char *next;
        struct slap_limits_set *lim = &c->be->be_def_limit;
        if (c->op == SLAP_CONFIG_EMIT) {
                char buf[8192];
@@ -2137,7 +2135,6 @@ static int config_syslog;
 static int
 config_loglevel(ConfigArgs *c) {
        int i;
-       char *next;
 
        if ( loglevel_ops == NULL ) {
                loglevel_init();
index 89ac536cd76452a309de9a79b72f6f7b1ed4a6e4..79db976854cb297567b178ee415e86a93c578f58 100644 (file)
@@ -114,8 +114,6 @@ retcode_send_onelevel( Operation *op, SlapReply *rs )
        retcode_item_t  *rdi;
        
        for ( rdi = rd->rd_item; rdi != NULL; rdi = rdi->rdi_next ) {
-               int     rc;
-
                if ( op->o_abandon ) {
                        return rs->sr_err = SLAPD_ABANDON;
                }
@@ -135,20 +133,14 @@ retcode_send_onelevel( Operation *op, SlapReply *rs )
                        rs->sr_err = LDAP_SUCCESS;
                        rs->sr_entry = &rdi->rdi_e;
 
-                       rc = send_search_entry( op, rs );
+                       rs->sr_err = send_search_entry( op, rs );
+                       rs->sr_entry = NULL;
 
-                       switch ( rc ) {
-                       case 0:         /* entry sent ok */
-                               break;
-                       case 1:         /* entry not sent */
-                               break;
-                       case -1:        /* connection closed */
-                               rs->sr_entry = NULL;
+                       switch ( rs->sr_err ) {
+                       case LDAP_UNAVAILABLE:  /* connection closed */
                                rs->sr_err = LDAP_OTHER;
-                               goto done;
-                       case SLAPD_SEND_SIZELIMIT:
-                               rs->sr_entry = NULL;
-                               rs->sr_err = LDAP_SIZELIMIT_EXCEEDED;
+                               /* fallthru */
+                       case LDAP_SIZELIMIT_EXCEEDED:
                                goto done;
                        }
                }
index 72889c1e3f0c203060abbea2ab879e42a81c155a..177273af8e88335ea44fd3668ed55cdc8c20ac4c 100644 (file)
@@ -665,10 +665,11 @@ slap_send_ldap_intermediate( Operation *op, SlapReply *rs )
 /*
  * returns:
  *
- *  0                  entry sent
- *  1                  entry not sent (other)
- * -1                  entry not sent (connection closed)
- * SLAPD_SEND_SIZELIMIT        entry not sent (caller must send sizelimitExceeded)
+ * LDAP_SUCCESS                        entry sent
+ * LDAP_OTHER                  entry not sent (other)
+ * LDAP_INSUFFICIENT_ACCESS    entry not sent (ACL)
+ * LDAP_UNAVAILABLE            entry not sent (connection closed)
+ * LDAP_SIZELIMIT_EXCEEDED     entry not sent (caller must send sizelimitExceeded)
  */
 
 int
@@ -677,7 +678,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        BerElementBuffer berbuf;
        BerElement      *ber = (BerElement *) &berbuf;
        Attribute       *a;
-       int             i, j, rc=-1, bytes;
+       int             i, j, rc = LDAP_UNAVAILABLE, bytes;
        char            *edn;
        int             userattrs;
        AccessControlState acl_state = ACL_STATE_INIT;
@@ -691,7 +692,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        char **e_flags = NULL;
 
        if ( op->ors_slimit >= 0 && rs->sr_nentries >= op->ors_slimit ) {
-               return SLAPD_SEND_SIZELIMIT;
+               return LDAP_SIZELIMIT_EXCEEDED;
        }
 
        rs->sr_type = REP_SEARCH;
@@ -744,7 +745,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                        "send_search_entry: conn %lu access to entry (%s) not allowed\n", 
                        op->o_connid, rs->sr_entry->e_name.bv_val, 0 );
 
-               rc = 1;
+               rc = LDAP_INSUFFICIENT_ACCESS;
                goto error_return;
        }
 
@@ -790,6 +791,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                send_ldap_error( op, rs, LDAP_OTHER, "encoding DN error" );
+               rc = rs->sr_err;
                goto error_return;
        }
 
@@ -837,6 +839,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                send_ldap_error( op, rs, LDAP_OTHER,
                                        "matched values filtering error" );
+                               rc = rs->sr_err;
                                goto error_return;
                        }
                }
@@ -886,6 +889,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                send_ldap_error( op, rs, LDAP_OTHER,
                                        "encoding description error");
+                               rc = rs->sr_err;
                                goto error_return;
                        }
                        finish = 1;
@@ -919,6 +923,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                                send_ldap_error( op, rs, LDAP_OTHER,
                                                        "encoding description error");
+                                               rc = rs->sr_err;
                                                goto error_return;
                                        }
                                }
@@ -930,6 +935,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                        send_ldap_error( op, rs, LDAP_OTHER,
                                                "encoding values error" );
+                                       rc = rs->sr_err;
                                        goto error_return;
                                }
                        }
@@ -942,6 +948,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                        send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
+                       rc = rs->sr_err;
                        goto error_return;
                }
        }
@@ -995,6 +1002,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                send_ldap_error( op, rs, LDAP_OTHER,
                                        "matched values filtering error" );
+                               rc = rs->sr_err;
                                goto error_return;
                        }
                }
@@ -1044,6 +1052,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                        send_ldap_error( op, rs, LDAP_OTHER,
                                "encoding description error" );
+                       rc = rs->sr_err;
                        goto error_return;
                }
 
@@ -1072,6 +1081,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                                        send_ldap_error( op, rs, LDAP_OTHER,
                                                "encoding values error" );
+                                       rc = rs->sr_err;
                                        goto error_return;
                                }
                        }
@@ -1084,6 +1094,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                        if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                        send_ldap_error( op, rs, LDAP_OTHER, "encode end error" );
+                       rc = rs->sr_err;
                        goto error_return;
                }
        }
@@ -1118,7 +1129,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
 
                if ( op->o_res_ber == NULL ) ber_free_buf( ber );
                send_ldap_error( op, rs, LDAP_OTHER, "encode entry end error" );
-               rc = 1;
+               rc = rs->sr_err;
                goto error_return;
        }
 
@@ -1137,7 +1148,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                                "send_search_entry: conn %lu  ber write failed.\n", 
                                op->o_connid, 0, 0 );
 
-                       rc = -1;
+                       rc = LDAP_UNAVAILABLE;
                        goto error_return;
                }
                rs->sr_nentries++;
@@ -1155,7 +1166,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
        Debug( LDAP_DEBUG_TRACE,
                "<= send_search_entry: conn %lu exit.\n", op->o_connid, 0, 0 );
 
-       rc = 0;
+       rc = LDAP_SUCCESS;
 
 error_return:;
        if ( op->o_callback ) {
index 5de958e374057fa6090dc2c090a0c566765a07b6..23ff59b9d64bfcc9692a10a61d8d68fc9837226a 100644 (file)
@@ -153,9 +153,6 @@ LDAP_BEGIN_DECL
 /* unknown config file directive */
 #define SLAP_CONF_UNKNOWN (-1026)
 
-/* pseudo error code indicating caller should send sizelimitExceeded */
-#define SLAPD_SEND_SIZELIMIT (-1027)
-
 /* We assume "C" locale, that is US-ASCII */
 #define ASCII_SPACE(c) ( (c) == ' ' )
 #define ASCII_LOWER(c) ( (c) >= 'a' && (c) <= 'z' )