]> git.sur5r.net Git - openldap/commitdiff
Support double-buffering for threaded slapadd
authorHoward Chu <hyc@openldap.org>
Sat, 14 Apr 2012 14:54:26 +0000 (07:54 -0700)
committerQuanah Gibson-Mount <quanah@openldap.org>
Thu, 26 Jul 2012 21:27:45 +0000 (14:27 -0700)
servers/slapd/slapadd.c

index 034e9414040f9660bf14c6b33e5817e09cddb59f..58041d3026fea10c2b7d4665a42263a12a174253 100644 (file)
@@ -333,6 +333,7 @@ slapadd( int argc, char **argv )
        struct berval bvtext;
        ldap_pvt_thread_t thr;
        ID id;
+       Entry *prev = NULL;
 
        int ldifrc;
        int rc = EXIT_SUCCESS;
@@ -434,8 +435,11 @@ slapadd( int argc, char **argv )
                                                                 "(line=%d): %s\n", progname, erec.e->e_dn,
                                                                 erec.lineno, bvtext.bv_val );
                                rc = EXIT_FAILURE;
-                               entry_free( erec.e );
-                               if( continuemode ) continue;
+                               if( continuemode ) {
+                                       if ( prev ) entry_free( prev );
+                                       prev = erec.e;
+                                       continue;
+                               }
                                break;
                        }
                        if ( verbose )
@@ -447,7 +451,8 @@ slapadd( int argc, char **argv )
                                        erec.e->e_dn );
                }
 
-               entry_free( erec.e );
+               if ( prev ) entry_free( prev );
+               prev = erec.e;
        }
 
        if ( ldif_threaded ) {
@@ -458,6 +463,7 @@ slapadd( int argc, char **argv )
                ldap_pvt_thread_mutex_unlock( &add_mutex );
                ldap_pvt_thread_join( thr, NULL );
        }
+       if ( erec.e ) entry_free( erec.e );
 
        if ( ldifrc < 0 )
                rc = EXIT_FAILURE;