8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 16:43:03 +01:00

1. Cleaned up most of SUPERSERVER usage.

SUPERSERVER has 4 different meanings in our code:
- this is milticlient server (replaced with Config::getMultiClientServer())
- use shared data cache (replaced with Config::getSharedCache())
- use shared metadata cache (replaced with macro SHARED_METADATA_CACHE)
- database are NOT shared between processes (replaced with getSharedDatabase())

2. Use fb_smp_server as both superclassic and classic binary on posix
(xinetd autodecection is done).

3. Small posix build cleanup.
This commit is contained in:
alexpeshkoff 2010-04-15 14:40:27 +00:00
parent 6606f09c14
commit 88b8a40a04
60 changed files with 526 additions and 674 deletions

View File

@ -122,7 +122,7 @@ copyFiles() {
then
mkdir -p $TargetDir/usr/include
fi
cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_inet_server
cp -f $BuiltFBDir/bin/fb_smp_server $DestDir/bin/fb_smp_server
cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak
cp $BuiltFBDir/bin/gds_drop $DestDir/bin/gds_drop

View File

@ -35,7 +35,7 @@ origDir=`pwd`
if [ "$1" = "install-embedded" ]
then
# remove server files not needed for embedded usage
rm -f @FB_SBINDIR@/fb_inet_server @FB_SBINDIR@/fb_smp_server
rm -f @FB_SBINDIR@/fb_smp_server @FB_SBINDIR@/fb_smp_server
exit 0
fi

View File

@ -62,7 +62,7 @@ echo "Install and start Classic"
#inetd
if [ -f /var/run/inetd.pid -a -d /etc/inetd.d ]; then
if [ -f /etc/inetd.conf ]; then
echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_inet_server fb_inet_server" > /etc/.fb.inetd.conf.entry
echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_smp_server fb_smp_server" > /etc/.fb.inetd.conf.entry
cat /etc/inetd.conf /etc/.fb.inetd.conf.entry > /etc/.firebird.temp.install.inetd.conf
mv /etc/.firebird.temp.install.inetd.conf /etc/inetd.conf
rm -f /etc/.fb.inetd.conf.entry
@ -80,7 +80,7 @@ service gds_db
wait = no
user = firebird
EOF
echo "server = $FB_FW/Resources/bin/fb_inet_server" >> /etc/xinetd.d/firebird
echo "server = $FB_FW/Resources/bin/fb_smp_server" >> /etc/xinetd.d/firebird
cat >> /etc/xinetd.d/firebird << EOF
groups = yes
}
@ -111,7 +111,7 @@ echo "You are already in SuperClassic mode"
else
# Check if Classic is running
echo "Check if Classic is running"
if ps -axe | grep "fb_inet_server" | grep -v grep
if ps -axe | grep "fb_smp_server" | grep -v grep
then
echo "An instance of the Firebird Classic Server seems to be running."
echo "Please exit all Firebird applications before continuing."

View File

@ -135,7 +135,7 @@ else
chmod 444 "$FB_FW/Resources/English.lproj/var/help/help.fdb"
chmod a+s "$FB_FW/Resources/bin/gds_drop"
chmod a+s "$FB_FW/Resources/bin/fb_inet_server"
chmod a+s "$FB_FW/Resources/bin/fb_smp_server"
fi
@ -178,7 +178,7 @@ echo "Install ourselves in the correct place Classic"
echo "Test inetd"
if [ -f /var/run/inetd.pid -a -d /etc/inetd.d ]; then
if [ -f /etc/inetd.conf ]; then
echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_inet_server fb_inet_server" > /etc/.fb.inetd.conf.entry
echo "gds_db stream tcp nowait root $FB_FW/Resources/bin/fb_smp_server fb_smp_server" > /etc/.fb.inetd.conf.entry
cat /etc/inetd.conf /etc/.fb.inetd.conf.entry > /etc/.firebird.temp.install.inetd.conf
mv /etc/.firebird.temp.install.inetd.conf /etc/inetd.conf
rm -f /etc/.fb.inetd.conf.entry
@ -200,7 +200,7 @@ service gds_db
wait = no
user = firebird
EOF
echo "server = $FB_FW/Resources/bin/fb_inet_server" >> /etc/xinetd.d/firebird
echo "server = $FB_FW/Resources/bin/fb_smp_server" >> /etc/xinetd.d/firebird
cat >> /etc/xinetd.d/firebird << EOF
groups = yes
}

View File

@ -8,7 +8,7 @@
<string>org.firebird.gds</string>
<key>ProgramArguments</key>
<array>
<string>/Library/Frameworks/Firebird.framework/Resources/bin/fb_inet_server</string>
<string>/Library/Frameworks/Firebird.framework/Resources/bin/fb_smp_server</string>
</array>
<key>InetdCompatibility</key>
<dict>

View File

