Mercurial > hg4j
diff src/org/tmatesoft/hg/internal/DataAccessProvider.java @ 494:2743641f2f12
Defect: use of 0 as configuration value for mapio boundary results in every file being memmap-ed
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 18 Oct 2012 19:51:07 +0200 |
parents | 909306e412e2 |
children | 243202f1bda5 |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/internal/DataAccessProvider.java Thu Oct 18 18:36:13 2012 +0200 +++ b/src/org/tmatesoft/hg/internal/DataAccessProvider.java Thu Oct 18 19:51:07 2012 +0200 @@ -55,18 +55,23 @@ public DataAccessProvider(SessionContext ctx) { context = ctx; PropertyMarshal pm = new PropertyMarshal(ctx); - mapioMagicBoundary = pm.getInt(CFG_PROPERTY_MAPIO_LIMIT, DEFAULT_MAPIO_LIMIT); + mapioMagicBoundary = mapioBoundaryValue(pm.getInt(CFG_PROPERTY_MAPIO_LIMIT, DEFAULT_MAPIO_LIMIT)); bufferSize = pm.getInt(CFG_PROPERTY_FILE_BUFFER_SIZE, DEFAULT_FILE_BUFFER); mapioBufSize = pm.getInt(CFG_PROPERTY_MAPIO_BUFFER_SIZE, DEFAULT_MAPIO_BUFFER); } public DataAccessProvider(SessionContext ctx, int mapioBoundary, int regularBufferSize, int mapioBufferSize) { context = ctx; - mapioMagicBoundary = mapioBoundary == 0 ? Integer.MAX_VALUE : mapioBoundary; + mapioMagicBoundary = mapioBoundaryValue(mapioBoundary); bufferSize = regularBufferSize; mapioBufSize = mapioBufferSize; } + // ensure contract of CFG_PROPERTY_MAPIO_LIMIT, for mapioBoundary == 0 use MAX_VALUE so that no file is memmap-ed + private static int mapioBoundaryValue(int mapioBoundary) { + return mapioBoundary == 0 ? Integer.MAX_VALUE : mapioBoundary; + } + public DataAccess create(File f) { if (!f.exists()) { return new DataAccess();