*** include/db.h.orig Mon Aug 2 13:13:13 1999 --- include/db.h Mon Aug 2 13:15:57 1999 *************** *** 199,204 **** --- 199,205 ---- #define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */ #define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */ #define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */ + #define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */ /* * Deadlock detector modes; used in the DBENV structure to configure the *************** *** 405,410 **** --- 406,412 ---- /* Documented, returned information. */ DBTYPE type; /* DB access method. */ int byteswapped; /* Database byte order is swapped. */ + int saved_open_fd; /* For fcntl lock preservation. */ DB_ENV *dbenv; /* DB_ENV structure. */ DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */ *** build_win32/db.h.orig Tue Aug 31 13:40:16 1999 --- build_win32/db.h Tue Aug 31 13:40:26 1999 *************** *** 202,207 **** --- 202,208 ---- #define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */ #define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */ #define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */ + #define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */ /* * Deadlock detector modes; used in the DBENV structure to configure the *************** *** 408,413 **** --- 409,415 ---- /* Documented, returned information. */ DBTYPE type; /* DB access method. */ int byteswapped; /* Database byte order is swapped. */ + int saved_open_fd; /* For fcntl lock preservation. */ DB_ENV *dbenv; /* DB_ENV structure. */ DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */ *** build_vms/db.h.orig Tue Aug 31 13:41:09 1999 --- build_vms/db.h Tue Aug 31 13:41:18 1999 *************** *** 196,201 **** --- 196,202 ---- #define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */ #define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */ #define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */ + #define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */ /* * Deadlock detector modes; used in the DBENV structure to configure the *************** *** 402,407 **** --- 403,409 ---- /* Documented, returned information. */ DBTYPE type; /* DB access method. */ int byteswapped; /* Database byte order is swapped. */ + int saved_open_fd; /* For fcntl lock preservation. */ DB_ENV *dbenv; /* DB_ENV structure. */ DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */ *** build_win16/db.h.orig Tue Aug 31 13:41:58 1999 --- build_win16/db.h Tue Aug 31 13:42:03 1999 *************** *** 202,207 **** --- 202,208 ---- #define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */ #define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */ #define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */ + #define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */ /* * Deadlock detector modes; used in the DBENV structure to configure the *************** *** 408,413 **** --- 409,415 ---- /* Documented, returned information. */ DBTYPE type; /* DB access method. */ int byteswapped; /* Database byte order is swapped. */ + int saved_open_fd; /* For fcntl lock preservation. */ DB_ENV *dbenv; /* DB_ENV structure. */ DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */ *** db/db.c.orig Wed Aug 18 13:05:35 1999 --- db/db.c Wed Aug 18 13:18:01 1999 *************** *** 113,121 **** /* Validate arguments. */ #ifdef HAVE_SPINLOCKS ! #define OKFLAGS (DB_CREATE | DB_NOMMAP | DB_RDONLY | DB_THREAD | DB_TRUNCATE) #else ! #define OKFLAGS (DB_CREATE | DB_NOMMAP | DB_RDONLY | DB_TRUNCATE) #endif if ((ret = __db_fchk(dbenv, "db_open", flags, OKFLAGS)) != 0) return (ret); --- 113,121 ---- /* Validate arguments. */ #ifdef HAVE_SPINLOCKS ! #define OKFLAGS (DB_CREATE | DB_FCNTL_LOCKING | DB_NOMMAP | DB_RDONLY | DB_THREAD | DB_TRUNCATE) #else ! #define OKFLAGS (DB_CREATE | DB_FCNTL_LOCKING | DB_NOMMAP | DB_RDONLY | DB_TRUNCATE) #endif if ((ret = __db_fchk(dbenv, "db_open", flags, OKFLAGS)) != 0) return (ret); *************** *** 143,158 **** } } - /* Initialize for error return. */ - fd = -1; - need_fileid = 1; - real_name = NULL; - /* Allocate the DB structure, reference the DB_ENV structure. */ if ((ret = __os_calloc(1, sizeof(DB), &dbp)) != 0) return (ret); dbp->dbenv = dbenv; /* Random initialization. */ TAILQ_INIT(&dbp->free_queue); TAILQ_INIT(&dbp->active_queue); --- 143,158 ---- } } /* Allocate the DB structure, reference the DB_ENV structure. */ if ((ret = __os_calloc(1, sizeof(DB), &dbp)) != 0) return (ret); dbp->dbenv = dbenv; + /* Initialize for error return. */ + dbp->saved_open_fd = fd = -1; + need_fileid = 1; + real_name = NULL; + /* Random initialization. */ TAILQ_INIT(&dbp->free_queue); TAILQ_INIT(&dbp->active_queue); *************** *** 330,337 **** if ((ret = __os_read(fd, mbuf, sizeof(mbuf), &nr)) != 0) goto err; ! /* The fd is no longer needed. */ ! (void)__os_close(fd); fd = -1; if (nr != sizeof(mbuf)) { --- 330,339 ---- if ((ret = __os_read(fd, mbuf, sizeof(mbuf), &nr)) != 0) goto err; ! if (LF_ISSET(DB_FCNTL_LOCKING)) ! dbp->saved_open_fd = fd; ! else ! (void)__os_close(fd); fd = -1; if (nr != sizeof(mbuf)) { *************** *** 762,767 **** --- 764,774 ---- if (F_ISSET(dbp, DB_AM_MLOCAL) && (t_ret = memp_close(dbp->mp)) != 0 && ret == 0) ret = t_ret; + + if (dbp->saved_open_fd != -1) { + (void)__os_close(dbp->saved_open_fd); + dbp->saved_open_fd = -1; + } /* Discard the log file id. */ if (F_ISSET(dbp, DB_AM_LOGGING))