@ -162,7 +162,6 @@ copyFiles() {
chmod 0755 ${TargetDir}@FB_BINDIR@/*
#sbin
copyIfExists $BuiltFBDir/bin/fb_inet_server ${TargetDir}@FB_SBINDIR@
copyIfExists $BuiltFBDir/bin/fb_smp_server ${TargetDir}@FB_SBINDIR@
copyIfExists $BuiltFBDir/bin/fbserver ${TargetDir}@FB_SBINDIR@
cp -f $BuiltFBDir/bin/fbguard ${TargetDir}@FB_SBINDIR@
@ -437,7 +436,7 @@ cat >>/etc/services <<EOF
@FB_SERVICE_NAME@ @FB_SERVICE_PORT@/tcp #Firebird Database Remote Protocol
EOF
cat >>/etc/inetd.conf <<EOF
@FB_SERVICE_NAME@ stream tcp nowait firebird ${TargetDir}@FB_SBINDIR@/fb_inet_server fb_inet_server
@FB_SERVICE_NAME@ stream tcp nowait firebird ${TargetDir}@FB_SBINDIR@/fb_smp_server fb_smp_server
EOF
if [ -f /var/run/inetd.pid ]; then
kill -HUP `cat /var/run/inetd.pid`

View File

@ -120,7 +120,7 @@ copyFiles() {
mkdir -p $TargetDir@libdir@
mkdir -p $TargetDir/usr/include
cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_inet_server
cp -f $BuiltFBDir/bin/fb_smp_server $DestDir/bin/fb_smp_server
cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak
cp $BuiltFBDir/bin/gds_drop $DestDir/bin/gds_drop

View File

@ -54,7 +54,7 @@
checkString=`ps -ef | egrep "(fb_inet_server)" |grep -v grep`
checkString=`ps -ef | egrep "(fb_inet_server|fb_smp_server)" |grep -v grep`
if [ ! -z "$checkString" ]
then

View File

@ -16,5 +16,5 @@ service @FB_SERVICE_NAME@
# using default firewall configuration (SF#1065511)
# log_on_success += USERID
# log_on_failure += USERID
server = @FB_SBINDIR@/fb_inet_server
server = @FB_SBINDIR@/fb_smp_server
}

View File

@ -161,7 +161,6 @@ copyFiles() {
chmod 0755 ${TargetDir}@FB_BINDIR@/*
#sbin
copyIfExists $BuiltFBDir/bin/fb_inet_server ${TargetDir}@FB_SBINDIR@
copyIfExists $BuiltFBDir/bin/fb_smp_server ${TargetDir}@FB_SBINDIR@
copyIfExists $BuiltFBDir/bin/fbserver ${TargetDir}@FB_SBINDIR@
cp -f $BuiltFBDir/bin/fbguard ${TargetDir}@FB_SBINDIR@

View File

@ -138,7 +138,7 @@ do
mkdir -p $DestDir/$D || exit
done
cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_inet_server || exit
cp -f $BuiltFBDir/bin/fb_inet_server $DestDir/bin/fb_smp_server || exit
cp $BuiltFBDir/bin/gbak $DestDir/bin/gbak || exit
cp $BuiltFBDir/bin/gds_drop $DestDir/bin/gds_drop || exit
copyIfExists $BuiltFBDir/bin/fb_lock_mgr $DestDir/bin/fb_lock_mgr || exit
@ -250,7 +250,7 @@ done
chmod a=rx isql qli
# SUID is needed for running server programs.
for i in fb_lock_mgr gds_drop fb_inet_server
for i in fb_lock_mgr gds_drop fb_smp_server
do
if [ -f $i ]; then
chmod ug=rx,o= $i || exit
@ -303,7 +303,7 @@ if ! grep ^@FB_SERVICE_NAME@ /etc/inetd.conf
then
echo Adding firebird to /etc/inetd.conf
cat >>/etc/inetd.conf <<EOF
@FB_SERVICE_NAME@ stream tcp nowait firebird @prefix@/bin/fb_inet_server fb_inet_server
@FB_SERVICE_NAME@ stream tcp nowait firebird @prefix@/bin/fb_smp_server fb_smp_server
EOF
fi

View File

@ -20,7 +20,7 @@
<exec_method
type='method'
name='inetd_start'
exec='/opt/firebird/bin/fb_inet_server'
exec='/opt/firebird/bin/fb_smp_server'
timeout_seconds='0'>
<method_context>
<method_credential user='firebird' group='firebird' />
@ -46,7 +46,7 @@
<propval name='converted' type='boolean' value='true' />
<propval name='version' type='integer' value='1' />
<propval name='source_line' type='astring' value=
'gds_db stream tcp nowait firebird /opt/firebird/bin/fb_inet_server fb_inet_server'
'gds_db stream tcp nowait firebird /opt/firebird/bin/fb_smp_server fb_smp_server'
/>
</property_group>

View File

@ -59,7 +59,7 @@ f none @prefix@/UDF/fbudf.sql=$SRCDIR/../../src/extlib/fbudf/fbudf.sql 0644 fire
# bin
d none @prefix@/bin 0751 firebird firebird
f none @prefix@/bin/fb_inet_server=$SRCDIR/bin/fb_inet_server 0451 firebird firebird
f none @prefix@/bin/fb_smp_server=$SRCDIR/bin/fb_smp_server 0451 firebird firebird
f none @prefix@/bin/gfix=$SRCDIR/bin/gfix 0451 firebird firebird
f none @prefix@/bin/gbak=$SRCDIR/bin/gbak 0451 firebird firebird
f none @prefix@/bin/gsplit=$SRCDIR/bin/gsplit 0451 firebird firebird

View File

@ -59,7 +59,7 @@ f none @prefix@/UDF/fbudf.sql=$SRCDIR/../../src/extlib/fbudf/fbudf.sql 0644 fire
# bin
d none @prefix@/bin 0755 firebird firebird
#f none @prefix@/bin/fb_inet_server=$SRCDIR/bin/fb_inet_server 0451 firebird firebird
#f none @prefix@/bin/fb_smp_server=$SRCDIR/bin/fb_smp_server 0451 firebird firebird
f none @prefix@/bin/gfix=$SRCDIR/bin/gfix 0755 firebird firebird
f none @prefix@/bin/gbak=$SRCDIR/bin/gbak 0755 firebird firebird
f none @prefix@/bin/gsplit=$SRCDIR/bin/gsplit 0755 firebird firebird

View File

@ -79,7 +79,7 @@ changeXinetdServiceUser() {
# This just adds/replaces the service entry line
updateInetdEntry() {
newLine="@FB_SERVICE_NAME@ stream tcp nowait.30000 $RunUser @FB_SBINDIR@/fb_inet_server fb_inet_server # Firebird Database Remote Server"
newLine="@FB_SERVICE_NAME@ stream tcp nowait.30000 $RunUser @FB_SBINDIR@/fb_smp_server fb_smp_server # Firebird Database Remote Server"
replaceLineInFile /etc/inetd.conf "$newLine" "^@FB_SERVICE_NAME@"
}

View File

@ -218,7 +218,7 @@ checkIfServerRunning() {
exit 1
fi
checkString=`ps -ef$psOptions | egrep "\b(fb_inet_server|gds_pipe)\b" |grep -v grep`
checkString=`ps -ef$psOptions | egrep "\b(fb_inet_server|fb_smp_server|gds_pipe)\b" |grep -v grep`
if [ ! -z "$checkString" ]
then
echo "An instance of the Firebird Classic server seems to be running."

View File

@ -332,18 +332,15 @@ examples_cp:
#_ Embedded Firebird Targets (Classic)_______________________________________
.PHONY: libfbembed inet_server fb_smp_server embed_gfix embed_gbak embed_isql
.PHONY: libfbembed fb_smp_server embed_gfix embed_gbak embed_isql
.PHONY: embed_gpre embed_util
classic_targets: $(PLAT_CLASSIC_PRE_TARGET) libfbembed inet_server fb_smp_server embed_gfix embed_gbak embed_isql \
classic_targets: $(PLAT_CLASSIC_PRE_TARGET) libfbembed fb_smp_server embed_gfix embed_gbak embed_isql \
embed_gpre libfbclient embed_util embed_qli embed_fbudf $(PLAT_CLASSIC_POST_TARGET)
libfbembed:
$(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.libfbembed $@
inet_server:
$(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.inet_server
fb_smp_server:
$(MAKE) $(CPU_OPTION) -f $(GEN_ROOT)/Makefile.smp_server
@ -585,7 +582,7 @@ clean_makefiles:
$(RM) $(SRC_ROOT)/include/gen/blrtable.h
clean_gpre_gen:
-$(RM) `find $(SRC_ROOT) -type f -name '*.epp' -print | sed 's/epp$$/cpp/'`
-$(RM) -f `find $(TMP_ROOT)/ -type f -name '*.cpp' -print`
clean_yacc_gen:
$(RM) $(ROOT)/src/dsql/parse.cpp $(ROOT)/src/dsql/dsql.tab.h

View File

@ -286,7 +286,6 @@ LINK_OPTS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS)
LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared
FB_SUPER_SERVER = $(BIN)/fbserver$(EXEC_EXT)
FB_CLASSIC_SERVER = $(BIN)/fb_inet_server$(EXEC_EXT)
FB_DAEMON = $(BIN)/fb_smp_server$(EXEC_EXT)
STATIC_CXXSUPPORT_LIB=@STATIC_CXXSUPPORT_LIB@

View File

@ -78,7 +78,7 @@ JRD_Objects = $(addprefix $(OBJ)/, $(addsuffix .o, $(basename $(JRD_Sources))))
DSQL_ClientFiles = array.epp blob.epp \
preparse.cpp user_dsql.cpp utld.cpp keywords.cpp
DSQL_ServerFiles= metd.epp \
DSQL_ServerFiles= metd.epp DSqlDataTypeUtil.cpp \
ddl.cpp dsql.cpp errd.cpp gen.cpp hsh.cpp make.cpp \
movd.cpp parse.cpp Parser.cpp pass1.cpp misc_func.cpp \
DdlNodes.epp PackageNodes.epp AggNodes.cpp ExprNodes.cpp StmtNodes.cpp WinNodes.cpp

View File

@ -74,7 +74,7 @@ darwin_finish_cs_framework:
cp -r ../gen/firebird/examples $(FB_FW)/Resources
mkdir -p $(FB_FW)/Resources/bin
ln -s ../../bin $(FB_FW)/Resources/English.lproj/var/bin
cp ../gen/firebird/bin/fb_inet_server $(FB_FW)/Resources/bin
cp ../gen/firebird/bin/fb_smp_server $(FB_FW)/Resources/bin
cp ../gen/firebird/bin/gfix $(FB_FW)/Resources/bin
cp ../gen/firebird/bin/gbak $(FB_FW)/Resources/bin
cp ../gen/firebird/bin/isql $(FB_FW)/Resources/bin

View File

@ -112,11 +112,6 @@ Firebird::InitInstance<ConfigRoot> rootDetector;
const char* GCPolicyCooperative = "cooperative";
const char* GCPolicyBackground = "background";
const char* GCPolicyCombined = "combined";
#ifdef SUPERSERVER
const char* GCPolicyDefault = GCPolicyCombined;
#else
const char* GCPolicyDefault = GCPolicyCooperative;
#endif
const char* AmNative = "native";
const char* AmTrusted = "trusted";
@ -125,13 +120,7 @@ const char* AmMixed = "mixed";
const Config::ConfigEntry Config::entries[MAX_CONFIG_KEY] =
{
{TYPE_INTEGER, "TempBlockSize", (ConfigValue) 1048576}, // bytes
#ifdef SUPERSERVER
{TYPE_INTEGER, "TempCacheLimit", (ConfigValue) 67108864}, // bytes
#elif defined(WIN_NT) // win32 CS
{TYPE_INTEGER, "TempCacheLimit", (ConfigValue) 8388608}, // bytes
#else // non-win32 CS
{TYPE_INTEGER, "TempCacheLimit", (ConfigValue) 0}, // bytes
#endif
{TYPE_INTEGER, "TempCacheLimit", (ConfigValue) -1}, // bytes
#ifdef BOOT_BUILD
{TYPE_BOOLEAN, "RemoteFileOpenAbility", (ConfigValue) true},
#else
@ -141,11 +130,7 @@ const Config::ConfigEntry Config::entries[MAX_CONFIG_KEY] =
{TYPE_INTEGER, "CpuAffinityMask", (ConfigValue) 1},
{TYPE_INTEGER, "TcpRemoteBufferSize", (ConfigValue) 8192}, // bytes
{TYPE_BOOLEAN, "TcpNoNagle", (ConfigValue) true},
#ifdef SUPERSERVER
{TYPE_INTEGER, "DefaultDbCachePages", (ConfigValue) 2048}, // pages
#else
{TYPE_INTEGER, "DefaultDbCachePages", (ConfigValue) 256}, // pages
#endif
{TYPE_INTEGER, "DefaultDbCachePages", (ConfigValue) -1}, // pages
{TYPE_INTEGER, "ConnectionTimeout", (ConfigValue) 180}, // seconds
{TYPE_INTEGER, "DummyPacketInterval", (ConfigValue) 0}, // seconds
{TYPE_INTEGER, "LockMemSize", (ConfigValue) 1048576}, // bytes
@ -182,7 +167,7 @@ const Config::ConfigEntry Config::entries[MAX_CONFIG_KEY] =
{TYPE_BOOLEAN, "BugcheckAbort", (ConfigValue) false}, // whether to abort() engine when internal error is found
#endif
{TYPE_BOOLEAN, "LegacyHash", (ConfigValue) true}, // let use old passwd hash verification
{TYPE_STRING, "GCPolicy", (ConfigValue) GCPolicyDefault}, // garbage collection policy
{TYPE_STRING, "GCPolicy", (ConfigValue) NULL}, // garbage collection policy
{TYPE_BOOLEAN, "Redirection", (ConfigValue) false},
{TYPE_STRING, "Authentication", (ConfigValue) AmNative}, // use native, trusted or mixed
{TYPE_INTEGER, "DatabaseGrowthIncrement", (ConfigValue) 128 * 1048576}, // bytes
@ -351,7 +336,11 @@ int Config::getTempBlockSize()
int Config::getTempCacheLimit()
{
int v = (int) getDefaultConfig()->values[KEY_TEMP_CACHE_LIMIT];
return v < 0 ? 0 : v;
if (v < 0)
{
v = getSharedDatabase() ? 8388608 : 67108864; // bytes
}
return v;
}
bool Config::getRemoteFileOpenAbility()
@ -386,7 +375,12 @@ bool Config::getTcpNoNagle()
int Config::getDefaultDbCachePages() const
{
return get<int>(KEY_DEFAULT_DB_CACHE_PAGES);
int rc = get<int>(KEY_DEFAULT_DB_CACHE_PAGES);
if (rc < 0)
{
rc = getSharedDatabase() ? 75 : 2048; // pages
}
return rc;
}
int Config::getConnectionTimeout()
@ -556,7 +550,25 @@ bool Config::getLegacyHash()
const char *Config::getGCPolicy() const
{
return get<const char*>(KEY_GC_POLICY);
const char* rc = get<const char*>(KEY_GC_POLICY);
if (rc)
{
if (strcmp(rc, GCPolicyCooperative) != 0 &&
strcmp(rc, GCPolicyBackground) != 0 &&
strcmp(rc, GCPolicyCombined) != 0)
{
// user-provided value is invalid - fail to default
rc = 0;
}
}
if (! rc)
{
rc = getSharedCache() ? GCPolicyCombined : GCPolicyCooperative;
}
return rc;
}
bool Config::getRedirection()
@ -604,3 +616,32 @@ int Config::getMaxUserTraceLogSize()
{
return (int) getDefaultConfig()->values[KEY_MAX_TRACELOG_SIZE];
}
bool Config::getSharedCache()
{
#ifdef SUPERSERVER
return true;
#else
return false;
#endif
}
bool Config::getSharedDatabase()
{
#ifdef SUPERSERVER
return false;
#else
return true;
#endif
}
bool Config::getMultiClientServer()
{
// AP - absolutely wrong for superclassic assumption
// should be set by server in case of 'super' mode in it
#ifdef SUPERSERVER
return true;
#else
return false;
#endif
}

View File

@ -67,7 +67,6 @@
extern const char* GCPolicyCooperative;
extern const char* GCPolicyBackground;
extern const char* GCPolicyCombined;
extern const char* GCPolicyDefault;
extern const char* AmNative;
extern const char* AmTrusted;
@ -316,6 +315,12 @@ public:
static const char* getAuditTraceConfigFile();
static int getMaxUserTraceLogSize();
static bool getSharedCache();
static bool getSharedDatabase();
static bool getMultiClientServer();
};
#endif // COMMON_CONFIG_H

View File

@ -43,11 +43,13 @@ public:
MainStream(const char* fname, bool fExceptionOnError)
: file(fopen(fname, "rt")), l(0)
{
/*
if (!file && fExceptionOnError)
{
// config file does not exist
fatal_exception::raiseFmt("Missing configuration file: %s", fname);
}
*/
}
bool getLine(ConfigFile::String& input, unsigned int& line)

