diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-04-05 12:54:20 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2016-04-05 12:54:20 +1000 |
commit | 466d74b84e7f347ee98074d8457b94420a8c5e95 (patch) | |
tree | 0ba890fd133ec55c173aec2d428a6552ddedc6dc | |
parent | 7a5fce2b618d51e0bb42a12b0a2e44a3632d3d10 (diff) | |
parent | c31217f30fafde000239a93adcfe960546f13943 (diff) | |
download | mongo-466d74b84e7f347ee98074d8457b94420a8c5e95.tar.gz |
Merge pull request #2633 from wiredtiger/wt-2533
WT-2533 Don't let in-memory tables return a zero size.
-rw-r--r-- | src/os_common/os_fs_inmemory.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/os_common/os_fs_inmemory.c b/src/os_common/os_fs_inmemory.c index 218deb15d29..260514eac66 100644 --- a/src/os_common/os_fs_inmemory.c +++ b/src/os_common/os_fs_inmemory.c @@ -8,6 +8,8 @@ #include "wt_internal.h" +static int __im_handle_size(WT_SESSION_IMPL *, WT_FH *, wt_off_t *); + /* * In-memory information. */ @@ -151,12 +153,12 @@ __im_file_size( __wt_spin_lock(session, &im->lock); if (__wt_handle_search(session, name, true, NULL, &fh)) { - *sizep = (wt_off_t)fh->buf.size; - ret = __wt_close(session, &fh); + WT_ERR(__im_handle_size(session, fh, sizep)); + WT_ERR(__wt_close(session, &fh)); } else ret = ENOENT; - __wt_spin_unlock(session, &im->lock); +err: __wt_spin_unlock(session, &im->lock); return (ret); } @@ -308,7 +310,12 @@ __im_handle_size(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep) { WT_UNUSED(session); - *sizep = (wt_off_t)fh->buf.size; + /* + * XXX hack - MongoDB assumes that any file with content will have a + * non-zero size. In memory tables generally are zero-sized, make + * MongoDB happy. + */ + *sizep = fh->buf.size == 0 ? 1024 : (wt_off_t)fh->buf.size; return (0); } |