1 /* porter.c - port functions of the bdb2 backend */
11 #include "back-bdb2.h"
13 #define PORTER_OBJ "bdb2_backend"
17 bdb2i_enter_backend( DB_ENV *dbEnv, DB_LOCK *lock, int writer )
20 db_lockmode_t lock_type;
24 if ( ( slapMode != SLAP_SERVER_MODE ) && ( slapMode != SLAP_TOOL_MODE ) )
27 if ( ( ret = lock_id( dbEnv->lk_info, &locker )) != 0 ) {
29 Debug( LDAP_DEBUG_ANY,
30 "bdb2i_enter_backend(): unable to get locker id -- %s\n",
31 strerror( ret ), 0, 0 );
36 lock_type = writer ? DB_LOCK_WRITE : DB_LOCK_READ;
37 lock_dbt.data = PORTER_OBJ;
38 lock_dbt.size = strlen( PORTER_OBJ );
40 switch ( ( ret = lock_get( dbEnv->lk_info, locker, 0, &lock_dbt,
44 Debug( LDAP_DEBUG_TRACE, "bdb2i_enter_backend() -- %s lock granted\n",
45 writer ? "write" : "read", 0, 0 );
48 case DB_LOCK_NOTGRANTED:
49 Debug( LDAP_DEBUG_ANY,
50 "bdb2i_enter_backend() -- %s lock NOT granted\n",
51 writer ? "write" : "read", 0, 0 );
54 case DB_LOCK_DEADLOCK:
55 Debug( LDAP_DEBUG_ANY,
56 "bdb2i_enter_backend() -- %s lock returned DEADLOCK\n",
57 writer ? "write" : "read", 0, 0 );
61 Debug( LDAP_DEBUG_ANY,
62 "bdb2i_enter_backend() -- %s lock returned ERROR: %s\n",
63 writer ? "write" : "read", strerror( errno ), 0 );
74 bdb2i_enter_backend_r( DB_ENV *dbEnv, DB_LOCK *lock )
76 return( bdb2i_enter_backend( dbEnv, lock, 0 ));
81 bdb2i_enter_backend_w( DB_ENV *dbEnv, DB_LOCK *lock )
83 return( bdb2i_enter_backend( dbEnv, lock, 1 ));
88 bdb2i_leave_backend( DB_ENV *dbEnv, DB_LOCK lock )
92 if ( ( slapMode != SLAP_SERVER_MODE ) && ( slapMode != SLAP_TOOL_MODE ) )
95 switch( ( ret = lock_put( dbEnv->lk_info, lock ))) {
98 Debug( LDAP_DEBUG_TRACE, "bdb2i_leave_backend() -- lock released\n",
102 case DB_LOCK_NOTHELD:
103 Debug( LDAP_DEBUG_ANY,
104 "bdb2i_leave_backend() -- lock NOT held\n",
108 case DB_LOCK_DEADLOCK:
109 Debug( LDAP_DEBUG_ANY,
110 "bdb2i_leave_backend() -- lock returned DEADLOCK\n",
115 Debug( LDAP_DEBUG_ANY,
116 "bdb2i_leave_backend() -- lock returned ERROR: %s\n",
117 strerror( errno ), 0, 0 );