diff options
author | c-blake <c-blake@users.noreply.github.com> | 2017-03-12 15:45:10 -0400 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-12 20:45:10 +0100 |
commit | d59441340dcc3b131c984def530084da93796775 (patch) | |
tree | 3ea6345957b615bd20443966f5b374834fd97632 /web | |
parent | 9fda97b05840a373f1e49417e7f50fa1328d7b06 (diff) | |
download | Nim-d59441340dcc3b131c984def530084da93796775.tar.gz |
Fixes incorrect fd==0 test on Unix; Conserves handles by default. (#5512)
* Fix 2 problems. First, 0 is a valid fd on Unix (easily gotten if user first closes all fds and then starts using memfiles). Use -1 instead for an invalid fd. Second, it is best practice to conserve open fds on Unix and file handles on Windows. These handles are not needed unless the user wants to remap the memory with ``mapMem`` (or a hypothetical future ``proc resize``). Adding a new bool param ``allowRemap=false`` to ``memfiles.open`` solves this cleanly in a "mostly" backward compatible way. This is only "mostly" because the default ``false`` case does not keep unneeded resources allocated, but that most sensible default means that any ``mapMem`` callers need to fix all their open calls to have allowRemap=true, as this PR also does for tmemfiles2.nim. * Include backwards compatibility note.
Diffstat (limited to 'web')
-rw-r--r-- | web/news/e031_version_0_16_2.rst | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/web/news/e031_version_0_16_2.rst b/web/news/e031_version_0_16_2.rst index 3f111b503..802478090 100644 --- a/web/news/e031_version_0_16_2.rst +++ b/web/news/e031_version_0_16_2.rst @@ -23,6 +23,9 @@ Changes affecting backwards compatibility pointer. Now the hash is calculated from the contents of the string, assuming ``cstring`` is a null-terminated string. Equal ``string`` and ``cstring`` values produce an equal hash value. +- ``memfiles.open`` now closes file handleds/fds by default. Passing + ``allowRemap=true`` to ``memfiles.open`` recovers the old behavior. The old + behavior is only needed to call ``mapMem`` on the resulting ``MemFile``. Library Additions ----------------- |