View File

@ -0,0 +1,38 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: DSqlDataTypeUtil.cpp
* DESCRIPTION: DSqlDataTypeUtil
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
*/
#include "firebird.h"
#include "../dsql/DSqlDataTypeUtil.h"
#include "../dsql/dsql.h"
#include "../dsql/metd_proto.h"
UCHAR Jrd::DSqlDataTypeUtil::maxBytesPerChar(UCHAR charSet)
{
return METD_get_charset_bpc(dsqlScratch->getTransaction(), charSet);
}
USHORT Jrd::DSqlDataTypeUtil::getDialect() const
{
return dsqlScratch->clientDialect;
}

View File

@ -0,0 +1,52 @@
/*
* PROGRAM: Dynamic SQL runtime support
* MODULE: DSqlDataTypeUtil.h
* DESCRIPTION: DSqlDataTypeUtil
*
* The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html
*
* Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation.
*
* All Rights Reserved.
* Contributor(s): ______________________________________.
*
*/
#ifndef DSQL_DSQLDATATYPEUTIL_H
#define DSQL_DSQLDATATYPEUTIL_H
#include "../jrd/DataTypeUtil.h"
namespace Jrd {
class DsqlCompilerScratch;
class DSqlDataTypeUtil : public DataTypeUtilBase
{
public:
explicit DSqlDataTypeUtil(DsqlCompilerScratch* aDsqlScratch)
: dsqlScratch(aDsqlScratch)
{
}
public:
virtual UCHAR maxBytesPerChar(UCHAR charSet);
virtual USHORT getDialect() const;
private:
DsqlCompilerScratch* dsqlScratch;
};
} // namespace
#endif // DSQL_DSQLDATATYPEUTIL_H

View File

@ -40,6 +40,7 @@
#include "../dsql/metd_proto.h"
#include "../dsql/pass1_proto.h"
#include "../dsql/utld_proto.h"
#include "../dsql/DSqlDataTypeUtil.h"
#include "../jrd/DataTypeUtil.h"
using namespace Firebird;

View File

@ -99,6 +99,7 @@
#include "../jrd/why_proto.h"
#include "../common/utils_proto.h"
#include "../dsql/DdlNodes.h"
#include "../dsql/DSqlDataTypeUtil.h"
#include "../common/StatusArg.h"
#ifdef DSQL_DEBUG

View File

@ -49,6 +49,7 @@
#include "../dsql/metd_proto.h"
#include "../dsql/misc_func.h"
#include "../dsql/utld_proto.h"
#include "../dsql/DSqlDataTypeUtil.h"
#include "../jrd/DataTypeUtil.h"
#include "../jrd/jrd.h"
#include "../jrd/ods.h"

View File

@ -38,6 +38,13 @@ namespace Jrd {
class dsql_req;
class dsql_str;
class DsqlCompilerScratch;
class jrd_tra;
class dsql_intlsym;
class dsql_fld;
class dsql_udf;
class dsql_nod;
class dsql_prc;
class dsql_rel;
};
void METD_drop_charset(Jrd::jrd_tra*, const Firebird::MetaName&);

View File

@ -160,6 +160,7 @@
#include "../dsql/misc_func.h"
#include "../dsql/pass1_proto.h"
#include "../dsql/utld_proto.h"
#include "../dsql/DSqlDataTypeUtil.h"
#include "../jrd/dsc_proto.h"
#include "../jrd/intl_proto.h"
#include "../jrd/jrd_proto.h"

View File

@ -40,9 +40,6 @@
#include "../jrd/constants.h"
#include "../dsql/utld_proto.h"
#include "../jrd/gds_proto.h"
#if !defined(SUPERCLIENT)
#include "../dsql/metd_proto.h"
#endif
#include "../common/classes/init.h"
using namespace Jrd;
@ -1071,17 +1068,3 @@ static void xsqlvar_to_sqlvar(const XSQLVAR* xsqlvar, SQLVAR* sqlvar)
}
}
#if !defined(SUPERCLIENT)
UCHAR DSqlDataTypeUtil::maxBytesPerChar(UCHAR charSet)
{
return METD_get_charset_bpc(dsqlScratch->getTransaction(), charSet);
}
USHORT DSqlDataTypeUtil::getDialect() const
{
return dsqlScratch->clientDialect;
}
#endif

View File

@ -27,10 +27,6 @@
#ifndef DSQL_UTLD_PROTO_H
#define DSQL_UTLD_PROTO_H
#if !defined(SUPERCLIENT)
#include "../jrd/DataTypeUtil.h"
#endif
struct sqlda_sup;
USHORT UTLD_char_length_to_byte_length(USHORT lengthInChars, USHORT maxBytesPerChar);
@ -42,31 +38,4 @@ void UTLD_save_status_strings(ISC_STATUS*);
SCHAR* UTLD_skip_sql_info(SCHAR*);
#if !defined(SUPERCLIENT)
namespace Jrd {
class DsqlCompilerScratch;
class DSqlDataTypeUtil : public DataTypeUtilBase
{
public:
explicit DSqlDataTypeUtil(DsqlCompilerScratch* aDsqlScratch)
: dsqlScratch(aDsqlScratch)
{
}
public:
virtual UCHAR maxBytesPerChar(UCHAR charSet);
virtual USHORT getDialect() const;
private:
DsqlCompilerScratch* dsqlScratch;
};
} // namespace
#endif
#endif // DSQL_UTLD_PROTO_H

View File

@ -74,4 +74,8 @@
#define TRUSTED_AUTH
#endif
#if defined(SUPERSERVER)
#define SHARED_METADATA_CACHE
#endif
#endif /* INCLUDE_Firebird_H */

View File

@ -165,9 +165,7 @@ public:
SLONG att_remote_pid; // Process id of remote client
Firebird::PathName att_remote_process; // Process name of remote client
RandomGenerator att_random_generator; // Random bytes generator
#ifndef SUPERSERVER
Lock* att_temp_pg_lock; // temporary pagespace ID lock
#endif
DSqlCache att_dsql_cache; // DSQL cache locks
Firebird::SortedArray<void*> att_udf_pointers;
dsql_dbb* att_dsql_instance;

