]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldap/add.c
fix memory handling
[openldap] / servers / slapd / back-ldap / add.c
index eb272c76628fa067c9f8f489fc96d056725be588..c15fdd0e9f4bcf187774980bfb3a17c19c0b32af 100644 (file)
@@ -36,7 +36,9 @@ ldap_back_add(
        Operation       *op,
        SlapReply       *rs )
 {
-       struct ldapconn *lc;
+       ldapinfo_t      *li = (ldapinfo_t *)op->o_bd->be_private;
+
+       ldapconn_t      *lc;
        int             i = 0,
                        j = 0;
        Attribute       *a;
@@ -54,6 +56,7 @@ ldap_back_add(
 
        lc = ldap_back_getconn( op, rs, LDAP_BACK_SENDERR );
        if ( !lc || !ldap_back_dobind( lc, op, rs, LDAP_BACK_SENDERR ) ) {
+               lc = NULL;
                goto cleanup;
        }
 
@@ -68,7 +71,8 @@ ldap_back_add(
 
        isupdate = be_shadow_update( op );
        for ( i = 0, a = op->oq_add.rs_e->e_attrs; a; a = a->a_next ) {
-               if ( !isupdate && a->a_desc->ad_type->sat_no_user_mod  ) {
+               if ( !isupdate && !get_manageDIT( op ) && a->a_desc->ad_type->sat_no_user_mod  )
+               {
                        continue;
                }
 
@@ -98,10 +102,11 @@ ldap_back_add(
 retry:
        rs->sr_err = ldap_add_ext( lc->lc_ld, op->o_req_dn.bv_val, attrs,
                        ctrls, NULL, &msgid );
-       rs->sr_err = ldap_back_op_result( lc, op, rs, msgid, LDAP_BACK_SENDRESULT );
+       rs->sr_err = ldap_back_op_result( lc, op, rs, msgid,
+               li->li_timeout[ LDAP_BACK_OP_ADD ], LDAP_BACK_SENDRESULT );
        if ( rs->sr_err == LDAP_UNAVAILABLE && do_retry ) {
                do_retry = 0;
-               if ( ldap_back_retry( lc, op, rs, LDAP_BACK_SENDERR ) ) {
+               if ( ldap_back_retry( &lc, op, rs, LDAP_BACK_SENDERR ) ) {
                        goto retry;
                }
        }
@@ -116,6 +121,10 @@ cleanup:
                ch_free( attrs );
        }
 
+       if ( lc ) {
+               ldap_back_release_conn( op, rs, lc );
+       }
+
        Debug( LDAP_DEBUG_ARGS, "<== ldap_back_add(\"%s\"): %d\n",
                        op->o_req_dn.bv_val, rs->sr_err, 0 );