]> git.sur5r.net Git - openldap/commitdiff
fix context memory and more cleanup
authorPierangelo Masarati <ando@openldap.org>
Fri, 11 Apr 2003 23:23:03 +0000 (23:23 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 11 Apr 2003 23:23:03 +0000 (23:23 +0000)
servers/slapd/back-sql/bind.c
servers/slapd/back-sql/entry-id.c
servers/slapd/back-sql/modify.c
servers/slapd/back-sql/other.c
servers/slapd/back-sql/search.c
servers/slapd/back-sql/util.c
servers/slapd/back-sql/util.h

index 10f871be40b086f86de1a20b0f28909679680287..fd3515d1f7c294a54959ba9ee5718f075385441b 100644 (file)
@@ -74,8 +74,8 @@ backsql_bind( Operation *op, SlapReply *rs )
                return 1;
        }
 
-       backsql_init_search( &bsi, bi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
-                       -1, -1, -1, NULL, dbh, op->o_bd, op->o_conn, op, NULL );
+       backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
+                       -1, -1, -1, NULL, dbh, op, NULL );
        e = backsql_id2entry( &bsi, &user_entry, &user_id );
        if ( e == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_bind(): "
index b87a012fd347e861e99946450e33c65960c6460e..2d449312c143791299019d8e535435f94f51af3c 100644 (file)
@@ -325,7 +325,8 @@ backsql_get_attr_vals( void *v_at, void *v_bsi )
                                bv.bv_len = strlen( row.cols[ i ] );
 #endif
                                        backsql_entry_addattr( bsi->e, 
-                                               &row.col_names[ i ], &bv );
+                                               &row.col_names[ i ], &bv,
+                                               bsi->op->o_tmpmemctx );
 
 #ifdef BACKSQL_TRACE
                                Debug( LDAP_DEBUG_TRACE, "prec=%d\n",
@@ -356,7 +357,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid )
 
        Debug( LDAP_DEBUG_TRACE, "==>backsql_id2entry()\n", 0, 0, 0 );
 
-       rc = dnPrettyNormal( NULL, &eid->dn, &e->e_name, &e->e_nname );
+       rc = dnPrettyNormal( NULL, &eid->dn, &e->e_name, &e->e_nname,
+                       bsi->op->o_tmpmemctx );
        if ( rc != LDAP_SUCCESS ) {
                return NULL;
        }
@@ -409,7 +411,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid )
                                bsi, 0, AVL_INORDER );
        }
 
-       if ( attr_mergeit_one( bsi->e, ad_oc, &bsi->oc->oc->soc_cname ) ) {
+       if ( attr_merge_normalize_one( bsi->e, ad_oc, &bsi->oc->oc->soc_cname,
+                               bsi->op->o_tmpmemctx ) ) {
                entry_free( e );
                return NULL;
        }
@@ -436,7 +439,8 @@ backsql_id2entry( backsql_srch_info *bsi, Entry *e, backsql_entryID *eid )
 
                if ( bsi->bsi_flags | BSQL_SF_ALL_OPER 
                                || an_find( bsi->attrs, &AllOper ) ) {
-                       if ( attr_mergeit_one( bsi->e, ad_soc, &soc ) ) {
+                       if ( attr_merge_normalize_one( bsi->e, ad_soc, &soc,
+                                               bsi->op->o_tmpmemctx ) ) {
                                entry_free( e );
                                return NULL;
                        }
index 8b1a376673d9abce2a59132a8c2bb97971626655..de3d63aa92e4c8d4a7592fe3fa4fda877af4ae3a 100644 (file)
@@ -679,13 +679,13 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                goto modrdn_return;
        }
 
-       build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn ); 
-       if ( dnNormalize2( NULL, &new_dn, &new_ndn ) != LDAP_SUCCESS ) {
+       build_new_dn( &new_dn, new_pdn, &op->oq_modrdn.rs_newrdn );
+       rs->sr_err = dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx );
+       if ( rs->sr_err != LDAP_SUCCESS ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_modrdn(): "
                        "new dn is invalid ('%s') - aborting\n",
                        new_dn.bv_val, 0, 0 );
-               rs->sr_err = LDAP_INVALID_DN_SYNTAX;
-               rs->sr_text = "new DN is invalid";
+               rs->sr_text = "unable to build new DN";
                send_ldap_result( op, rs );
                goto modrdn_return;
        }
index c5a9d10132e540f1e30170a9f85b28311b3c9a6f..8cd14269d8f86cb248279cf26f6a460a6237df68 100644 (file)
@@ -56,9 +56,8 @@ backsql_compare( Operation *op, SlapReply *rs )
        anlist[0].an_name = op->oq_compare.rs_ava->aa_desc->ad_cname;
        anlist[0].an_desc = op->oq_compare.rs_ava->aa_desc;
        anlist[1].an_name.bv_val = NULL;
