From aa8e5cdde7817b615dabab41fad79316f470fb3f Mon Sep 17 00:00:00 2001 From: Marcus Boerger Date: Mon, 30 Dec 2002 17:42:55 +0000 Subject: [PATCH] -disallow using db- with libraries of different major versions -disallow using db-4.1 with patch level < 25 -fix db-4.1 -added undocumented DB_FCNTL_LOCKING flag for version 3 and 4 # wow the sleepycat guys answered *very* fast --- ext/dba/config.m4 | 21 ++++++++++++++++++--- ext/dba/dba_db3.c | 11 +++++------ ext/dba/dba_db4.c | 4 ++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/ext/dba/config.m4 b/ext/dba/config.m4 index b3952e6eba..f39e3c9d6e 100644 --- a/ext/dba/config.m4 +++ b/ext/dba/config.m4 @@ -144,7 +144,7 @@ AC_DEFUN(PHP_DBA_DB_CHECK,[ AC_TRY_RUN([ #include "$THIS_INCLUDE" int main() { - return DB_VERSION_MAJOR >= $1 ? 0 : 1; + return (DB_VERSION_MAJOR == $1) ? 0 : 1; } ],[ THIS_LIBS=$LIB @@ -156,6 +156,21 @@ int main() { ]) ]) done + if test "$1" = "4"; then + AC_MSG_CHECKING(for db4 minor version and patch level) + AC_TRY_RUN([ +#include "$THIS_INCLUDE" +int main() { + return (DB_VERSION_MINOR != 1 || DB_VERSION_PATCH >= 25) ? 0 : 1; +} + ],[ + AC_MSG_RESULT(ok) + ],[ + AC_MSG_ERROR(Version 4.1 requires patch level 25) + ],[ + AC_MSG_RESULT(crosscompiling) + ]) + fi if test -n "$THIS_LIBS"; then AC_DEFINE(DBA_DB$1, 1, [ ]) if test -n "$THIS_INCLUDE"; then @@ -194,7 +209,7 @@ AC_ARG_WITH(db4, break fi done - PHP_DBA_DB_CHECK(4, db-4.1 db-4 db4 db, db_create) + PHP_DBA_DB_CHECK(4, db-4.1 db-4.0 db-4 db4 db, db_create) fi ]) AC_DBA_STD_RESULT(db4,Berkeley DB4) @@ -229,7 +244,7 @@ AC_ARG_WITH(db3, break fi done - PHP_DBA_DB_CHECK(3, db-3.3 db-3.2 db-3.1 db-3 db3 db, db_create) + PHP_DBA_DB_CHECK(3, db-3.3 db-3.2 db-3.1 db-3.0 db-3 db3 db, db_create) fi ]) AC_DBA_STD_RESULT(db3,Berkeley DB3) diff --git a/ext/dba/dba_db3.c b/ext/dba/dba_db3.c index 97cd4ef390..cb3f3567b5 100644 --- a/ext/dba/dba_db3.c +++ b/ext/dba/dba_db3.c @@ -81,14 +81,13 @@ DBA_OPEN_FUNC(db3) filemode = Z_LVAL_PP(info->argv[0]); } +#ifdef DB_FCNTL_LOCKING + gmode |= DB_FCNTL_LOCKING; +#endif + if ((err=db_create(&dbp, NULL, 0)) == 0) { dbp->set_errcall(dbp, php_dba_db3_errcall_fcn); - if ( -#if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1) - (err=dbp->open(dbp, 0, info->path, NULL, type, gmode, filemode)) == 0) { -#else - (err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) { -#endif + if ((err=dbp->open(dbp, info->path, NULL, type, gmode, filemode)) == 0) { dba_db3_data *data; data = pemalloc(sizeof(*data), info->flags&DBA_PERSISTENT); diff --git a/ext/dba/dba_db4.c b/ext/dba/dba_db4.c index cab8961764..de3eb3441d 100644 --- a/ext/dba/dba_db4.c +++ b/ext/dba/dba_db4.c @@ -81,6 +81,10 @@ DBA_OPEN_FUNC(db4) filemode = Z_LVAL_PP(info->argv[0]); } +#ifdef DB_FCNTL_LOCKING + gmode |= DB_FCNTL_LOCKING; +#endif + if ((err=db_create(&dbp, NULL, 0)) == 0) { dbp->set_errcall(dbp, php_dba_db4_errcall_fcn); if ( -- 2.40.0