- Debug( LDAP_DEBUG_TRACE, "bdb2 backend saving nextid\n", 0, 0, 0 );
- if ( bdb2i_next_id_save( be ) < 0 ) {
- Debug( LDAP_DEBUG_ANY, "bdb2 backend nextid save failed!\n", 0, 0, 0 );
+ struct ldbminfo *li = (struct ldbminfo *) be->be_private;
+ DB_LOCK lock;
+
+ /* since close will probably write the NEXTID file,
+ wee need transaction control */
+ if ( bdb2i_enter_backend_w( &lock ) != 0 ) {
+ return( -1 );
+ }
+
+ if ( li->li_nextid != NOID ) {
+ Debug( LDAP_DEBUG_TRACE, "bdb2 backend saving nextid\n", 0, 0, 0 );
+ if ( bdb2i_next_id_save( be ) < 0 ) {
+ Debug( LDAP_DEBUG_ANY, "bdb2 backend nextid save failed!\n",
+ 0, 0, 0 );
+ }