]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/nextid.c
Removed unnecessary definition that is already in core.schema.
[openldap] / servers / slapd / back-ldbm / nextid.c
index 7c6f2264135a21400d9a07a3fb73c8d9ec3a91a0..34c7bfe5c92c6414ff7b52f7ae078c4066c50f07 100644 (file)
 #include "slap.h"
 #include "back-ldbm.h"
 
+static ID  next_id_read( Backend *be );
+static int next_id_write( Backend *be, ID id );
+static ID  next_id_get_save( Backend *be, int do_save );
+
+
 static ID
 next_id_read( Backend *be )
 {
@@ -22,6 +27,9 @@ next_id_read( Backend *be )
        char*   file = li->li_nextid_file; 
        FILE*   fp;
 
+       if ( ldbm_ignore_nextid_file )
+               return NOID;
+
        if ( (fp = fopen( file, "r" )) == NULL ) {
                Debug( LDAP_DEBUG_ANY,
                    "next_id_read: could not open \"%s\"\n",
@@ -58,6 +66,9 @@ next_id_write( Backend *be, ID id )
        FILE*   fp;
        int             rc;
 
+       if ( ldbm_ignore_nextid_file )
+               return 0;
+
        if ( (fp = fopen( file, "w" )) == NULL ) {
                Debug( LDAP_DEBUG_ANY, "next_id_write(%ld): could not open \"%s\"\n",
                    id, file, 0 );
@@ -84,15 +95,7 @@ next_id_write( Backend *be, ID id )
 int
 next_id_save( Backend *be )
 {
-       struct ldbminfo *li = (struct ldbminfo *) be->be_private;
-       ID id = next_id_get( be );
-       int rc = next_id_write( be, id );
-
-       if (rc == 0) {
-               li->li_nextid_wrote = id;
-       }
-
-       return rc;
+       return( next_id_get_save( be, 1 ) == NOID ? -1 : 0 );
 }
 
 ID
@@ -156,6 +159,12 @@ next_id_return( Backend *be, ID id )
 
 ID
 next_id_get( Backend *be )
+{
+       return next_id_get_save( be, 0 );
+}
+
+static ID
+next_id_get_save( Backend *be, int do_save )
 {
        struct ldbminfo *li = (struct ldbminfo *) be->be_private;
        ID              id;
@@ -177,6 +186,14 @@ next_id_get( Backend *be )
 
        id = li->li_nextid;
 
+       if ( do_save ) {
+               if ( next_id_write( be, id ) == 0 ) {
+                       li->li_nextid_wrote = id;
+               } else {
+                       id = NOID;
+               }
+       }
+
        ldap_pvt_thread_mutex_unlock( &li->li_nextid_mutex );
 
        return( id );