diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-03-25 08:19:12 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2016-03-25 08:19:12 +1100 |
commit | 43e885a0f9a3ad046eae1726b005ca1280624be3 (patch) | |
tree | f03d31a7b36c476484f26ea5259777aeb7b13201 /src/os_posix/os_open.c | |
parent | 5cdd3e320cb19cd54111c2572a3d6e33d3009ad4 (diff) | |
parent | 9cf8eb2f15c6df7da90c19c86ccf7516ed126183 (diff) | |
download | mongodb-3.2.5.tar.gz |
Merge branch 'mongodb-3.4' into mongodb-3.2mongodb-3.2.5
Diffstat (limited to 'src/os_posix/os_open.c')
-rw-r--r-- | src/os_posix/os_open.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/os_posix/os_open.c b/src/os_posix/os_open.c index b085676c53b..219b26c2fa1 100644 --- a/src/os_posix/os_open.c +++ b/src/os_posix/os_open.c @@ -73,7 +73,16 @@ __wt_open(WT_SESSION_IMPL *session, goto setupfh; } - f = O_RDWR; + /* + * If this is a read-only connection, open all files read-only + * except the lock file. + */ + if (F_ISSET(conn, WT_CONN_READONLY) && + !WT_STRING_MATCH(name, WT_SINGLETHREAD, + strlen(WT_SINGLETHREAD))) + f = O_RDONLY; + else + f = O_RDWR; #ifdef O_BINARY /* Windows clones: we always want to treat the file as a binary. */ f |= O_BINARY; @@ -94,6 +103,9 @@ __wt_open(WT_SESSION_IMPL *session, #endif if (ok_create) { + WT_ASSERT(session, !F_ISSET(conn, WT_CONN_READONLY) || + WT_STRING_MATCH(name, WT_SINGLETHREAD, + strlen(WT_SINGLETHREAD))); f |= O_CREAT; if (exclusive) f |= O_EXCL; |