]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/operational.c
use pooled memory whenever appropriate
[openldap] / servers / slapd / back-sql / operational.c
index c0c7ed2442f5012f84a023febd91ffc9a5841725..e99741a6d9b4ae530e504a5f971f32c889f661cf 100644 (file)
@@ -1,8 +1,9 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2004 The OpenLDAP Foundation.
+ * Copyright 1999-2005 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
+ * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -15,7 +16,8 @@
  */
 /* ACKNOWLEDGEMENTS:
  * This work was initially developed by Dmitry Kovalev for inclusion
- * by OpenLDAP Software.
+ * by OpenLDAP Software.  Additional significant contributors include
+ * Pierangelo Masarati.
  */
 
 #include "portable.h"
@@ -81,15 +83,17 @@ backsql_operational_entryCSN( Operation *op )
        BER_BVZERO( &a->a_vals[ 1 ] );
 
 #ifdef BACKSQL_SYNCPROV
-       if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH ) {
-               assert( op->o_private );
+       if ( op->o_sync && op->o_tag == LDAP_REQ_SEARCH && op->o_private != NULL ) {
+               assert( op->o_private != NULL );
 
                entryCSN = *((struct berval *)op->o_private);
 
        } else
 #endif /* BACKSQL_SYNCPROV */
        {
-               slap_get_csn( op, csnbuf, sizeof(csnbuf), &entryCSN, 0 );
+               entryCSN.bv_val = csnbuf;
+               entryCSN.bv_len = sizeof( csnbuf );
+               slap_get_csn( op, &entryCSN, 0 );
        }
 
        ber_dupbv( &a->a_vals[ 0 ], &entryCSN );
@@ -156,13 +160,13 @@ backsql_operational(
                        && !got[ BACKSQL_OP_HASSUBORDINATES ]
                        && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL )
        {
-               rc = backsql_has_children( bi, dbh, &rs->sr_entry->e_nname );
+               rc = backsql_has_children( op, dbh, &rs->sr_entry->e_nname );
 
                switch( rc ) {
                case LDAP_COMPARE_TRUE:
                case LDAP_COMPARE_FALSE:
                        *ap = slap_operational_hasSubordinate( rc == LDAP_COMPARE_TRUE );
-                       assert( *ap );
+                       assert( *ap != NULL );
                        ap = &(*ap)->a_next;
                        rc = 0;
                        break;
@@ -178,12 +182,12 @@ backsql_operational(
                        && !got[ BACKSQL_OP_ENTRYUUID ]
                        && attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_entryUUID ) == NULL )
        {
-               backsql_srch_info       bsi;
+               backsql_srch_info       bsi = { 0 };
 
                rc = backsql_init_search( &bsi, &rs->sr_entry->e_nname,
-                               LDAP_SCOPE_BASE, -1, -1, -1, NULL,
-                               dbh, op, rs, NULL,
-                               ( BACKSQL_ISF_GET_ID | BACKSQL_ISF_MUCK ) );
+                               LDAP_SCOPE_BASE,
+                               (time_t)(-1), NULL, dbh, op, rs, NULL,
+                               BACKSQL_ISF_GET_ID );
                if ( rc != LDAP_SUCCESS ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "
                                "could not retrieve entry ID - no such entry\n", 
@@ -193,7 +197,11 @@ backsql_operational(
 
                *ap = backsql_operational_entryUUID( bi, &bsi.bsi_base_id );
 
-               (void)backsql_free_entryID( &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+
+               if ( bsi.bsi_attrs != NULL ) {
+                       op->o_tmpfree( bsi.bsi_attrs, op->o_tmpmemctx );
+               }
 
                if ( *ap == NULL ) {
                        Debug( LDAP_DEBUG_TRACE, "backsql_operational(): "