Skip to content

Commit e2999cd

Browse files
committed
Fixed bug #7927 : Some default values is set incorrectly for SC\CS architectures
1 parent e35437e commit e2999cd

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/common/config/config.cpp

+28-8
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Config::Config(const ConfigFile& file)
152152
: valuesSource(*getDefaultMemoryPool()),
153153
notifyDatabase(*getDefaultMemoryPool()),
154154
serverMode(-1),
155-
defaultConfig(false)
155+
defaultConfig(true)
156156
{
157157
memset(sourceIdx, 0, sizeof(sourceIdx));
158158
valuesSource.add(NULL);
@@ -180,6 +180,7 @@ Config::Config(const ConfigFile& file)
180180
}
181181

182182
loadValues(file, CONFIG_FILE);
183+
fixDefaults();
183184
}
184185

185186
Config::Config(const ConfigFile& file, const char* srcName, const Config& base, const PathName& notify)
@@ -294,7 +295,7 @@ static const char* txtServerModes[6] =
294295

295296
void Config::setupDefaultConfig()
296297
{
297-
defaultConfig = true;
298+
fb_assert(defaultConfig);
298299

299300
for (unsigned i = 0; i < MAX_CONFIG_KEY; i++)
300301
defaults[i] = entries[i].default_value;
@@ -305,26 +306,45 @@ void Config::setupDefaultConfig()
305306
serverMode = bootBuild ? MODE_CLASSIC : MODE_SUPER;
306307
pDefault->strVal = txtServerModes[2 * serverMode];
307308

308-
pDefault = &defaults[KEY_TEMP_CACHE_LIMIT];
309+
defaults[KEY_REMOTE_FILE_OPEN_ABILITY].boolVal = bootBuild;
310+
311+
//pDefault = &entries[KEY_WIRE_CRYPT].default_value;
312+
// if (!*pDefault)
313+
// *pDefault == (ConfigValue) (xxx == WC_CLIENT) ? WIRE_CRYPT_ENABLED : WIRE_CRYPT_REQUIRED;
314+
315+
}
316+
317+
void Config::fixDefaults()
318+
{
319+
fb_assert(defaultConfig);
320+
321+
ConfigValue* pDefault = &defaults[KEY_TEMP_CACHE_LIMIT];
322+
ConfigValue* pValue = &values[KEY_TEMP_CACHE_LIMIT];
309323
if (pDefault->intVal < 0)
310324
pDefault->intVal = (serverMode != MODE_SUPER) ? 8388608 : 67108864; // bytes
311325

312-
defaults[KEY_REMOTE_FILE_OPEN_ABILITY].boolVal = bootBuild;
326+
if (pValue->intVal < 0)
327+
pValue->intVal = pDefault->intVal;
328+
313329

314330
pDefault = &defaults[KEY_DEFAULT_DB_CACHE_PAGES];
331+
pValue = &values[KEY_DEFAULT_DB_CACHE_PAGES];
315332
if (pDefault->intVal < 0)
316333
pDefault->intVal = (serverMode != MODE_SUPER) ? 256 : 2048; // pages
317334

335+
if (pValue->intVal < 0)
336+
pValue->intVal = pDefault->intVal;
337+
338+
318339
pDefault = &defaults[KEY_GC_POLICY];
340+
pValue = &values[KEY_GC_POLICY];
319341
if (!pDefault->strVal)
320342
{
321343
pDefault->strVal = (serverMode == MODE_SUPER) ? GCPolicyCombined : GCPolicyCooperative;
322344
}
323345

324-
//pDefault = &entries[KEY_WIRE_CRYPT].default_value;
325-
// if (!*pDefault)
326-
// *pDefault == (ConfigValue) (xxx == WC_CLIENT) ? WIRE_CRYPT_ENABLED : WIRE_CRYPT_REQUIRED;
327-
346+
if (!pValue->strVal)
347+
pValue->strVal = pDefault->strVal;
328348
}
329349

330350
void Config::checkIntForLoBound(ConfigKey key, SINT64 loBound, bool setDefault)

src/common/config/config.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,15 @@ class Config : public RefCounted, public GlobalStorage
324324
static ConfigValue specialProcessing(ConfigKey key, ConfigValue val);
325325

326326
void loadValues(const ConfigFile& file, const char* srcName);
327-
void setupDefaultConfig();
328327
void checkValues();
329328

329+
// set default ServerMode and default values that didn't depends on ServerMode
330+
void setupDefaultConfig();
331+
332+
// set default values that depends on ServerMode and actual values that was
333+
// not set in config file
334+
void fixDefaults();
335+
330336
// helper check-value functions
331337
void checkIntForLoBound(ConfigKey key, SINT64 loBound, bool setDefault);
332338
void checkIntForHiBound(ConfigKey key, SINT64 hiBound, bool setDefault);

0 commit comments

Comments
 (0)