|
|
c7d609 |
diff -up db-5.3.28/src/dbinc_auto/int_def.in.pthreads_ppc db-5.3.28/src/dbinc_auto/int_def.in
|
|
|
c7d609 |
--- db-5.3.28/src/dbinc_auto/int_def.in.pthreads_ppc 2017-06-26 15:06:09.282020804 +0200
|
|
|
c7d609 |
+++ db-5.3.28/src/dbinc_auto/int_def.in 2017-06-26 15:06:22.238771039 +0200
|
|
|
c7d609 |
@@ -1572,6 +1572,7 @@
|
|
|
c7d609 |
#define __os_strerror __os_strerror@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
#define __os_posix_err __os_posix_err@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
#define __os_fileid __os_fileid@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
+#define __check_lock_fn __check_lock_fn@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
#define __os_fdlock __os_fdlock@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
#define __os_fsync __os_fsync@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
#define __os_getenv __os_getenv@DB_VERSION_UNIQUE_NAME@
|
|
|
c7d609 |
diff -up db-5.3.28/src/dbinc_auto/os_ext.h.pthreads_ppc db-5.3.28/src/dbinc_auto/os_ext.h
|
|
|
c7d609 |
--- db-5.3.28/src/dbinc_auto/os_ext.h.pthreads_ppc 2017-06-26 15:05:23.792897700 +0200
|
|
|
c7d609 |
+++ db-5.3.28/src/dbinc_auto/os_ext.h 2017-06-26 15:06:22.172772311 +0200
|
|
|
c7d609 |
@@ -41,6 +41,7 @@ void __os_set_errno __P((int));
|
|
|
c7d609 |
char *__os_strerror __P((int, char *, size_t));
|
|
|
c7d609 |
int __os_posix_err __P((int));
|
|
|
c7d609 |
int __os_fileid __P((ENV *, const char *, int, u_int8_t *));
|
|
|
c7d609 |
+int __check_lock_fn __P((char *, pid_t));
|
|
|
c7d609 |
int __os_fdlock __P((ENV *, DB_FH *, off_t, db_lockmode_t, int));
|
|
|
c7d609 |
int __os_fsync __P((ENV *, DB_FH *));
|
|
|
c7d609 |
int __os_getenv __P((ENV *, const char *, char **, size_t));
|
|
|
c7d609 |
diff -up db-5.3.28/src/env/env_region.c.pthreads_ppc db-5.3.28/src/env/env_region.c
|
|
|
c7d609 |
--- db-5.3.28/src/env/env_region.c.pthreads_ppc 2017-06-26 15:04:40.805726365 +0200
|
|
|
c7d609 |
+++ db-5.3.28/src/env/env_region.c 2017-06-26 15:04:40.807726326 +0200
|
|
|
c7d609 |
@@ -305,14 +305,6 @@ user_map_functions:
|
|
|
c7d609 |
goto creation;
|
|
|
c7d609 |
}
|
|
|
c7d609 |
|
|
|
c7d609 |
- /* We have an old environment but cannot rebuild it safely. */
|
|
|
c7d609 |
- if (ret == DB_OLD_VERSION) {
|
|
|
c7d609 |
- __db_errx(env, DB_STR("1539",
|
|
|
c7d609 |
- "Build signature doesn't match environment"));
|
|
|
c7d609 |
- ret = DB_VERSION_MISMATCH;
|
|
|
c7d609 |
- goto err;
|
|
|
c7d609 |
- }
|
|
|
c7d609 |
-
|
|
|
c7d609 |
if (renv->majver != DB_VERSION_MAJOR ||
|
|
|
c7d609 |
renv->minver != DB_VERSION_MINOR) {
|
|
|
c7d609 |
/*
|
|
|
c7d609 |
@@ -337,6 +329,20 @@ user_map_functions:
|
|
|
c7d609 |
goto err;
|
|
|
c7d609 |
}
|
|
|
c7d609 |
|
|
|
c7d609 |
+ /*
|
|
|
c7d609 |
+ * We have an old environment but cannot rebuild it safely.
|
|
|
c7d609 |
+ * The environment might still be readable by the current process
|
|
|
c7d609 |
+ * (only the libpthread timestamp changed) if this process is the one
|
|
|
c7d609 |
+ * that is holding the lock on the region file as we can be sure
|
|
|
c7d609 |
+ * the environment did not get rebuilt under our feet.
|
|
|
c7d609 |
+ */
|
|
|
c7d609 |
+ if (ret == DB_OLD_VERSION && __check_lock_fn(env->lockfhp->name, getpid()) ) {
|
|
|
c7d609 |
+ __db_errx(env, DB_STR("1539",
|
|
|
c7d609 |
+ "Build signature doesn't match environment"));
|
|
|
c7d609 |
+ ret = DB_VERSION_MISMATCH;
|
|
|
c7d609 |
+ goto err;
|
|
|
c7d609 |
+ }
|
|
|
c7d609 |
+
|
|
|
c7d609 |
/*
|
|
|
c7d609 |
* Check if the environment has had a catastrophic failure.
|
|
|
c7d609 |
*
|
|
|
c7d609 |
diff -up db-5.3.28/src/os/os_flock.c.pthreads_ppc db-5.3.28/src/os/os_flock.c
|
|
|
c7d609 |
--- db-5.3.28/src/os/os_flock.c.pthreads_ppc 2017-06-26 15:04:40.806726346 +0200
|
|
|
c7d609 |
+++ db-5.3.28/src/os/os_flock.c 2017-06-26 15:04:40.807726326 +0200
|
|
|
c7d609 |
@@ -15,6 +15,70 @@ static int __os_filelocking_notsup __P((
|
|
|
c7d609 |
#endif
|
|
|
c7d609 |
|
|
|
c7d609 |
/*
|
|
|
c7d609 |
+ * __check_lock_fn --
|
|
|
c7d609 |
+ * Parse /proc/locks to see if the file described by 'fn' is locked.
|
|
|
c7d609 |
+ * Additionally (if 'pid' is not 0) check if the process holding
|
|
|
c7d609 |
+ * the lock has the same pid value as 'pid'.
|
|
|
c7d609 |
+ *
|
|
|
c7d609 |
+ * Returns 0 if a lock on fn is found, 1 if it is not found and -1 on error.
|
|
|
c7d609 |
+ * PUBLIC: int __check_lock_fn __P((char *, pid_t));
|
|
|
c7d609 |
+ */
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+int __check_lock_fn(fn, pid)
|
|
|
c7d609 |
+ char *fn;
|
|
|
c7d609 |
+ pid_t pid;
|
|
|
c7d609 |
+{
|
|
|
c7d609 |
+ FILE* fp;
|
|
|
c7d609 |
+ char buffer[PATH_MAX];
|
|
|
c7d609 |
+ char *token;
|
|
|
c7d609 |
+ int i, inode;
|
|
|
c7d609 |
+ struct stat st;
|
|
|
c7d609 |
+ pid_t lpid = 0;
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+ if (!fn)
|
|
|
c7d609 |
+ return -1;
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+ fp = fopen("/proc/locks", "r");
|
|
|
c7d609 |
+ if (!fp)
|
|
|
c7d609 |
+ return -1;
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+ /* Get the file's inode */
|
|
|
c7d609 |
+ if (stat(fn, &st)) {
|
|
|
c7d609 |
+ fclose(fp);
|
|
|
c7d609 |
+ return -1;
|
|
|
c7d609 |
+ }
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+ while (fgets(buffer, sizeof(buffer), fp))
|
|
|
c7d609 |
+ for (token = strtok(buffer, " "), i = 0; token; token = strtok(NULL, " "), i++) {
|
|
|
c7d609 |
+ /* Do not parse any other fields */
|
|
|
c7d609 |
+ if (i > 5)
|
|
|
c7d609 |
+ break;
|
|
|
c7d609 |
+ /* Save the PID */
|
|
|
c7d609 |
+ if (i == 4)
|
|
|
c7d609 |
+ lpid = atoi(token);
|
|
|
c7d609 |
+ /* Check the inode */
|
|
|
c7d609 |
+ else if (i == 5) {
|
|
|
c7d609 |
+ inode = 0;
|
|
|
c7d609 |
+ sscanf(token, "%*02x:%*02x:%d", &inode;;
|
|
|
c7d609 |
+ /* Not the inode we are looking for */
|
|
|
c7d609 |
+ if (inode != st.st_ino)
|
|
|
c7d609 |
+ continue;
|
|
|
c7d609 |
+ /*
|
|
|
c7d609 |
+ * We have the correct file.
|
|
|
c7d609 |
+ * We are either looking for a specific process or we do not care at all.
|
|
|
c7d609 |
+ */
|
|
|
c7d609 |
+ if (!pid || lpid == pid) {
|
|
|
c7d609 |
+ fclose(fp);
|
|
|
c7d609 |
+ return 0;
|
|
|
c7d609 |
+ }
|
|
|
c7d609 |
+ /* Not the lock we are looking for */
|
|
|
c7d609 |
+ }
|
|
|
c7d609 |
+ }
|
|
|
c7d609 |
+ fclose(fp);
|
|
|
c7d609 |
+ return 1;
|
|
|
c7d609 |
+}
|
|
|
c7d609 |
+
|
|
|
c7d609 |
+/*
|
|
|
c7d609 |
* __os_fdlock --
|
|
|
c7d609 |
* Acquire/release a lock on a byte in a file.
|
|
|
c7d609 |
*
|