View File

@ -66,12 +66,6 @@
#include <windows.h>
#endif
#ifdef SUPERSERVER
static const bool SHARED_DBB = true;
#else
static const bool SHARED_DBB = false;
#endif
using namespace Firebird;
using namespace Jrd;
@ -915,7 +909,7 @@ void DatabaseSnapshot::putDatabase(const Database* database, Writer& writer, int
writer.putRecord(record);
putStatistics(database->dbb_stats, writer, stat_id, stat_database);
if (SHARED_DBB)
if (Config::getSharedDatabase())
{
putMemoryUsage(database->dbb_memory_stats, writer, stat_id, stat_database);
}
@ -990,7 +984,7 @@ bool DatabaseSnapshot::putAttachment(thread_db* tdbb, const Jrd::Attachment* att
writer.putRecord(record);
putStatistics(attachment->att_stats, writer, stat_id, stat_attachment);
if (SHARED_DBB)
if (Config::getSharedDatabase())
{
putMemoryUsage(attachment->att_memory_stats, writer, stat_id, stat_attachment);
}

View File

@ -33,6 +33,7 @@
#include "../common/classes/init.h"
#include "../common/config/config.h"
#include "../common/config/config_file.h"
#include "../common/utils_proto.h"
#include "../config/ScanDir.h"
using namespace Firebird;
@ -79,9 +80,14 @@ void PluginManager::initialize()
#else
libraryName->assign("fb_inet_server.exe");
#endif
#elif !defined(SUPERSERVER)
PathUtils::concatPath(libraryName, Config::getRootDirectory(), "lib/libfbembed.so");
#else // WIN_NT
// This will become
// libraryName->assign(fb_utils::getPrefix(fb_utils::FB_DIR_LIB, "libfirebird.so"));
// when we start building libfirebird.so.
#ifndef SUPERSERVER
libraryName->assign(fb_utils::getPrefix(fb_utils::FB_DIR_LIB, "libfbembed.so"));
#endif
#endif // WIN_NT
PathName pluginsPath = getPluginsDirectory();
ScanDir dir(pluginsPath.c_str(), "*.conf");

View File

@ -120,11 +120,16 @@ inline bool IS_DATE_AND_TIME(const dsc d1, const dsc d2)
const unsigned MAP_LENGTH = 256;
#if defined (HPUX) && defined (SUPERSERVER)
const int MAX_RECURSION = 96;
#else
const int MAX_RECURSION = 128;
inline int maxRecusrion()
{
// RITTER - changed HP10 to HPUX
#ifdef HPUX
if (Config::getMultiClientServer())
return 96;
else
#endif
return 128;
}
const unsigned MAX_REQUEST_SIZE = 10485760; // 10 MB - just to be safe
@ -864,10 +869,10 @@ jrd_req* CMP_find_request(thread_db* tdbb, USHORT id, USHORT which)
for (int n = 1; true; n++)
{
if (n > MAX_RECURSION)
if (n > maxRecusrion())
{
ERR_post(Arg::Gds(isc_no_meta_update) <<
Arg::Gds(isc_req_depth_exceeded) << Arg::Num(MAX_RECURSION));
Arg::Gds(isc_req_depth_exceeded) << Arg::Num(maxRecusrion()));
// Msg363 "request depth exceeded. (Recursive definition?)"
}
jrd_req* clone = CMP_clone_request(tdbb, request, n, false);

View File

@ -79,18 +79,10 @@
*/
#ifdef SUPERSERVER
#define SWEEP_THREAD
#define GARBAGE_THREAD
#endif
#ifdef SUPERSERVER
#define FB_ARCHITECTURE isc_info_db_class_server_access
#else
#define FB_ARCHITECTURE isc_info_db_class_classic_access
#endif
/*****************************************************
* Linux platforms
*****************************************************/

View File

@ -42,13 +42,10 @@
#include "../jrd/dbg_proto.h"
#include "../jrd/err_proto.h"
#ifdef SUPERSERVER
#include "../jrd/err_proto.h"
#endif
using namespace Jrd;
// Given pointer a field in the block, find the block
#define BLOCK(fld_ptr, type, fld) (type)((SCHAR*) fld_ptr - OFFSET (type, fld))

View File

@ -653,7 +653,7 @@ SLONG DPM_data_pages(thread_db* tdbb, jrd_rel* relation)
}
CCH_RELEASE(tdbb, &window);
#ifdef SUPERSERVER
#ifdef SHARED_METADATA_CACHE
relPages->rel_data_pages = pages;
#endif
}

View File

@ -227,12 +227,15 @@ static void stuff_stack_trace(const jrd_req*);
// macro definitions
#if (defined SUPERSERVER) && (defined WIN_NT)
const size_t MAX_CLONES = 750;
#else
const size_t MAX_CLONES = 1000;
inline size_t maxClones()
{
#ifdef WIN_NT
if (Config::getMultiClientServer())
return 750;
else
#endif
return 1000;
}
const int ALL_TRIGS = 0;
const int PRE_TRIG = 1;
@ -687,7 +690,7 @@ jrd_req* EXE_find_request(thread_db* tdbb, jrd_req* request, bool validate)
}
}
if (count > MAX_CLONES)
if (count > maxClones())
{
ERR_post(Arg::Gds(isc_req_max_clones_exceeded));
}

View File

