]> git.sur5r.net Git - openldap/commitdiff
Don't use thread local malloc for search filter if SLAPI is enabled;
authorLuke Howard <lukeh@openldap.org>
Fri, 11 Apr 2003 06:30:41 +0000 (06:30 +0000)
committerLuke Howard <lukeh@openldap.org>
Fri, 11 Apr 2003 06:30:41 +0000 (06:30 +0000)
breaks API compat

servers/slapd/search.c

index 6c30fe2b2220988c7f71525d8b8e3057cb24cbe2..8aca9c3723611b6181259a819d3a33adc8ca047f 100644 (file)
@@ -45,6 +45,7 @@ do_search(
        int                     manageDSAit;
 #ifdef LDAP_SLAPI
        char            **attrs = NULL;
+       Operation       ch_op;
 #endif
 
 #ifdef NEW_LOGGING
@@ -135,7 +136,20 @@ do_search(
 #endif
 
        /* filter - returns a "normalized" version */
+#ifdef LDAP_SLAPI
+       /*
+        * SLAPI computed search rewriter plugins can reset the search
+        * filter, and because they have no way to specify the use of
+        * the thread-local malloc replacement, we must always use
+        * ch_malloc() to allocate the filter when SLAPI is enabled.
+        */
+       ch_op = *op; /* struct copy */
+       ch_op.o_tmpmemctx = NULL;
+       ch_op.o_tmpmfuncs = &ch_mfuncs;
+       rs->sr_err = get_filter( &ch_op, op->o_ber, &op->ors_filter, &rs->sr_text );
+#else
        rs->sr_err = get_filter( op, op->o_ber, &op->ors_filter, &rs->sr_text );
+#endif /* LDAP_SLAPI */
        if( rs->sr_err != LDAP_SUCCESS ) {
                if( rs->sr_err == SLAPD_DISCONNECT ) {
                        rs->sr_err = LDAP_PROTOCOL_ERROR;
@@ -396,7 +410,11 @@ return_results:;
        if( op->o_req_ndn.bv_val != NULL) sl_free( op->o_req_ndn.bv_val, op->o_tmpmemctx );
 
        if( op->ors_filterstr.bv_val != NULL) op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+#ifdef LDAP_SLAPI
+       if( op->ors_filter != NULL) filter_free( op->ors_filter );
+#else
        if( op->ors_filter != NULL) filter_free_x( op, op->ors_filter );
+#endif
        if( op->ors_attrs != NULL ) op->o_tmpfree( op->ors_attrs, op->o_tmpmemctx );
 #ifdef LDAP_SLAPI
        if( attrs != NULL) op->o_tmpfree( attrs, op->o_tmpmemctx );
@@ -472,36 +490,21 @@ static int doPreSearchPluginFNs( Operation *op )
 static int doSearchRewriteFNs( Operation *op )
 {
        if ( doPluginFNs( op->o_bd, SLAPI_PLUGIN_COMPUTE_SEARCH_REWRITER_FN, op->o_pb ) == 0 ) {
-               Filter *f;
-
                /*
                 * The plugin can set the SLAPI_SEARCH_FILTER.
                 * SLAPI_SEARCH_STRFILER is not normative.
                 */
-               slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&f );
-               if ( f != op->ors_filter ) {
-                       /* Plugin modified filter. Is pointer comparison safe? */
-                       /*
-                        * This is inefficient but it is not possible to expose the
-                        * new memory allocation API through SLAPI. 
-                        *
-                        * Further, the plugin should be responsible for freeing
-                        * the original filter, but there is no way to communicate
-                        * the memory context through the SLAPI filter free API.
-                        */
-                       op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
-                       filter2bv_x( op, f, &op->ors_filterstr );
-                       filter_free_x( op, op->ors_filter );
-                       op->ors_filter = str2filter_x( op, op->ors_filterstr.bv_val );
+               slapi_pblock_get( op->o_pb, SLAPI_SEARCH_FILTER, (void *)&op->ors_filter );
+               op->o_tmpfree( op->ors_filterstr.bv_val, op->o_tmpmemctx );
+               filter2bv_x( op, op->ors_filter, &op->ors_filterstr );
 #ifdef NEW_LOGGING
-                       LDAP_LOG( OPERATION, ARGS, 
-                               "doSearchRewriteFNs: after compute_rewrite_search filter: %s\n", 
-                               op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
+               LDAP_LOG( OPERATION, ARGS, 
+                       "doSearchRewriteFNs: after compute_rewrite_search filter: %s\n", 
+                       op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
 #else
-                       Debug( LDAP_DEBUG_ARGS, "    after compute_rewrite_search filter: %s\n",
-                               op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
+               Debug( LDAP_DEBUG_ARGS, "    after compute_rewrite_search filter: %s\n",
+                       op->ors_filterstr.bv_len ? op->ors_filterstr.bv_val : "empty", 0, 0 );
 #endif
-               }
        }
 
        return LDAP_SUCCESS;