From: <ale...@us...> - 2015-07-10 13:41:13
|
Revision: 61964 http://sourceforge.net/p/firebird/code/61964 Author: alexpeshkoff Date: 2015-07-10 13:41:10 +0000 (Fri, 10 Jul 2015) Log Message: ----------- Fixed CORE-4871: Merge SharedDatabase/SharedCache into single parameter ServerMode, affecting the way how server is started Modified Paths: -------------- firebird/trunk/builds/install/misc/firebird.conf.in firebird/trunk/src/common/call_service.cpp firebird/trunk/src/common/config/config.cpp firebird/trunk/src/common/config/config.h firebird/trunk/src/jrd/dpm.epp firebird/trunk/src/jrd/inf.cpp firebird/trunk/src/jrd/jrd.cpp firebird/trunk/src/jrd/os/posix/unix.cpp firebird/trunk/src/jrd/os/win32/winnt.cpp firebird/trunk/src/jrd/pag.cpp firebird/trunk/src/lock/lock.cpp firebird/trunk/src/remote/server/os/posix/inet_server.cpp Modified: firebird/trunk/builds/install/misc/firebird.conf.in =================================================================== --- firebird/trunk/builds/install/misc/firebird.conf.in 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/builds/install/misc/firebird.conf.in 2015-07-10 13:41:10 UTC (rev 61964) @@ -869,16 +869,20 @@ # Settings for Architecture Configuration # ============================ - -# Type: boolean -#SharedCache = true - -# Type: boolean -#SharedDatabase = false - - -# SharedCache SharedDatabase Mode -# false false Classic with exclusive access // single attachment only ? -# false true Classic with shared access // traditional CS/SC -# true false Super with exclusive access // traditional SS -# true true Super with shared access // +# +# Control a method firebird engine is using to work with databases and +# related firebird server startup parameters. +# +# The values are: +# Super / ThreadedDedicated - databases are opened exclusive by single server process, +# attachments share single DB pages cache inside process +# SuperClassic / ThreadedShared - databases are opened by single server process, +# but it does not prevent opening them in other processes (embedded access), +# each attachment has it's own DB pages cache +# Classic / MultiProcess - for each attachment to server separate process is started, +# each database mauy be opened by mu;tiple processes (including local ones for +# embedded access), each attachment (process) has it's own DB pages cache +# +# Type: string +# +#ServerMode = Super Modified: firebird/trunk/src/common/call_service.cpp =================================================================== --- firebird/trunk/src/common/call_service.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/common/call_service.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -245,7 +245,7 @@ { stuffSpb(spb, isc_spb_trusted_auth, ""); } - if ((!server[0]) && forceLoopback && (!Config::getSharedDatabase())) + if ((!server[0]) && forceLoopback && (Config::getServerMode() == MODE_SUPER)) { // local connection & force & superserver stuffSpb(spb, isc_spb_config, "Providers=Loopback," CURRENT_ENGINE); } Modified: firebird/trunk/src/common/config/config.cpp =================================================================== --- firebird/trunk/src/common/config/config.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/common/config/config.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -186,8 +186,7 @@ {TYPE_STRING, "UserManager", (ConfigValue) "Srp"}, {TYPE_STRING, "TracePlugin", (ConfigValue) "fbtrace"}, {TYPE_STRING, "SecurityDatabase", (ConfigValue) "$(dir_secDb)/security3.fdb"}, // security database name - {TYPE_BOOLEAN, "SharedCache", (ConfigValue) true}, - {TYPE_BOOLEAN, "SharedDatabase", (ConfigValue) false}, + {TYPE_STRING, "ServerMode", (ConfigValue) "Super"}, {TYPE_STRING, "WireCrypt", (ConfigValue) NULL}, {TYPE_STRING, "WireCryptPlugin", (ConfigValue) "Arc4"}, {TYPE_STRING, "KeyHolderPlugin", (ConfigValue) ""}, @@ -424,7 +423,7 @@ SINT64 v = (SINT64) getDefaultConfig()->values[KEY_TEMP_CACHE_LIMIT]; if (v < 0) { - v = getSharedDatabase() ? 8388608 : 67108864; // bytes + v = getServerMode() != MODE_SUPER ? 8388608 : 67108864; // bytes } return v; } @@ -469,7 +468,7 @@ int rc = get<int>(KEY_DEFAULT_DB_CACHE_PAGES); if (rc < 0) { - rc = getSharedDatabase() ? 256 : 2048; // pages + rc = getServerMode() != MODE_SUPER ? 256 : 2048; // pages } return rc; } @@ -636,7 +635,7 @@ if (! rc) { - rc = getSharedCache() ? GCPolicyCombined : GCPolicyCooperative; + rc = getServerMode() == MODE_SUPER ? GCPolicyCombined : GCPolicyCooperative; } return rc; @@ -678,14 +677,27 @@ return (FB_UINT64)(SINT64) getDefaultConfig()->values[KEY_MAX_TRACELOG_SIZE]; } -bool Config::getSharedCache() +int Config::getServerMode() { - return (bool) getDefaultConfig()->values[KEY_SHARED_CACHE]; -} + static int rc = -1; + if (rc >= 0) + return rc; -bool Config::getSharedDatabase() -{ - return (bool) getDefaultConfig()->values[KEY_SHARED_DATABASE]; + const char* textMode = (const char*) (getDefaultConfig()->values[KEY_SERVER_MODE]); + const char* modes[6] = + {"Super", "ThreadedDedicated", "SuperClassic", "ThreadedShared", "Classic", "MultiProcess"}; + for (int x = 0; x < 6; ++x) + { + if (fb_utils::stricmp(textMode, modes[x]) == 0) + { + rc = x / 2; + return rc; + } + } + + // use default + rc = MODE_SUPER; + return rc; } const char* Config::getPlugins(unsigned int type) const Modified: firebird/trunk/src/common/config/config.h =================================================================== --- firebird/trunk/src/common/config/config.h 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/common/config/config.h 2015-07-10 13:41:10 UTC (rev 61964) @@ -75,6 +75,10 @@ enum WireCryptMode {WC_CLIENT, WC_SERVER}; // Have different defaults +const int MODE_SUPER = 0; +const int MODE_SUPERCLASSIC = 1; +const int MODE_CLASSIC = 2; + const char* const CONFIG_FILE = "firebird.conf"; class Config : public Firebird::RefCounted, public Firebird::GlobalStorage @@ -129,8 +133,7 @@ KEY_PLUG_AUTH_MANAGE, KEY_PLUG_TRACE, KEY_SECURITY_DATABASE, - KEY_SHARED_CACHE, - KEY_SHARED_DATABASE, + KEY_SERVER_MODE, KEY_WIRE_CRYPT, KEY_PLUG_WIRE_CRYPT, KEY_PLUG_KEY_HOLDER, @@ -329,10 +332,8 @@ static FB_UINT64 getMaxUserTraceLogSize(); - static bool getSharedCache(); + static int getServerMode(); - static bool getSharedDatabase(); - const char* getPlugins(unsigned int type) const; const char* getSecurityDatabase() const; Modified: firebird/trunk/src/jrd/dpm.epp =================================================================== --- firebird/trunk/src/jrd/dpm.epp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/dpm.epp 2015-07-10 13:41:10 UTC (rev 61964) @@ -3118,7 +3118,7 @@ // Make few tries to lock consecutive data pages without waiting. In highly // concurrent environment with shared page cache it could be faster than wait // in OS for first candidate page. - int tries = dbb->dbb_config->getSharedCache() ? 8 : 0; + int tries = dbb->dbb_config->getServerMode() != MODE_SUPER ? 8 : 0; ULONG pp_sequence = (type == DPM_primary ? relPages->rel_pri_data_space : relPages->rel_sec_data_space); Modified: firebird/trunk/src/jrd/inf.cpp =================================================================== --- firebird/trunk/src/jrd/inf.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/inf.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -718,7 +718,7 @@ case isc_info_db_class: length = INF_convert( - (dbb->dbb_config->getSharedDatabase() ? + (dbb->dbb_config->getServerMode() != MODE_SUPER ? isc_info_db_class_classic_access : isc_info_db_class_server_access), buffer); break; Modified: firebird/trunk/src/jrd/jrd.cpp =================================================================== --- firebird/trunk/src/jrd/jrd.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/jrd.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -1545,7 +1545,7 @@ // Here we do not let anyone except SYSDBA (like DBO) to change dbb_page_buffers, // cause other flags is UserId can be set only when DB is opened. // No idea how to test for other cases before init is complete. - if (config->getSharedDatabase() ? userId.locksmith() : true) + if ((config->getServerMode() != MODE_SUPER) || userId.locksmith()) dbb->dbb_page_buffers = options.dpb_page_buffers; } @@ -5656,7 +5656,7 @@ break; case isc_dpb_num_buffers: - if (!Config::getSharedCache()) + if (Config::getServerMode() != MODE_SUPER) { dpb_buffers = rdr.getInt(); const unsigned TEMP_LIMIT = 25; @@ -6037,15 +6037,8 @@ { // scope MutexLockGuard listGuard(databases_mutex, FB_FUNCTION); - if (config->getSharedCache()) + if (config->getServerMode() == MODE_SUPER) { - if (config->getSharedDatabase()) - { - const char* const errorMsg = - "SharedDatabase and SharedCache settings cannot be both enabled at once"; - ERR_post(Arg::Gds(isc_wish_list) << Arg::Gds(isc_random) << Arg::Str(errorMsg)); - } - shared = true; dbb = databases; @@ -6342,7 +6335,7 @@ dbb->dbb_extManager.closeAttachment(tdbb, attachment); - if (!dbb->dbb_config->getSharedDatabase() && attachment->att_relations) + if ((dbb->dbb_config->getServerMode() == MODE_SUPER) && attachment->att_relations) { vec<jrd_rel*>& rels = *attachment->att_relations; for (FB_SIZE_T i = 1; i < rels.count(); i++) @@ -6544,7 +6537,7 @@ if ((flags & SHUT_DBB_LINGER) && (!(engineShutdown || (dbb->dbb_ast_flags & DBB_shutdown))) && (dbb->dbb_linger_seconds > 0) && - (MasterInterfacePtr()->serverMode(-1) == 1) && // multiuser server + (dbb->dbb_config->getServerMode() != MODE_CLASSIC) && (dbb->dbb_flags & DBB_shared)) { if (!dbb->dbb_linger_timer) Modified: firebird/trunk/src/jrd/os/posix/unix.cpp =================================================================== --- firebird/trunk/src/jrd/os/posix/unix.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/os/posix/unix.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -222,7 +222,7 @@ Arg::Gds(isc_io_create_err) << Arg::Unix(errno)); } - const bool shareMode = dbb->dbb_config->getSharedDatabase(); + const bool shareMode = dbb->dbb_config->getServerMode() != MODE_SUPER; if (!lockDatabaseFile(desc, shareMode, temporary)) { int lockErrno = errno; @@ -665,7 +665,7 @@ dbb->dbb_flags |= DBB_being_opened_read_only; } - const bool shareMode = dbb->dbb_config->getSharedDatabase(); + const bool shareMode = dbb->dbb_config->getServerMode() != MODE_SUPER; if (!lockDatabaseFile(desc, shareMode || readOnly)) { ERR_post(Arg::Gds(isc_io_error) << Arg::Str("lock") << Arg::Str(file_name) << Modified: firebird/trunk/src/jrd/os/win32/winnt.cpp =================================================================== --- firebird/trunk/src/jrd/os/win32/winnt.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/os/win32/winnt.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -221,7 +221,7 @@ adjustFsCacheOnce.init(); const TEXT* file_name = string.c_str(); - const bool shareMode = dbb->dbb_config->getSharedDatabase(); + const bool shareMode = dbb->dbb_config->getServerMode() != MODE_SUPER; DWORD dwShareMode = getShareFlags(shareMode, temporary); @@ -543,7 +543,7 @@ **************************************/ const TEXT* const ptr = (string.hasData() ? string : file_name).c_str(); bool readOnly = false; - const bool shareMode = dbb->dbb_config->getSharedDatabase(); + const bool shareMode = dbb->dbb_config->getServerMode() != MODE_SUPER; adjustFsCacheOnce.init(); Modified: firebird/trunk/src/jrd/pag.cpp =================================================================== --- firebird/trunk/src/jrd/pag.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/jrd/pag.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -2285,7 +2285,7 @@ fb_assert(tempPageSpaceID == 0); - if (dbb->dbb_config->getSharedDatabase()) + if (dbb->dbb_config->getServerMode() != MODE_SUPER) { Jrd::Attachment* const attachment = tdbb->getAttachment(); Modified: firebird/trunk/src/lock/lock.cpp =================================================================== --- firebird/trunk/src/lock/lock.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/lock/lock.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -219,7 +219,7 @@ m_config(conf), m_acquireSpins(m_config->getLockAcquireSpins()), m_memorySize(m_config->getLockMemSize()), - m_useBlockingThread(m_config->getSharedDatabase()) + m_useBlockingThread(m_config->getServerMode() != MODE_SUPER) #ifdef USE_SHMEM_EXT , m_extents(getPool()) #endif Modified: firebird/trunk/src/remote/server/os/posix/inet_server.cpp =================================================================== --- firebird/trunk/src/remote/server/os/posix/inet_server.cpp 2015-07-10 13:06:45 UTC (rev 61963) +++ firebird/trunk/src/remote/server/os/posix/inet_server.cpp 2015-07-10 13:41:10 UTC (rev 61964) @@ -203,20 +203,6 @@ debug = true; break; - case 'S': - if (!classic) - { - standaloneClassic = true; - } - break; - - case 'I': - if (!classic) - { - standaloneClassic = false; - } - break; - case 'E': if (argv < end) { @@ -254,8 +240,6 @@ case '?': printf("Firebird TCP/IP server options are:\n"); printf(" -d : debug on\n"); - printf(" -s : standalone - true\n"); - printf(" -i : standalone - false\n"); printf(" -p <port> : specify port to listen on\n"); printf(" -z : print version and exit\n"); printf(" -h|? : print this help\n"); @@ -281,8 +265,18 @@ } } - if (!(classic || standaloneClassic)) + if (Config::getServerMode() == MODE_CLASSIC) { + if (!classic) + standaloneClassic = true; + } + else + { + if (classic) + { + gds__log("Server misconfigured - to start it from (x)inetd add ServerMode=Classic to firebird.conf"); + exit(STARTUP_ERROR); + } INET_SERVER_flag |= SRVR_multi_client; super = true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |