]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/compare.c
ITS#2607: improve socket() error logging with AF info
[openldap] / servers / slapd / compare.c
index 2bffeafbde6fbdcab0c0c31239cbec94b0fde696..7615323a5c0375808e6aca118361f9ca19e67669 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <stdio.h>
 #include <ac/socket.h>
+#include <ac/string.h>
 
 #include "ldap_pvt.h"
 #include "slap.h"
@@ -38,12 +39,10 @@ do_compare(
 )
 {
        Entry *entry = NULL;
-       Entry *fentry = NULL;
        struct berval dn = { 0, NULL };
        struct berval desc = { 0, NULL };
        struct berval value = { 0, NULL };
        AttributeAssertion ava = { NULL, { 0, NULL } };
-       Backend *be;
        int manageDSAit;
 
 #ifdef LDAP_SLAPI
@@ -112,7 +111,7 @@ do_compare(
                goto cleanup;
        } 
 
-       rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn );
+       rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
        if( rs->sr_err != LDAP_SUCCESS ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, 
@@ -132,15 +131,10 @@ do_compare(
                goto cleanup;
        }
 
-#ifdef SLAP_NVALUES
        rs->sr_err = asserted_value_validate_normalize( ava.aa_desc,
                ava.aa_desc->ad_type->sat_equality,
                SLAP_MR_EQUALITY|SLAP_MR_VALUE_OF_ASSERTION_SYNTAX,
-               &value, &ava.aa_value, &rs->sr_text );
-#else
-       rs->sr_err = value_validate_normalize( ava.aa_desc, SLAP_MR_EQUALITY,
-               &value, &ava.aa_value, &rs->sr_text );
-#endif
+               &value, &ava.aa_value, &rs->sr_text, op->o_tmpmemctx );
        if( rs->sr_err != LDAP_SUCCESS ) {
                send_ldap_result( op, rs );
                goto cleanup;
@@ -172,8 +166,6 @@ do_compare(
                        goto cleanup;
                }
 
-               fentry = entry;
-
        } else if ( bvmatch( &op->o_req_ndn, &global_schemandn ) ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, ARGS, 
@@ -202,12 +194,11 @@ do_compare(
                        rs->sr_err = 0;
                        goto cleanup;
                }
-               fentry = entry;
        }
 
        if( entry ) {
                rs->sr_err = compare_entry( op, entry, &ava );
-               if( fentry) entry_free( fentry );
+               entry_free( entry );
 
                send_ldap_result( op, rs );
 
@@ -270,7 +261,7 @@ do_compare(
        slapi_pblock_set( pb, SLAPI_COMPARE_VALUE, (void *)&value );
 
        rs->sr_err = doPluginFNs( op->o_bd, SLAPI_PLUGIN_PRE_COMPARE_FN, pb );
-       if ( rs->sr_err != 0 ) {
+       if ( rs->sr_err < 0 ) {
                /*
                 * A preoperation plugin failure will abort the
                 * entire operation.
@@ -282,14 +273,16 @@ do_compare(
                Debug(LDAP_DEBUG_TRACE, "do_compare: compare preoperation plugin "
                                "failed.\n", 0, 0, 0);
 #endif
-               if ( slapi_pblock_get( pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0)
+               if ( ( slapi_pblock_get( op->o_pb, SLAPI_RESULT_CODE, (void *)&rs->sr_err ) != 0 )  ||
+                    rs->sr_err == LDAP_SUCCESS ) {
                        rs->sr_err = LDAP_OTHER;
+               }
                goto cleanup;
        }
 #endif /* defined( LDAP_SLAPI ) */
 
        if ( op->o_bd->be_compare ) {
-               op->oq_compare.rs_ava = &ava;
+               op->orc_ava = &ava;
                op->o_bd->be_compare( op, rs );
        } else {
                send_ldap_error( op, rs, LDAP_UNWILLING_TO_PERFORM,
@@ -297,7 +290,7 @@ do_compare(
        }
 
 #if defined( LDAP_SLAPI )
-       if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) != 0 ) {
+       if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_POST_COMPARE_FN, pb ) < 0 ) {
 #ifdef NEW_LOGGING
                LDAP_LOG( OPERATION, INFO, "do_compare: compare postoperation plugins "
                                "failed\n", 0, 0, 0 );
@@ -309,9 +302,9 @@ do_compare(
 #endif /* defined( LDAP_SLAPI ) */
 
 cleanup:
-       free( op->o_req_dn.bv_val );
-       free( op->o_req_ndn.bv_val );
-       if ( ava.aa_value.bv_val ) free( ava.aa_value.bv_val );
+       op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+       op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+       if ( ava.aa_value.bv_val ) op->o_tmpfree( ava.aa_value.bv_val, op->o_tmpmemctx );
 
        return rs->sr_err;
 }
@@ -336,15 +329,11 @@ static int compare_entry(
        {
                rc = LDAP_COMPARE_FALSE;
 
-#ifdef SLAP_NVALUES
                if ( value_find_ex( ava->aa_desc,
                        SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
                                SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
                        a->a_nvals,
-                       &ava->aa_value ) == 0 )
-#else
-               if ( value_find( ava->aa_desc, a->a_vals, &ava->aa_value ) == 0 )
-#endif
+                       &ava->aa_value, op->o_tmpmemctx ) == 0 )
                {
                        rc = LDAP_COMPARE_TRUE;
                        break;