-       backsql_init_search( &bsi, bi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
-                       -1, -1, -1, NULL, dbh, op->o_bd, op->o_conn, op,
-                       anlist);
+       backsql_init_search( &bsi, &op->o_req_ndn, LDAP_SCOPE_BASE, 
+                       -1, -1, -1, NULL, dbh, op, anlist);
        e = backsql_id2entry( &bsi, &user_entry, &user_id );
        if ( e == NULL ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_compare(): "
@@ -85,7 +84,9 @@ backsql_compare( Operation *op, SlapReply *rs )
                if ( value_find_ex( op->oq_compare.rs_ava->aa_desc,
                                        SLAP_MR_ATTRIBUTE_VALUE_NORMALIZED_MATCH |
                                        SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
-                                       a->a_nvals, &op->oq_compare.rs_ava->aa_value ) == 0 )
+                                       a->a_nvals,
+                                       &op->oq_compare.rs_ava->aa_value,
+                                       op->o_tmpmemctx ) == 0 )
                {
                        rs->sr_err = LDAP_COMPARE_TRUE;
                        break;
index eee527913fb17def6b7ecc1e377a1901dfbba01b..6a14ba7b0a025bdfdea25b981f808a44e8940377 100644 (file)
@@ -84,7 +84,6 @@ backsql_attrlist_add( backsql_srch_info *bsi, AttributeDescription *ad )
 void
 backsql_init_search(
        backsql_srch_info       *bsi, 
-       backsql_info            *bi,
        struct berval           *nbase, 
        int                     scope, 
        int                     slimit,
@@ -92,8 +91,6 @@ backsql_init_search(
        time_t                  stoptime, 
        Filter                  *filter, 
        SQLHDBC                 dbh,
-       BackendDB               *be, 
-       Connection              *conn, 
        Operation               *op,
        AttributeName           *attrs )
 {
@@ -105,8 +102,6 @@ backsql_init_search(
        bsi->tlimit = tlimit;
        bsi->filter = filter;
        bsi->dbh = dbh;
-       bsi->be = be;
-       bsi->conn = conn;
        bsi->op = op;
        bsi->bsi_flags = 0;
 
@@ -142,7 +137,6 @@ backsql_init_search(
        bsi->id_list = NULL;
        bsi->n_candidates = 0;
        bsi->stoptime = stoptime;
-       bsi->bi = bi;
        bsi->sel.bv_val = NULL;
        bsi->sel.bv_len = 0;
        bsi->sel_len = 0;
@@ -635,7 +629,7 @@ impossible:
 static int
 backsql_srch_query( backsql_srch_info *bsi, struct berval *query )
 {
-       backsql_info    *bi = (backsql_info *)bsi->be->be_private;
+       backsql_info    *bi = (backsql_info *)bsi->op->o_bd->be_private;
        ber_len_t       q_len = 0;
        int             rc;
 
@@ -1122,12 +1116,11 @@ backsql_search( Operation *op, SlapReply *rs )
        /* compute it anyway; root does not use it */
        stoptime = op->o_time + op->oq_search.rs_tlimit;
 
-       backsql_init_search( &srch_info, bi, &op->o_req_dn,
+       backsql_init_search( &srch_info, &op->o_req_dn,
                        op->oq_search.rs_scope,
                        op->oq_search.rs_slimit, op->oq_search.rs_tlimit,
                        stoptime, op->oq_search.rs_filter,
-                       dbh, op->o_bd, op->o_conn, op,
-                       op->oq_search.rs_attrs );
+                       dbh, op, op->oq_search.rs_attrs );
 
        /*
         * for each objectclass we try to construct query which gets IDs
index 488a15a41946da94ceae0f0c4ce0a155634448d2..126ca93b68beba33e153bb68480e76aa915ea93a 100644 (file)
@@ -234,7 +234,8 @@ int
 backsql_entry_addattr(
        Entry           *e,
        struct berval   *at_name,
-       struct berval   *at_val )
+       struct berval   *at_val,
+       void            *memctx )
 {
        AttributeDescription    *ad;
        int                     rc;
@@ -255,7 +256,7 @@ backsql_entry_addattr(
                return 0;
        }
 
-       rc = attr_mergeit_one( e, ad, at_val );
+       rc = attr_merge_normalize_one( e, ad, at_val, memctx );
 
        if ( rc != 0 ) {
                Debug( LDAP_DEBUG_TRACE, "backsql_entry_addattr(): "
index 06e38d5824b19db090b7f251c87e2b291609a3d7..37e94aa6f791b12d61b60f3d4ca55251c1276107 100644 (file)
@@ -21,7 +21,7 @@ struct berval * backsql_strfcat( struct berval *dest, ber_len_t *buflen,
                const char *fmt, ... );
 
 int backsql_entry_addattr( Entry *e, struct berval *at_name, 
-               struct berval *at_val );
+               struct berval *at_val, void *memctx );
 
 typedef struct backsql_srch_info {
        struct berval           *base_dn;
@@ -38,8 +38,6 @@ typedef struct backsql_srch_info {
        ber_len_t               sel_len, from_len, jwhere_len, fwhere_len;
        SQLHDBC                 dbh;
        int                     status;
-       Backend                 *be;
-       Connection              *conn;
        Operation               *op;
        AttributeName           *attrs;
        int                     bsi_flags;
@@ -50,11 +48,10 @@ typedef struct backsql_srch_info {
        int                     use_reverse_dn; 
 } backsql_srch_info;
 
-void backsql_init_search( backsql_srch_info *bsi, backsql_info *bi,
+void backsql_init_search( backsql_srch_info *bsi, 
                struct berval *nbase, int scope, int slimit, int tlimit,
                time_t stoptime, Filter *filter, SQLHDBC dbh,
-               BackendDB *be, Connection *conn, Operation *op,
-               AttributeName *attrs );
+               Operation *op, AttributeName *attrs );
 Entry *backsql_id2entry( backsql_srch_info *bsi, Entry *e, 
                backsql_entryID *id );