1 /* id.c - keep track of the next id to be given out */
9 #ifdef HAVE_SYS_PARAM_H
10 #include <sys/param.h>
14 #include "back-bdb2.h"
16 /* reading and writing NEXTID is handled in txn.c */
17 #define next_id_read(be) bdb2i_get_nextid( (be) )
18 #define next_id_write(be,id) bdb2i_put_nextid( (be), (id) )
22 bdb2i_next_id_save( BackendDB *be )
24 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
25 ID id = bdb2i_next_id_get( be );
28 rc = next_id_write( be, id );
30 li->li_nextid_wrote = id;
37 bdb2i_next_id( BackendDB *be )
39 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
42 /* first time in here since startup - try to read the nexid */
43 if ( li->li_nextid == NOID ) {
44 li->li_nextid = next_id_read( be );
46 if ( li->li_nextid == NOID ) {
50 #if SLAPD_NEXTID_CHUNK > 1
51 li->li_nextid_wrote = li->li_nextid;
57 #if SLAPD_NEXTID_CHUNK > 1
58 if ( li->li_nextid > li->li_nextid_wrote ) {
59 li->li_nextid_wrote += SLAPD_NEXTID_CHUNK;
60 (void) next_id_write( be, li->li_nextid_wrote );
63 (void) next_id_write( be, li->li_nextid );
70 bdb2i_next_id_return( BackendDB *be, ID id )
72 #ifdef SLAPD_NEXTID_RETURN
73 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
75 if ( id != li->li_nextid - 1 ) {
81 #if !( SLAPD_NEXTID_CHUNK > 1 )
82 (void) next_id_write( be, li->li_nextid );
88 bdb2i_next_id_get( BackendDB *be )
90 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
93 /* first time in here since startup - try to read the nexid */
94 if ( li->li_nextid == NOID ) {
95 li->li_nextid = next_id_read( be );
97 if ( li->li_nextid == NOID ) {
101 #if SLAPD_NEXTID_CHUNK > 1
102 li->li_nextid_wrote = li->li_nextid;