]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/add.c
Import Hallvards idl memory plugs from devel.
[openldap] / servers / slapd / add.c
index 60ae1cf93d8f98f04071b9ba98cd550e16ffea15..e128d81af74929c3a25e55e3c845a240a3edfc40 100644 (file)
@@ -45,10 +45,6 @@ do_add( Connection *conn, Operation *op )
         *      }
         */
 
-       e = (Entry *) ch_calloc( 1, sizeof(Entry) );
-       /* initialize reader/writer lock */
-       entry_rdwr_init(e);
-
        /* get the name */
        if ( ber_scanf( ber, "{a", &dn ) == LBER_ERROR ) {
                Debug( LDAP_DEBUG_ANY, "ber_scanf failed\n", 0, 0, 0 );
@@ -56,9 +52,16 @@ do_add( Connection *conn, Operation *op )
                    "decoding error" );
                return;
        }
+
+       e = (Entry *) ch_calloc( 1, sizeof(Entry) );
+       /* initialize reader/writer lock */
+       entry_rdwr_init(e);
+
        e->e_dn = dn;
-       dn = dn_normalize( ch_strdup( dn ) );
-       Debug( LDAP_DEBUG_ARGS, "    do_add: dn (%s)\n", dn, 0, 0 );
+       e->e_ndn = dn_normalize_case( ch_strdup( dn ) );
+       dn = NULL;
+
+       Debug( LDAP_DEBUG_ARGS, "    do_add: ndn (%s)\n", e->e_ndn, 0, 0 );
 
        /* get the attrs */
        e->e_attrs = NULL;
@@ -79,6 +82,7 @@ do_add( Connection *conn, Operation *op )
                            0, 0 );
                        send_ldap_result( conn, op, LDAP_PROTOCOL_ERROR, NULL,
                            NULL );
+                       free( type );
                        entry_free( e );
                        return;
                }
@@ -90,14 +94,15 @@ do_add( Connection *conn, Operation *op )
        }
 
        Statslog( LDAP_DEBUG_STATS, "conn=%d op=%d ADD dn=\"%s\"\n",
-           conn->c_connid, op->o_opid, dn, 0, 0 );
+           conn->c_connid, op->o_opid, e->e_ndn, 0, 0 );
 
        /*
         * We could be serving multiple database backends.  Select the
         * appropriate one, or send a referral to our "referral server"
         * if we don't hold it.
         */
-       if ( (be = select_backend( dn )) == NULL ) {
+       be = select_backend( e->e_ndn );
+       if ( be == NULL ) {
                entry_free( e );
                send_ldap_result( conn, op, LDAP_PARTIAL_RESULTS, NULL,
                    default_referral );
@@ -112,11 +117,11 @@ do_add( Connection *conn, Operation *op )
         */
        if ( be->be_add != NULL ) {
                /* do the update here */
-               if ( be->be_updatedn == NULL ||
-                       strcasecmp( be->be_updatedn, op->o_dn ) == 0 ) {
-
+               if ( be->be_update_ndn == NULL ||
+                       strcmp( be->be_update_ndn, op->o_ndn ) == 0 )
+               {
                        if ( (be->be_lastmod == ON || (be->be_lastmod == UNDEFINED &&
-                               global_lastmod == ON)) && be->be_updatedn == NULL ) {
+                               global_lastmod == ON)) && be->be_update_ndn == NULL ) {
 
                                add_created_attrs( op, e );
                        }
@@ -176,7 +181,7 @@ add_created_attrs( Operation *op, Entry *e )
        }
        attr_merge( e, "creatorsname", bvals );
 
-       pthread_mutex_lock( &currenttime_mutex );
+       ldap_pvt_thread_mutex_lock( &currenttime_mutex );
 #ifndef LDAP_LOCALTIME
        ltm = gmtime( &currenttime );
        strftime( buf, sizeof(buf), "%Y%m%d%H%M%SZ", ltm );
@@ -184,7 +189,7 @@ add_created_attrs( Operation *op, Entry *e )
        ltm = localtime( &currenttime );
        strftime( buf, sizeof(buf), "%y%m%d%H%M%SZ", ltm );
 #endif
-       pthread_mutex_unlock( &currenttime_mutex );
+       ldap_pvt_thread_mutex_unlock( &currenttime_mutex );
 
        bv.bv_val = buf;
        bv.bv_len = strlen( bv.bv_val );