diff options
| author | Kim van der Riet <kpvdr@apache.org> | 2013-04-22 19:19:27 +0000 |
|---|---|---|
| committer | Kim van der Riet <kpvdr@apache.org> | 2013-04-22 19:19:27 +0000 |
| commit | 1da5c1e50dd1890d0c692ce223bd42f2a5a9ccd7 (patch) | |
| tree | b37530f7329e75499d7bbefea03faed748d5a5cf /cpp/src | |
| parent | 3497c8f243c6c9bb7f18182b9dc0d5d6c7e93823 (diff) | |
| download | qpid-python-1da5c1e50dd1890d0c692ce223bd42f2a5a9ccd7.tar.gz | |
QPID-4765: "Incorrect parameter validation for legacystore wcache-page-size and jfile-size-pgs"
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1470667 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
| -rw-r--r-- | cpp/src/qpid/legacystore/MessageStoreImpl.cpp | 48 |
1 files changed, 18 insertions, 30 deletions
diff --git a/cpp/src/qpid/legacystore/MessageStoreImpl.cpp b/cpp/src/qpid/legacystore/MessageStoreImpl.cpp index 69e9f48a17..8c1baa5052 100644 --- a/cpp/src/qpid/legacystore/MessageStoreImpl.cpp +++ b/cpp/src/qpid/legacystore/MessageStoreImpl.cpp @@ -113,36 +113,24 @@ u_int32_t MessageStoreImpl::chkJrnlFileSizeParam(const u_int32_t param, const st u_int32_t MessageStoreImpl::chkJrnlWrPageCacheSize(const u_int32_t param, const std::string paramName, const u_int16_t jrnlFsizePgs) { u_int32_t p = param; - switch (p) - { - case 1: - case 2: - case 4: - case 8: - case 16: - case 32: - case 64: - case 128: - if (jrnlFsizePgs == 1) { - p = 64; - QPID_LOG(warning, "parameter " << paramName << " (" << param << ") cannot set a page size greater than the journal file size; changing this parameter to the journal file size (" << p << ")"); - } - break; - default: - if (p == 0) { - // For zero value, use default - p = JRNL_WMGR_DEF_PAGE_SIZE * JRNL_DBLK_SIZE * JRNL_SBLK_SIZE / 1024; - QPID_LOG(warning, "parameter " << paramName << " (" << param << ") must be a power of 2 between 1 and 128; changing this parameter to default value (" << p << ")"); - } else { - // For any positive value, use closest value - if (p < 6) p = 4; - else if (p < 12) p = 8; - else if (p < 24) p = 16; - else if (p < 48) p = 32; - else if (p < 96) p = 64; - else p = 128; - QPID_LOG(warning, "parameter " << paramName << " (" << param << ") must be a power of 2 between 1 and 128; changing this parameter to closest allowable value (" << p << ")"); - } + + if (jrnlFsizePgs == 1 && p > 64 ) { + p = 64; + QPID_LOG(warning, "parameter " << paramName << " (" << param << ") cannot set a page size greater than the journal file size; changing this parameter to the journal file size (" << p << ")"); + } + else if (p == 0) { + // For zero value, use default + p = JRNL_WMGR_DEF_PAGE_SIZE * JRNL_DBLK_SIZE * JRNL_SBLK_SIZE / 1024; + QPID_LOG(warning, "parameter " << paramName << " (" << param << ") must be a power of 2 between 1 and 128; changing this parameter to default value (" << p << ")"); + } else if ( p > 128 || p & (p-1) ) { + // For any positive value that is not a power of 2, use closest value + if (p < 6) p = 4; + else if (p < 12) p = 8; + else if (p < 24) p = 16; + else if (p < 48) p = 32; + else if (p < 96) p = 64; + else p = 128; + QPID_LOG(warning, "parameter " << paramName << " (" << param << ") must be a power of 2 between 1 and 128; changing this parameter to closest allowable value (" << p << ")"); } return p; } |
