Browse Source

Resolves: bug 214851
Bug Description: integrating db43 into ds70
Reviewed by: nkinder (Thanks!)
Fix Description: I took the original diffs posted by Ulf and merged them in with our code which has changed slightly since the diffs were originally generated. I also put #if directives like the following:
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
... db43 features ...
#else
... db42 features ...
#endif
so that we can use both db42 and db43.
Platforms tested: RHEL4/FC5
Flag Day: no
Doc impact: no

Rich Megginson 19 years ago
parent
commit
b40456f952

+ 22 - 1
ldap/servers/plugins/replication/cl5_api.c

@@ -364,7 +364,11 @@ static int  _cl5UpdateRUV (Object *obj, CSN *csn, PRBool newReplica, PRBool purg
 static int  _cl5GetRUV2Purge2 (Object *fileObj, RUV **ruv);
 
 /* db error processing */
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+static void _cl5DBLogPrint(const DB_ENV *dbenv, const char* prefix, const char *buffer);
+#else /* assume 42 */
 static void _cl5DBLogPrint(const char* prefix, char *buffer);
+#endif
 
 /* bakup/recovery, import/export */
 static PRBool _cl5IsLogFile (const char *name);
@@ -384,7 +388,12 @@ static Object* _cl5GetReplica (const slapi_operation_parameters *op, const char*
 static int _cl5FileEndsWith(const char *filename, const char *ext);
 
 /* Callback function for libdb to spit error info into our log */
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+static void dblayer_log_print(const DB_ENV *dbenv, const char* prefix,
+                              const char *buffer)
+#else
 static void dblayer_log_print(const char* prefix, char *buffer)
+#endif
 {
 	/* We ignore the prefix since we know who we are anyway */
 	slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "libdb: %s\n", buffer);
@@ -3796,7 +3805,11 @@ static void _cl5InitDBEnv(DB_ENV *dbEnv)
 	if (s_cl5Desc.dbConfig.verbose)
 	{
 		int on = 1;
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+		/* DB_VERB_CHKPOINT removed in 43 */
+#else
 		dbEnv->set_verbose(dbEnv, DB_VERB_CHKPOINT, on);
+#endif
 		dbEnv->set_verbose(dbEnv, DB_VERB_DEADLOCK, on);
 		dbEnv->set_verbose(dbEnv, DB_VERB_RECOVERY, on);
 		dbEnv->set_verbose(dbEnv, DB_VERB_WAITSFOR, on);
@@ -3810,7 +3823,12 @@ static void _cl5InitDBEnv(DB_ENV *dbEnv)
 #endif
 }
 
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+static void _cl5DBLogPrint(const DB_ENV *dbenv, const char* prefix,
+                           const char *buffer)
+#else
 static void _cl5DBLogPrint(const char* prefix, char *buffer)
+#endif
 {
 	/* We ignore the prefix since we know who we are anyway */
 	slapi_log_error (SLAPI_LOG_FATAL, repl_plugin_name_cl, "cl5: %s\n", buffer);
@@ -4549,7 +4567,10 @@ static int _cl5GetEntryCount (CL5DBFile *file)
 							return CL5_SUCCESS;
 
 		case DB_NOTFOUND:	file->entryCount = 0;
-#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 3300
+
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+                            rc = file->db->stat(file->db, NULL, (void*)&stats, 0);
+#elif 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 3300
                             rc = file->db->stat(file->db, (void*)&stats, 0);
 #else
                             rc = file->db->stat(file->db, (void*)&stats, malloc, 0);

+ 4 - 0
ldap/servers/slapd/back-ldbm/dbhelp.c

@@ -225,7 +225,11 @@ void dblayer_set_env_debugging(DB_ENV *pEnv, dblayer_private *priv)
 {
 	pEnv->set_errpfx(pEnv, "ns-slapd");
     if (priv->dblayer_verbose) {
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+        /* DB_VERB_CHKPOINT removed in 43 */
+#else
         pEnv->set_verbose(pEnv, DB_VERB_CHKPOINT, 1);    /* 1 means on */
+#endif
         pEnv->set_verbose(pEnv, DB_VERB_DEADLOCK, 1);    /* 1 means on */
         pEnv->set_verbose(pEnv, DB_VERB_RECOVERY, 1);    /* 1 means on */
         pEnv->set_verbose(pEnv, DB_VERB_WAITSFOR, 1);    /* 1 means on */

+ 19 - 0
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -325,7 +325,12 @@ static void dblayer_reset_env(struct ldbminfo *li)
 }
 
 /* Callback function for libdb to spit error info into our log */
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+void dblayer_log_print(const DB_ENV *dbenv, const char* prefix,
+                       const char *buffer)
+#else
 void dblayer_log_print(const char* prefix, char *buffer)
+#endif
 {
     /* We ignore the prefix since we know who we are anyway */
     LDAPDebug(LDAP_DEBUG_ANY,"libdb: %s\n", buffer, 0, 0);    
@@ -400,6 +405,16 @@ static int dblayer_seek24_large(int fd, size_t pgsize, db_pgno_t pageno,
     return (ret < 0) ? errno : 0;
 }
 
+/* Helper function for large seeks, db4.3 */
+static int dblayer_seek43_large(int fd, off64_t offset, int whence)
+{
+    int ret = 0;
+
+    ret = lseek64(fd, offset, whence);
+
+    return (ret < 0) ? errno : 0;
+}
+
 /* helper function for large fstat -- this depends on 'struct stat64' having
  * the following members:
  *    off64_t        st_size;
@@ -464,7 +479,11 @@ static int dblayer_override_libdb_functions(DB_ENV *pEnv, dblayer_private *priv)
 #endif  /* !irix */
     db_env_set_func_ioinfo(dblayer_ioinfo_large);
     db_env_set_func_exists((int (*)())dblayer_exists_large);
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+    db_env_set_func_seek((int (*)())dblayer_seek43_large);
+#else
     db_env_set_func_seek((int (*)())dblayer_seek24_large);
+#endif
 
     LDAPDebug(LDAP_DEBUG_TRACE, "Enabled 64-bit files\n", 0, 0, 0);
 #endif   /* DB_USE_64LFS */

+ 5 - 0
ldap/servers/slapd/back-ldbm/dblayer.h

@@ -170,7 +170,12 @@ struct dblayer_private
     int dblayer_lock_config;
 };
 
+#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR >= 4300
+void dblayer_log_print(const DB_ENV *dbenv, const char* prefix,
+                       const char *buffer);
+#else
 void dblayer_log_print(const char* prefix, char *buffer);
+#endif
 
 int dblayer_db_remove(dblayer_private_env * env, char const path[], char const dbName[]);