@ -87,14 +87,6 @@
#include <fcntl.h>
#endif
#ifdef UNIX
#if (defined SUPERSERVER) || (defined SOLARIS)
#include <sys/mman.h>
#include <sys/resource.h>
#include "../jrd/err_proto.h"
#endif
#endif
#include "../common/config/config.h"
#include "gen/sql_code.h"
@ -365,9 +357,9 @@ const char* const FB_TMP_ENV = "FIREBIRD_TMP";
// be printed in. However, this means buffer should be large enough to contain
// any ULONG (11 bytes) and thus prevent a buffer overflow. If minlen >= 11,
// then buffer should have be of size = (minlen + 1).
void gds__ulstr(char* buffer, ULONG value, const int minlen, const char filler)
void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler)
{
ULONG n = value;
FB_UINT64 n = value;
int c = 0;
do {
@ -1140,26 +1132,16 @@ void API_ROUTINE gds__trace(const TEXT* text)
*p++ = ' ';
ULONG apid =
#ifdef WIN_NT
#ifdef SUPERSERVER
GetCurrentThreadId();
#else
GetCurrentProcessId();
#endif
#else
getpid();
#endif
gds__ulstr(p, apid, 5, ' ');
p += 5;
*p++ = ' ';
#if (defined(WIN_NT) && !defined(SUPERSERVER))
ULONG atid = GetCurrentThreadId();
if (apid != atid) // For superclassic
{
gds__ulstr(p, atid, 5, ' ');
p += 5;
*p++ = ' ';
}
#endif
gds__ulstr(p, getThreadId(), 5, ' ');
p += 5;
*p++ = ' ';
strcpy(p, text);
p += strlen(p);
strcat(p, "\n");

View File

@ -128,7 +128,7 @@ SINT64 API_ROUTINE isc_portable_integer(const UCHAR*, SSHORT);
// 14-June-2004. Nickolay Samofatov. The routines below are not part of the
// API and are not exported. Maybe use another prefix like GDS_ for them?
void gds__cleanup();
void gds__ulstr(char* buffer, ULONG value, const int minlen, const char filler);
void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler);
void FB_EXPORTED gds__default_printer(void*, SSHORT, const TEXT*);
void gds__trace_printer(void*, SSHORT, const TEXT*);

View File

@ -788,7 +788,9 @@ void INF_database_info(const UCHAR* items,
break;
case isc_info_db_class:
length = INF_convert(FB_ARCHITECTURE, buffer);
length = INF_convert(dbb->dbb_config->getSharedDatabase() ?
isc_info_db_class_classic_access :
isc_info_db_class_server_access, buffer);
break;
case frb_info_att_charset:

View File

@ -1016,49 +1016,6 @@ void ISC_expand_share(tstring& file_name)
}
#endif // WIN_NT
#ifdef NOT_USED_OR_REPLACED
// There's no signature for this function in any header file.
#ifdef SUPERSERVER
int ISC_strip_extension(TEXT* file_name)
{
/**************************************
*
* I S C _ s t r i p _ e x t e n s i o n ( S U P E R S E R V E R )
*
**************************************
*
* Functional description
* Get rid of the file name extension part
* (after the dot '.')
*
**************************************/
// Set p to point to the starting part of the actual file name (sans directory name)
TEXT* p = strrchr(file_name, '/');
TEXT* q = strrchr(file_name, '\\');
if (p || q)
{
// Get the maximum of the two
if (q > p)
p = q;
}
else
p = file_name;
// Now search for the first dot in the actual file name
q = strchr(p, '.');
if (q)
*q = '\0'; // Truncate the extension including the dot
return strlen(file_name);
}
#endif
#endif
#if (!defined NO_NFS || defined FREEBSD || defined NETBSD)
static void expand_filename2(tstring& buff, bool expand_mounts)

View File

@ -1084,7 +1084,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
if (dbb->dbb_filename.empty())
{
#if defined(DEV_BUILD) && defined(SUPERSERVER)
#if defined(DEV_BUILD) && defined(SHARED_METADATA_CACHE)
// make sure we do not reopen same DB twice
for (Database* d = databases; d; d = d->dbb_next)
{
@ -1132,7 +1132,7 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
if (options.dpb_set_page_buffers)
{
#ifdef SUPERSERVER
#ifdef SHARED_METADATA_CACHE
// 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.
@ -1288,7 +1288,6 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
SHUT_online(tdbb, options.dpb_online);
}
#ifdef SUPERSERVER
// Check if another attachment has or is requesting exclusive database access.
// If this is an implicit attachment for the security (password) database, don't
// try to get exclusive attachment to avoid a deadlock condition which happens
@ -1314,7 +1313,6 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
ERR_post(Arg::Gds(isc_shutdown) << Arg::Str(file_name));
}
}
#endif
// If database is shutdown then kick 'em out.
@ -1435,12 +1433,14 @@ ISC_STATUS GDS_ATTACH_DATABASE(ISC_STATUS* user_status,
if (options.dpb_set_page_buffers)
{
#ifdef SUPERSERVER
validateAccess(attachment);
#else
if (dbb->dbb_config->getSharedCache())
{
validateAccess(attachment);
}
if (attachment->locksmith())
#endif
{
PAG_set_page_buffers(tdbb, options.dpb_page_buffers);
}
}
if (options.dpb_set_db_readonly)
@ -4454,13 +4454,7 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt)
}
tdbb->tdbb_quantum = (tdbb->tdbb_quantum <= 0) ?
#ifdef SUPERSERVER
(quantum ? quantum : (ThreadPriorityScheduler::boosted() ?
Config::getPriorityBoost() : 1) * QUANTUM) :
#else
(quantum ? quantum : QUANTUM) :
#endif
tdbb->tdbb_quantum;
(quantum ? quantum : QUANTUM) : tdbb->tdbb_quantum;
return false;
}
@ -4788,15 +4782,16 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
dpb_set_page_buffers = true;
break;
#ifndef SUPERSERVER
case isc_dpb_num_buffers:
dpb_buffers = rdr.getInt();
if (dpb_buffers < 10)
if (!Config::getSharedCache())
{
ERR_post(Arg::Gds(isc_bad_dpb_content));
dpb_buffers = rdr.getInt();
if (dpb_buffers < 10)
{
ERR_post(Arg::Gds(isc_bad_dpb_content));
}
}
break;
#endif
case isc_dpb_page_size:
dpb_page_size = (USHORT) rdr.getInt();
@ -5153,7 +5148,7 @@ static Database* init(thread_db* tdbb,
// Check to see if the database is already actively attached
#ifdef SUPERSERVER
#ifdef SHARED_METADATA_CACHE
for (dbb = databases; dbb; dbb = dbb->dbb_next)
{
if (!(dbb->dbb_flags & (DBB_bugcheck | DBB_not_in_use)) &&
@ -5200,19 +5195,10 @@ static Database* init(thread_db* tdbb,
else if (gc_policy == GCPolicyCombined) {
dbb->dbb_flags |= DBB_gc_cooperative | DBB_gc_background;
}
else // config value is invalid, use default
else // config value is invalid
{
if (GCPolicyDefault == GCPolicyCooperative) {
dbb->dbb_flags |= DBB_gc_cooperative;
}
else if (GCPolicyDefault == GCPolicyBackground) {
dbb->dbb_flags |= DBB_gc_background;
}
else if (GCPolicyDefault == GCPolicyCombined) {
dbb->dbb_flags |= DBB_gc_cooperative | DBB_gc_background;
}
else
fb_assert(false);
// this shoudl not happen - means bug in config
fb_assert(false);
}
}
@ -5370,8 +5356,7 @@ static void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
dbb->dbb_extManager.closeAttachment(tdbb, attachment);
#ifdef SUPERSERVER
if (dbb->dbb_relations)
if (dbb->dbb_config->getSharedCache() && dbb->dbb_relations)
{
vec<jrd_rel*>& rels = *dbb->dbb_relations;
for (size_t i = 1; i < rels.count(); i++)
@ -5384,7 +5369,6 @@ static void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
}
}
}
#endif
if (dbb->dbb_event_mgr && attachment->att_event_session)
{
@ -5394,10 +5378,10 @@ static void release_attachment(thread_db* tdbb, Jrd::Attachment* attachment)
if (attachment->att_id_lock)
LCK_release(tdbb, attachment->att_id_lock);
#ifndef SUPERSERVER
if (attachment->att_temp_pg_lock)
LCK_release(tdbb, attachment->att_temp_pg_lock);
#ifndef SHARED_METADATA_CACHE
DSqlCache::Accessor accessor(&attachment->att_dsql_cache);
for (bool getResult = accessor.getFirst(); getResult; getResult = accessor.getNext())
{

View File

@ -76,47 +76,33 @@ static void set_lock_attachment(Lock*, Jrd::Attachment*);
// globals and macros
#ifdef SUPERSERVER
inline LOCK_OWNER_T LCK_OWNER_ID_DBB(thread_db* tdbb)
{
return (LOCK_OWNER_T) getpid() << 32 | tdbb->getDatabase()->dbb_lock_owner_id;
}
inline LOCK_OWNER_T LCK_OWNER_ID_ATT(thread_db* tdbb)
{
#ifdef SHARED_METADATA_CACHE
return (LOCK_OWNER_T) getpid() << 32 | tdbb->getAttachment()->att_lock_owner_id;
#else
return (LOCK_OWNER_T) getpid() << 32 | tdbb->getDatabase()->dbb_lock_owner_id;
#endif
}
inline SLONG* LCK_OWNER_HANDLE_DBB(thread_db* tdbb)
{
return &tdbb->getDatabase()->dbb_lock_owner_handle;
}
inline SLONG* LCK_OWNER_HANDLE_ATT(thread_db* tdbb)
{
#ifdef SHARED_METADATA_CACHE
return &tdbb->getAttachment()->att_lock_owner_handle;
}
#else // SUPERSERVER
inline LOCK_OWNER_T LCK_OWNER_ID_DBB(thread_db* tdbb)
{
return (LOCK_OWNER_T) getpid() << 32 | tdbb->getDatabase()->dbb_lock_owner_id;
}
inline LOCK_OWNER_T LCK_OWNER_ID_ATT(thread_db* tdbb)
{
return (LOCK_OWNER_T) getpid() << 32 | tdbb->getDatabase()->dbb_lock_owner_id;
}
inline SLONG* LCK_OWNER_HANDLE_DBB(thread_db* tdbb)
{
#else
return &tdbb->getDatabase()->dbb_lock_owner_handle;
#endif
}
inline SLONG* LCK_OWNER_HANDLE_ATT(thread_db* tdbb)
{
return &tdbb->getDatabase()->dbb_lock_owner_handle;
}
#endif // SUPERSERVER
static const bool compatibility[LCK_max][LCK_max] =

View File

@ -42,28 +42,6 @@ typedef Firebird::PathName string;
* Platform-specific root locator
*/
#ifdef SUPERSERVER
static string getRootPathFromExePath()
{
// get the pathname of the running executable
string bin_dir = fb_utils::get_process_name();
if (bin_dir.length() == 0 || bin_dir[0] != '/')
{
return "";
}
// get rid of the filename
int index = bin_dir.rfind(PathUtils::dir_sep);
bin_dir = bin_dir.substr(0, index);
// go to the parent directory
index = bin_dir.rfind(PathUtils::dir_sep, bin_dir.length());
string dir = (index ? bin_dir.substr(0, index) : bin_dir) + PathUtils::dir_sep;
return dir;
}
#endif
void ConfigRoot::osConfigRoot()
{
// Try to use value set at configure time
@ -77,15 +55,6 @@ void ConfigRoot::osConfigRoot()
return;
}
#ifdef SUPERSERVER
// Try getting the root path from the executable
root_dir = getRootPathFromExePath();
if (root_dir.hasData())
{
return;
}
#endif
// As a last resort get it from the default install directory
root_dir = install_dir + PathUtils::dir_sep;
}
@ -93,20 +62,18 @@ void ConfigRoot::osConfigRoot()
void ConfigRoot::osConfigInstallDir()
{
#ifdef SUPERSERVER
// Try getting the root path from the executable
install_dir = getRootPathFromExePath();
if (install_dir.hasData())
{
return;
}
#elif defined(ENABLE_BINRELOC)
#ifdef ENABLE_BINRELOC
BrInitError brError;
if (br_init_lib(&brError))
{
string temp;
PathUtils::splitLastComponent(install_dir, temp, br_find_exe_dir(FB_PREFIX));
return;
char *temp = br_find_exe_dir(NULL);
if (temp)
{
string dummy;
PathUtils::splitLastComponent(install_dir, dummy, temp);
free(temp);
return;
}
}
#endif

View File

@ -100,8 +100,22 @@ bool get_user_home(int user_id, PathName& homeDir)
return false;
}
// runuser/rungroup
static const char* const FIREBIRD = "firebird";
namespace {
// runuser/rungroup
const char* const FIREBIRD = "firebird";
// change ownership and access of file
void changeFileRights(const char* pathname, const mode_t mode)
{
uid_t uid = geteuid() == 0 ? get_user_id(FIREBIRD) : -1;
gid_t gid = get_user_group_id(FIREBIRD);
while (chown(pathname, uid, gid) < 0 && SYSCALL_INTERRUPTED(errno))
;
while (chmod(pathname, mode) < 0 && SYSCALL_INTERRUPTED(errno))
;
}
} // anonymous namespace
// create directory for lock files and set appropriate access rights
void createLockDirectory(const char* pathname)
@ -139,16 +153,7 @@ void createLockDirectory(const char* pathname)
(Arg::Gds(isc_lock_dir_access) << pathname).raise();
}
#ifndef SUPERSERVER
uid_t uid = geteuid() == 0 ? get_user_id(FIREBIRD) : -1;
gid_t gid = get_user_group_id(FIREBIRD);
while (chown(pathname, uid, gid) < 0 && SYSCALL_INTERRUPTED(errno))
;
#endif //SUPERSERVER
const mode_t mode = 0770;
while (chmod(pathname, mode) < 0 && SYSCALL_INTERRUPTED(errno))
;
changeFileRights(pathname, 0770);
}
// open (or create if missing) and set appropriate access rights
@ -172,16 +177,7 @@ int openCreateSharedFile(const char* pathname, int flags)
return -1;
}
#ifndef SUPERSERVER
uid_t uid = geteuid() == 0 ? get_user_id(FIREBIRD) : -1;
gid_t gid = get_user_group_id(FIREBIRD);
while (fchown(fd, uid, gid) < 0 && SYSCALL_INTERRUPTED(errno))
;
#endif //SUPERSERVER
const mode_t mode = 0660;
while (fchmod(fd, mode) < 0 && SYSCALL_INTERRUPTED(errno))
;
changeFileRights(pathname, 0660);
}
return fd;

