return NULL;
}
+static int ldif_threaded;
+
static int
getrec(Erec *erec)
{
int rc;
- if ( slap_tool_thread_max < 2 )
+ if ( !ldif_threaded )
return getrec0(erec);
while (!trec.ready)
struct berval bvtext;
ldap_pvt_thread_t thr;
ID id;
+ Entry *prev = NULL;
int ldifrc;
int rc = EXIT_SUCCESS;
ldap_pvt_thread_mutex_init( &add_mutex );
ldap_pvt_thread_cond_init( &add_cond );
ldap_pvt_thread_create( &thr, 0, getrec_thr, NULL );
+ ldif_threaded = 1;
}
erec.nextline = 0;
"(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 )
erec.e->e_dn );
}
- entry_free( erec.e );
+ if ( prev ) entry_free( prev );
+ prev = erec.e;
}
- if ( slap_tool_thread_max > 1 ) {
+ if ( ldif_threaded ) {
ldap_pvt_thread_mutex_lock( &add_mutex );
add_stop = 1;
trec.ready = 0;
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;