1 /* ldbmcache.c - maintain a cache of open bdb2 files */
14 #ifdef HAVE_SYS_PARAM_H
15 #include <sys/param.h>
18 #include "ldapconfig.h"
20 #include "back-bdb2.h"
30 /* all files are open, so return handle from file cache */
31 if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) ) {
32 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
36 sprintf( buf, "%s%s", name, suffix );
37 return( bdb2i_get_db_file_cache( li, buf ));
41 /* if not SERVER or TOOL, who else would ask?
42 NO ONE, so return error */
44 Debug( LDAP_DEBUG_ANY,
45 "bdb2i_cache_open: database user (%d) unknown -- cannot open \"%s%s\".\n",
46 slapMode, name, suffix );
52 bdb2i_cache_close( BackendDB *be, struct dbcache *db )
54 /* all files stay open until SERVER or TOOL shut down */
55 if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
58 /* if unknown user, complain */
59 Debug( LDAP_DEBUG_ANY,
60 "bdb2i_cache_close: database user (%d) unknown -- ignored.\n",
67 bdb2i_cache_really_close( BackendDB *be, struct dbcache *db )
69 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
71 /* all files stay open until SERVER or TOOL shut down */
72 if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
75 /* if unknown user, complain */
76 Debug( LDAP_DEBUG_ANY,
77 "bdb2i_cache_really_close: database user (%d) unknown -- ignored.\n",
84 bdb2i_cache_flush_all( BackendDB *be )
86 struct ldbminfo *li = (struct ldbminfo *) be->be_private;
89 /* if SERVER or TOOL, syncing is done by TP, or during shutdown */
90 if ( ( slapMode == SLAP_SERVER_MODE ) || ( slapMode == SLAP_TOOL_MODE ) )
93 /* if unknown user, complain */
94 Debug( LDAP_DEBUG_ANY,
95 "bdb2i_cache_really_close: database user (%d) unknown -- ignored.\n",
109 ldbm_datum_init( data );
111 data = ldbm_fetch( db->dbc_db, key );
127 Statslog( LDAP_DEBUG_STATS,
128 "=> bdb2i_cache_store(): key.dptr=%s, key.dsize=%d\n",
129 key.dptr, key.dsize, 0, 0, 0 );
131 Statslog( LDAP_DEBUG_STATS,
132 "=> bdb2i_cache_store(): key.dptr=0x%08x, data.dptr=0x%0 8x\n",
133 key.dptr, data.dptr, 0, 0, 0 );
135 Statslog( LDAP_DEBUG_STATS,
136 "=> bdb2i_cache_store(): data.dptr=%s, data.dsize=%d\n",
137 data.dptr, data.dsize, 0, 0, 0 );
139 Statslog( LDAP_DEBUG_STATS,
140 "=> bdb2i_cache_store(): flags=0x%08x\n",
142 #endif /* LDBM_DEBUG */
144 rc = ldbm_store( db->dbc_db, key, data, flags );
157 rc = ldbm_delete( db->dbc_db, key );