View File

@ -2175,36 +2175,40 @@ void PageManager::releaseLocks()
USHORT PageManager::getTempPageSpaceID(thread_db* tdbb)
{
USHORT result;
#ifdef SUPERSERVER
result = TEMP_PAGE_SPACE;
#else
SET_TDBB(tdbb);
Database* dbb = tdbb->getDatabase();
Jrd::Attachment* att = tdbb->getAttachment();
if (!att->att_temp_pg_lock)
if (Config::getSharedDatabase())
{
Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock();
lock->lck_type = LCK_page_space;
lock->lck_owner_handle = LCK_get_owner_handle(tdbb, lock->lck_type);
lock->lck_parent = dbb->dbb_lock;
lock->lck_length = sizeof(SLONG);
lock->lck_dbb = dbb;
PAG_attachment_id(tdbb);
while (true)
SET_TDBB(tdbb);
Database* dbb = tdbb->getDatabase();
Jrd::Attachment* att = tdbb->getAttachment();
if (!att->att_temp_pg_lock)
{
const double tmp = rand() * (MAX_USHORT - TEMP_PAGE_SPACE - 1.0) / (RAND_MAX + 1.0);
lock->lck_key.lck_long = static_cast<SLONG>(tmp) + TEMP_PAGE_SPACE + 1;
if (LCK_lock(tdbb, lock, LCK_write, LCK_NO_WAIT))
break;
Lock* lock = FB_NEW_RPT(*dbb->dbb_permanent, sizeof(SLONG)) Lock();
lock->lck_type = LCK_page_space;
lock->lck_owner_handle = LCK_get_owner_handle(tdbb, lock->lck_type);
lock->lck_parent = dbb->dbb_lock;
lock->lck_length = sizeof(SLONG);
lock->lck_dbb = dbb;
PAG_attachment_id(tdbb);
while (true)
{
const double tmp = rand() * (MAX_USHORT - TEMP_PAGE_SPACE - 1.0) / (RAND_MAX + 1.0);
lock->lck_key.lck_long = static_cast<SLONG>(tmp) + TEMP_PAGE_SPACE + 1;
if (LCK_lock(tdbb, lock, LCK_write, LCK_NO_WAIT))
break;
}
att->att_temp_pg_lock = lock;
}
att->att_temp_pg_lock = lock;
result = (USHORT) att->att_temp_pg_lock->lck_key.lck_long;
}
else
{
result = TEMP_PAGE_SPACE;
}
result = (USHORT) att->att_temp_pg_lock->lck_key.lck_long;
#endif
if (!this->findPageSpace(result)) {
attach_temp_pages(tdbb, result);

View File

@ -728,18 +728,25 @@ static const serv_entry services[] =
// The SERVER_CAPABILITIES_FLAG is used to mark architectural
// differences across servers. This allows applications like server
// manager to disable features as necessary.
#ifdef SUPERSERVER
const ULONG SERVER_CAPABILITIES = REMOTE_HOP_SUPPORT | MULTI_CLIENT_SUPPORT | SERVER_CONFIG_SUPPORT;
# ifdef WIN_NT
const ULONG SERVER_CAPABILITIES_FLAG = SERVER_CAPABILITIES | QUOTED_FILENAME_SUPPORT;
# else
const ULONG SERVER_CAPABILITIES_FLAG = SERVER_CAPABILITIES | NO_SERVER_SHUTDOWN_SUPPORT;
# endif // WIN_NT
#else // SUPERSERVER
const ULONG SERVER_CAPABILITIES_FLAG = REMOTE_HOP_SUPPORT | NO_SERVER_SHUTDOWN_SUPPORT;
#endif // SERVER_CAPABILITIES
namespace {
inline ULONG getServerCapabilities()
{
ULONG val = REMOTE_HOP_SUPPORT
#ifdef WIN_NT
| QUOTED_FILENAME_SUPPORT
#endif // WIN_NT
;
if (Config::getMultiClientServer())
{
val |= MULTI_CLIENT_SUPPORT;
}
else
{
val |= NO_SERVER_SHUTDOWN_SUPPORT;
}
return val;
}
}
Service::Service(const TEXT* service_name, USHORT spb_length, const UCHAR* spb_data)
: svc_parsed_sw(getPool()),
@ -1268,7 +1275,6 @@ ISC_STATUS Service::query2(thread_db* tdbb,
}
break;
#ifdef SUPERSERVER
case isc_info_svc_dump_pool_info:
{
char fname[MAXPATHLEN];
@ -1280,7 +1286,6 @@ ISC_STATUS Service::query2(thread_db* tdbb,
fname[length2] = 0;
break;
}
#endif
case isc_info_svc_get_config:
// TODO: iterate through all integer-based config values
@ -1319,7 +1324,7 @@ ISC_STATUS Service::query2(thread_db* tdbb,
if (!ck_space_for_numeric(info, end))
return 0;
*info++ = item;
ADD_SPB_NUMERIC(info, SERVER_CAPABILITIES_FLAG);
ADD_SPB_NUMERIC(info, getServerCapabilities());
break;
case isc_info_svc_running:
@ -1692,7 +1697,6 @@ void Service::query(USHORT send_item_length,
// need_admin_privs(status, "isc_info_svc_get_env");
break;
#ifdef SUPERSERVER
case isc_info_svc_dump_pool_info:
{
char fname[MAXPATHLEN];
@ -1704,7 +1708,6 @@ void Service::query(USHORT send_item_length,
fname[length2] = 0;
break;
}
#endif
/*
case isc_info_svc_get_config:
// TODO: iterate through all integer-based config values
@ -1747,7 +1750,7 @@ void Service::query(USHORT send_item_length,
case isc_info_svc_capabilities:
// bitmask defining any specific architectural differences
length = INF_convert(SERVER_CAPABILITIES_FLAG, buffer);
length = INF_convert(getServerCapabilities(), buffer);
info = INF_put_item(item, length, buffer, info, end);
if (!info)
return;

View File

@ -64,7 +64,7 @@ const ULONG REMOTE_HOP_SUPPORT = 0x4L; // Server can connect to other server
//const ULONG NO_FORCED_WRITE_SUPPORT = 0x40L; // Can not configure sync writes
//const ULONG NO_SHUTDOWN_SUPPORT = 0x80L; // Can not shutdown/restart databases
const ULONG NO_SERVER_SHUTDOWN_SUPPORT = 0x100L; // Can not shutdown server
const ULONG SERVER_CONFIG_SUPPORT = 0x200L; // Can configure server
//const ULONG SERVER_CONFIG_SUPPORT = 0x200L; // Can configure server
const ULONG QUOTED_FILENAME_SUPPORT = 0x400L; // Can pass quoted filenames in
// Range definitions for service actions. Any action outside of

View File

@ -864,7 +864,6 @@ void API_ROUTINE isc_set_login(const UCHAR** dpb, SSHORT* dpb_size)
* or password already referenced).
*
**************************************/
#ifndef SUPERSERVER
// look for the environment variables
@ -914,7 +913,6 @@ void API_ROUTINE isc_set_login(const UCHAR** dpb, SSHORT* dpb_size)
}
else if (password.length() && !password_seen)
isc_expand_dpb_internal(dpb, dpb_size, isc_dpb_password, password.c_str(), 0);
#endif
}

View File

@ -3047,9 +3047,7 @@ bool VIO_sweep(thread_db* tdbb, jrd_tra* transaction)
if (--tdbb->tdbb_quantum < 0) {
JRD_reschedule(tdbb, SWEEP_QUANTUM, true);
}
#ifdef SUPERSERVER
transaction->tra_oldest_active = dbb->dbb_oldest_snapshot;
#endif
}
--relation->rel_sweep_count;
--relation->rel_scan_count;

View File

@ -191,7 +191,8 @@ LockManager::LockManager(const Firebird::string& id, RefPtr<Config> conf)
m_dbId(getPool(), id),
m_config(conf),
m_acquireSpins(m_config->getLockAcquireSpins()),
m_memorySize(m_config->getLockMemSize())
m_memorySize(m_config->getLockMemSize()),
m_useBlockingThread(m_config->getSharedDatabase())
#ifdef USE_SHMEM_EXT
, m_extents(getPool())
#endif
@ -221,16 +222,17 @@ LockManager::~LockManager()
if (m_process)
{
#ifdef USE_BLOCKING_THREAD
// Wait for AST thread to start (or 5 secs)
m_startupSemaphore.tryEnter(5);
if (m_useBlockingThread)
{
// Wait for AST thread to start (or 5 secs)
m_startupSemaphore.tryEnter(5);
// Wakeup the AST thread - it might be blocking
ISC_event_post(&m_process->prc_blocking);
// Wakeup the AST thread - it might be blocking
ISC_event_post(&m_process->prc_blocking);
// Wait for the AST thread to finish cleanup or for 5 seconds
m_cleanupSemaphore.tryEnter(5);
#endif
// Wait for the AST thread to finish cleanup or for 5 seconds
m_cleanupSemaphore.tryEnter(5);
}
#if defined HAVE_MMAP || defined WIN_NT
ISC_unmap_object(localStatus, (UCHAR**) &m_process, sizeof(prc));
@ -1773,21 +1775,22 @@ bool LockManager::create_process(Arg::StatusVector& statusVector)
if (!m_process)
return false;
#ifdef USE_BLOCKING_THREAD
const ULONG status = gds__thread_start(blocking_action_thread, this, THREAD_high, 0, 0);
if (status)
if (m_useBlockingThread)
{
statusVector << Arg::Gds(isc_lockmanerr) << Arg::Gds(isc_sys_request) <<
const ULONG status = gds__thread_start(blocking_action_thread, this, THREAD_high, 0, 0);
if (status)
{
statusVector << Arg::Gds(isc_lockmanerr) << Arg::Gds(isc_sys_request) <<
#ifdef WIN_NT
Arg::Str("CreateThread") <<
Arg::Windows(status);
Arg::Str("CreateThread") <<
Arg::Windows(status);
#else
Arg::Str("thr_create") <<
Arg::Unix(status);
Arg::Str("thr_create") <<
Arg::Unix(status);
#endif
return false;
return false;
}
}
#endif
return true;
}

View File

@ -107,10 +107,6 @@ const UCHAR PLATFORM_LHB_VERSION = 0; // 32-bit target
const UCHAR LHB_VERSION = PLATFORM_LHB_VERSION + BASE_LHB_VERSION;
#ifndef SUPERSERVER
#define USE_BLOCKING_THREAD
#endif
#ifdef DEV_BUILD
#define VALIDATE_LOCK_TABLE
#endif
@ -438,8 +434,10 @@ private:
Firebird::string m_dbId;
Firebird::RefPtr<Config> m_config;
// configurations parameters - cached values
const ULONG m_acquireSpins;
const ULONG m_memorySize;
bool m_useBlockingThread;
#ifdef WIN_NT
struct mtx m_shmemMutex;

View File

@ -361,7 +361,6 @@ static Firebird::GlobalPtr<Firebird::Mutex> init_mutex;
static volatile bool INET_initialized = false;
static volatile bool INET_shutting_down = false;
static slct_t INET_select = { 0, 0, 0 };
static int INET_max_clients;
static rem_port* inet_async_receive = NULL;
@ -966,23 +965,6 @@ rem_port* INET_server(SOCKET sock)
return port;
}
void INET_set_clients( int count)
{
/**************************************
*
* I N E T _ s e t _ c l i e n t s
*
**************************************
*
* Functional description
* Set maxinum number of clients served before
* starting new server
*
**************************************/
INET_max_clients = (count && count < MAXCLIENTS) ? count : MAXCLIENTS;
}
static bool accept_connection(rem_port* port, const P_CNCT* cnct)
{
/**************************************

View File

@ -36,7 +36,6 @@ rem_port* INET_analyze(const Firebird::PathName&, ISC_STATUS*, const TEXT*, cons
rem_port* INET_connect(const TEXT*, struct packet*, ISC_STATUS*, USHORT, Firebird::ClumpletReader*);
rem_port* INET_reconnect(SOCKET, ISC_STATUS*);
rem_port* INET_server(SOCKET);
void INET_set_clients(int);
void setStopMainThread(FPTR_INT func);
#endif // REMOTE_INET_PROTO_H

View File

@ -69,9 +69,10 @@
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#include <errno.h>
#include "../jrd/ibase.h"
#include "../jrd/jrd_pwd.h"
@ -101,30 +102,17 @@
#include "../common/classes/semaphore.h"
#ifdef UNIX
const char* TEMP_DIR = "/tmp";
#define CHANGE_DIR chdir
#endif
#ifdef SUPERSERVER
const char* INTERBASE_USER_NAME = "interbase";
const char* INTERBASE_USER_SHORT = "interbas";
const char* FIREBIRD_USER_NAME = "firebird";
#endif
static void set_signal(int, void (*)(int));
static void signal_handler(int);
#ifdef SUPERSERVER
static int shutdownInetServer(const int reason, const int, void*);
static void shutdownInit();
static int tryStopMainThread();
#endif
static TEXT protocol[128];
static int INET_SERVER_start = 0;
static USHORT INET_SERVER_flag = 0;
static bool serverClosing = false;
@ -153,20 +141,29 @@ int FB_EXPORTED server_main( int argc, char** argv)
// std::set_terminate (__gnu_cxx::__verbose_terminate_handler);
//#endif
// We should support 3 modes:
// 1. Standalone single-process listener (like SS).
// 2. Standalone listener, forking on each packet accepted (loke -s switch in CS).
// 3. Process spawned by (x)inetd (like CS).
bool classic = false;
bool standaloneClassic = false;
bool super = false;
// It's very easy to detect that we are spawned - just check fd 0 to be a socket.
const int channel = 0;
struct stat stat0;
if (fstat(channel, &stat0) == 0 && S_ISSOCK(stat0.st_mode))
{
// classic server mode
classic = true;
}
const TEXT* const* const end = argc + argv;
argv++;
bool debug = false, standalone = false;
INET_SERVER_flag = 0;
int channel = 0;
bool debug = false;
USHORT INET_SERVER_flag = 0;
protocol[0] = 0;
bool multi_client = false, multi_threaded = false;
#ifdef SUPERSERVER
INET_SERVER_flag |= SRVR_multi_client;
multi_client = multi_threaded = standalone = true;
#endif
int clients = 0;
bool done = false;
while (argv < end)
@ -179,96 +176,114 @@ int FB_EXPORTED server_main( int argc, char** argv)
switch (UPPER(c))
{
case 'D':
INET_SERVER_flag |= SRVR_debug;
debug = standalone = true;
break;
#ifndef SUPERSERVER
case 'M':
INET_SERVER_flag |= SRVR_multi_client;
if (argv < end)
{
if (clients = atoi(*argv))
argv++;
}
multi_client = standalone = true;
debug = true;
break;
case 'S':
standalone = true;
if (!classic)
{
standaloneClassic = true;
}
break;
case 'I':
standalone = false;
if (!classic)
{
standaloneClassic = false;
}
break;
case 'T':
multi_threaded = true;
break;
case 'U':
multi_threaded = false;
break;
#endif // SUPERSERVER
case 'E':
if (ISC_set_prefix(p, *argv) == -1)
printf("Invalid argument Ignored\n");
if (argv < end)
{
if (ISC_set_prefix(p, *argv) == -1)
printf("Invalid argument Ignored\n");
else
argv++; // do not skip next argument if this one is invalid
}
else
argv++; // do not skip next argument if this one is invalid
{
printf("Missing argument, switch -E ignored\n");
}
done = true;
break;
case 'P':
fb_utils::snprintf(protocol, sizeof(protocol), "/%s", *argv++);
if (argv < end)
{
if (!classic)
{
fb_utils::snprintf(protocol, sizeof(protocol), "/%s", *argv++);
}
else
{
gds__log("Switch -P ignored in CS mode\n");
}
}
else
{
printf("Missing argument, switch -P ignored\n");
}
break;
case 'H':
case '?':
printf("Firebird TCP/IP server options are:\n");
printf(" -d : debug on\n");
#ifndef SUPERSERVER
// These options are not applicable to super server
printf(" -m : multiclient - on\n");
printf(" -s : standalone - true\n");
printf(" -i : standalone - false\n");
printf(" -t : multithread - true (non pc only)\n");
printf(" -u : multithread - false (pc only)\n");
printf(" -t : multithread (non pc only\n");
#endif
printf(" -p<protocol> : specify protocol\n");
printf(" -h|? : print this help\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");
printf("\n");
printf(" (The following -e options used to be -h options)\n");
printf(" -e <firebird_root_dir> : set firebird_root path\n");
printf(" -el <firebird_lock_dir> : set runtime firebird_lock dir\n");
printf(" -em <firebird_msg_dir> : set firebird_msg dir path\n");
printf(" -z : print version\n");
exit(FINI_OK);
case 'Z':
printf("Firebird TCP/IP server version %s\n", GDS_VERSION);
exit(FINI_OK);
default:
printf("Unknown switch `%c', ignored\n", c);
break;
}
if (done)
break;
}
}
if (!(classic || standaloneClassic))
{
INET_SERVER_flag |= SRVR_multi_client;
super = true;
}
if (debug)
{
INET_SERVER_flag |= SRVR_debug;
}
gds__log("modes are c=%d sac=%d s=%d", classic, standaloneClassic, super);
// activate paths set with -e family of switches
ISC_set_prefix(0, 0);
#ifdef UNIX
// ignore some signals
set_signal(SIGPIPE, signal_handler);
set_signal(SIGUSR1, signal_handler);
set_signal(SIGUSR2, signal_handler);
#endif
#if defined(UNIX) && defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT)
// First of all change directory to tmp
if (chdir(TEMP_DIR))
{
// error on changing the directory
gds__log("Could not change directory to %s due to errno %d", TEMP_DIR, errno);
}
#if defined(HAVE_SETRLIMIT) && defined(HAVE_GETRLIMIT)
#if !(defined(DEV_BUILD))
if (Config::getBugcheckAbort())
#endif
@ -287,17 +302,10 @@ int FB_EXPORTED server_main( int argc, char** argv)
{
gds__log("getrlimit() failed, errno=%d", errno);
}
// we need some writable directory for core file
// on any unix /tmp seems to be the best place
if (CHANGE_DIR(TEMP_DIR))
{
// error on changing the directory
gds__log("Could not change directory to %s due to errno %d", TEMP_DIR, errno);
}
}
#if defined(SUPERSERVER) && (defined SOLARIS || defined HPUX || defined LINUX)
#if (defined SOLARIS || defined HPUX || defined LINUX)
if (super)
{
// Increase max open files to hard limit for Unix
// platforms which are known to have low soft limits.
@ -322,88 +330,49 @@ int FB_EXPORTED server_main( int argc, char** argv)
}
}
}
#endif
#endif // Unix platforms
#endif
#endif // HAVE_*ETRLIMIT
// Fork off a server, wait for it to die, then fork off another,
// but give up after 100 tries
#ifndef SUPERSERVER
if (multi_client && !debug)
{
#ifdef UNIX
set_signal(SIGUSR1, signal_handler);
#endif
int child;
for (int n = 0; n < 100; n++)
{
INET_SERVER_start = 0;
if (!(child = fork()))
break;
while (wait(0) != child)
if (INET_SERVER_start)
{
n = 0; // reset error counter on "real" signal
break;
}
gds__log("INET_SERVER/main: gds_inet_server restarted");
}
#ifdef UNIX
set_signal(SIGUSR1, SIG_DFL);
#endif
}
#endif
if (standalone)
{
if (multi_client)
{
#ifdef SUPERSERVER
// Remove restriction on username, for DEV builds
// restrict only for production builds. MOD 21-July-2002
// Remove restriction on username, for DEV builds
// restrict only for production builds. MOD 21-July-2002
#ifndef DEV_BUILD
Firebird::string user_name; // holds the user name
// check user id
ISC_get_user(&user_name, NULL, NULL, NULL);
Firebird::string user_name; // holds the user name
// check user id
ISC_get_user(&user_name, NULL, NULL, NULL);
if (user_name != "root" &&
user_name != FIREBIRD_USER_NAME &&
user_name != INTERBASE_USER_NAME &&
user_name != INTERBASE_USER_SHORT)
{
// invalid user -- bail out
fprintf(stderr, "%s: Invalid user (must be %s, %s, %s or root).\n",
"fbserver", FIREBIRD_USER_NAME,
INTERBASE_USER_NAME, INTERBASE_USER_SHORT);
exit(STARTUP_ERROR);
}
#endif
#else
if (setreuid(0, 0) < 0)
printf("Inet_server: couldn't set uid to superuser.\n");
#endif
INET_set_clients(clients);
}
if (!debug)
{
int mask = 0; // FD_ZERO(&mask);
mask |= 1 << 2; // FD_SET(2, &mask);
divorce_terminal(mask);
}
{ // scope block
ISC_STATUS_ARRAY status_vector;
port = INET_connect(protocol, 0, status_vector, INET_SERVER_flag, 0);
if (!port)
{
gds__print_status(status_vector);
exit(STARTUP_ERROR);
}
} // end scope block
if (user_name != "root" &&
user_name != FIREBIRD_USER_NAME &&
user_name != INTERBASE_USER_NAME &&
user_name != INTERBASE_USER_SHORT)
{
// invalid user -- bail out
fprintf(stderr, "%s: Invalid user (must be %s, %s, %s or root).\n",
"fbserver", FIREBIRD_USER_NAME,
INTERBASE_USER_NAME, INTERBASE_USER_SHORT);
exit(STARTUP_ERROR);
}
else
#endif
if (!(debug || classic))
{
int mask = 0; // FD_ZERO(&mask);
mask |= 1 << 2; // FD_SET(2, &mask);
divorce_terminal(mask);
}
if (super || standaloneClassic)
{
ISC_STATUS_ARRAY status_vector;
port = INET_connect(protocol, 0, status_vector, INET_SERVER_flag, 0);
if (!port)
{
gds__print_status(status_vector);
exit(STARTUP_ERROR);
}
}
if (classic)
{
port = INET_server(channel);
if (!port)
@ -413,20 +382,13 @@ int FB_EXPORTED server_main( int argc, char** argv)
}
}
#ifdef SUPERSERVER
// before starting the superserver stuff change directory to tmp
if (CHANGE_DIR(TEMP_DIR))
if (super)
{
// error on changing the directory
gds__log("Could not change directory to %s due to errno %d", TEMP_DIR, errno);
}
// Server tries to attach to security2.fdb to make sure everything is OK
// This code fixes bug# 8429 + all other bug of that kind - from
// now on the server exits if it cannot attach to the database
// (wrong or no license, not enough memory, etc.
// Server tries to attach to security2.fdb to make sure everything is OK
// This code fixes bug# 8429 + all other bug of that kind - from
// now on the server exits if it cannot attach to the database
// (wrong or no license, not enough memory, etc.
{ // scope
TEXT path[MAXPATHLEN];
ISC_STATUS_ARRAY status;
isc_db_handle db_handle = 0L;
@ -449,9 +411,6 @@ int FB_EXPORTED server_main( int argc, char** argv)
}
} // end scope
shutdownInit();
#endif
SRVR_multi_thread(port, INET_SERVER_flag);
#ifdef DEBUG_GDS_ALLOC
@ -475,7 +434,7 @@ int FB_EXPORTED server_main( int argc, char** argv)
return FINI_OK;
}
}
} // extern "C"
static void set_signal( int signal_number, void (*handler) (int))
@ -517,69 +476,3 @@ static void signal_handler(int)
++INET_SERVER_start;
}
#ifdef SUPERSERVER
static int shutdownInetServer(const int reason, const int, void*)
{
/****************************************************
*
* s h u t d o w n I n e t S e r v e r
*
****************************************************
*
* Functional description
* In order to avoid blocking of the thread,
* which received SIGTERM, run in separate thread.
*
**************************************/
if (serverClosing)
{
// Ready to die
return FB_SUCCESS;
}
serverClosing = true;
// shutdown main thread - send self-signal to close select()
// in main thread and wait for it to get into safe state
#ifdef UNIX
kill(getpid(), SIGUSR1);
#else
need a way to interrupt select in main listener thread in windows
#endif
// shutdown will be completed in main thread if it's not due to exit() called
return reason == fb_shutrsn_exit_called ? FB_SUCCESS : FB_FAILURE;
}
static void shutdownInit()
{
setStopMainThread(tryStopMainThread);
ISC_STATUS_ARRAY status;
fb_shutdown_callback(status, shutdownInetServer, fb_shut_postproviders, 0);
if (status[0] == 1 && status[1] > 0)
{
gds__log_status("Error in shutdownInit()", status);
isc_print_status(status);
exit(STARTUP_ERROR);
}
}
static int tryStopMainThread()
{
/****************************************************
*
* t r y S t o p M a i n T h r e a d
*
****************************************************
*
* Functional description
* Called by main thread to test is not shutdown started.
*
**************************************/
return serverClosing ? 1 : 0;
}
#endif

View File

@ -1931,15 +1931,18 @@ void rem_port::disconnect(PACKET* sendL, PACKET* receiveL)
while (transaction = rdb->rdb_transactions)
{
if (!transaction->rtr_limbo)
{
isc_rollback_transaction(status_vector, &transaction->rtr_handle);
#ifdef SUPERSERVER
// The underlying JRD subsystem will release all
// memory resources related to a limbo transaction
// as a side-effect of the database detach call below.
// However, the y-valve handle must be released.
}
else
{
// The underlying JRD subsystem will release all
// memory resources related to a limbo transaction
// as a side-effect of the database detach call below.
// However, the y-valve handle must be released.
fb_disconnect_transaction(status_vector, &transaction->rtr_handle);
#endif
}
release_transaction(rdb->rdb_transactions);
}
isc_detach_database(status_vector, &rdb->rdb_handle);
@ -4953,14 +4956,17 @@ ISC_STATUS rem_port::start_transaction(P_OP operation, P_STTR * stuff, PACKET* s
{
object = 0;
if (operation != op_reconnect)
{
isc_rollback_transaction(status_vector, &handle);
#ifdef SUPERSERVER
// Note that there is an underlying transaction pool
// that won't be released until this connection is
// detached. At least release the y-valve handle.
}
else
{
// Note that there is an underlying transaction pool
// that won't be released until this connection is
// detached. At least release the y-valve handle.
fb_disconnect_transaction(status_vector, &handle);
#endif
}
status_vector[0] = isc_arg_gds;
status_vector[1] = isc_too_many_handles;
status_vector[2] = isc_arg_end;