8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-02-02 10:00:38 +01:00

Added first parameter IStatus* to a lot of functions in API interfaces

This commit is contained in:
alexpeshkoff 2014-07-02 12:57:12 +00:00
parent d9b465b824
commit a9721f18e0
38 changed files with 946 additions and 588 deletions

View File

@ -205,19 +205,22 @@ int FB_CARG CryptKeyHolder::keyCallback(IStatus* status, ICryptKeyCallback* call
status->init();
if (key != 0)
{
return 1;
}
IConfig* def = config->getDefaultConfig();
IConfigEntry* confEntry = def->find("Auto");
IConfig* def = config->getDefaultConfig(status);
if (!status->isSuccess())
return 1;
IConfigEntry* confEntry = def->find(status, "Auto");
def->release();
if (!status->isSuccess())
return 1;
if (confEntry)
{
char v = *(confEntry->getValue());
FB_BOOLEAN b = confEntry->getBoolValue();
confEntry->release();
if (v == '1' || v == 'y' || v == 'Y' || v == 't' || v == 'T')
if (b)
{
key = 0x5a;
return 1;
@ -256,11 +259,19 @@ public:
return &module;
}
IPluginBase* FB_CARG createPlugin(IPluginConfig* factoryParameter)
IPluginBase* FB_CARG createPlugin(IStatus* status, IPluginConfig* factoryParameter)
{
CryptKeyHolder* p = new CryptKeyHolder(factoryParameter);
p->addRef();
return p;
try
{
CryptKeyHolder* p = new CryptKeyHolder(factoryParameter);
p->addRef();
return p;
}
catch(const Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
};

View File

@ -200,9 +200,15 @@ void FB_CARG DbCrypt::setKey(IStatus* status, unsigned int length, IKeyHolderPlu
if (key != 0)
return;
IConfig* def = config->getDefaultConfig();
IConfigEntry* confEntry = def->find("Auto");
IConfig* def = config->getDefaultConfig(status);
if (!status->isSuccess())
return;
IConfigEntry* confEntry = def->find(status, "Auto");
def->release();
if (!status->isSuccess())
return;
if (confEntry)
{
char v = *(confEntry->getValue());
@ -218,14 +224,10 @@ void FB_CARG DbCrypt::setKey(IStatus* status, unsigned int length, IKeyHolderPlu
{
ICryptKeyCallback* callback = sources[n]->keyHandle(status, "sample");
if (!status->isSuccess())
{
return;
}
if (callback && callback->callback(0, NULL, 1, &key) == 1)
{
return;
}
}
key = 0;
@ -245,11 +247,19 @@ public:
return &module;
}
IPluginBase* FB_CARG createPlugin(IPluginConfig* factoryParameter)
IPluginBase* FB_CARG createPlugin(IStatus* status, IPluginConfig* factoryParameter)
{
DbCrypt* p = new DbCrypt(factoryParameter);
p->addRef();
return p;
try
{
DbCrypt* p = new DbCrypt(factoryParameter);
p->addRef();
return p;
}
catch(const Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
};

View File

@ -28,6 +28,7 @@
#include "firebird.h"
#include "../auth/AuthDbg.h"
#include "../jrd/ibase.h"
#include "../common/StatusHolder.h"
#ifdef AUTH_DEBUG
@ -55,9 +56,12 @@ extern "C" void FB_PLUGIN_ENTRY_POINT(Firebird::IMaster* master)
namespace Auth {
DebugServer::DebugServer(Firebird::IPluginConfig* pConf)
: str(getPool()),
config(Firebird::REF_NO_INCR, pConf->getDefaultConfig())
{ }
: str(getPool())
{
Firebird::LocalStatus s;
config.assignRefNoIncr(pConf->getDefaultConfig(&s));
check(&s);
}
int FB_CARG DebugServer::authenticate(Firebird::IStatus* status, IServerBlock* sb,
IWriter* writerInterface)
@ -94,14 +98,19 @@ int FB_CARG DebugServer::authenticate(Firebird::IStatus* status, IServerBlock* s
#ifdef AUTH_VERBOSE
fprintf(stderr, "DebugServer::authenticate2: %s\n", str.c_str());
#endif
writerInterface->add(str.c_str());
Firebird::LocalStatus s;
writerInterface->add(&s, str.c_str());
check(&s);
str.erase();
Firebird::RefPtr<Firebird::IConfigEntry> group(Firebird::REF_NO_INCR, config->find("GROUP"));
Firebird::RefPtr<Firebird::IConfigEntry> group(Firebird::REF_NO_INCR, config->find(&s, "GROUP"));
check(&s);
if (group)
{
writerInterface->add(group->getValue());
writerInterface->setType("GROUP");
writerInterface->add(&s, group->getValue());
check(&s);
writerInterface->setType(&s, "GROUP");
check(&s);
}
return AUTH_SUCCESS;

View File

@ -56,8 +56,12 @@ class SrpManagement FB_FINAL : public Firebird::StdPlugin<IManagement, FB_AUTH_M
{
public:
explicit SrpManagement(Firebird::IPluginConfig* par)
: config(Firebird::REF_NO_INCR, par->getFirebirdConf()), upCount(0), delCount(0)
{ }
: upCount(0), delCount(0)
{
Firebird::LocalStatus s;
config.assignRefNoIncr(par->getFirebirdConf(&s));
check(&s);
}
private:
void prepareDataStructures()
@ -497,8 +501,10 @@ public:
stmt->free(status);
check(status);
user->admin()->set(0);
user->admin()->setEntered(1);
user->admin()->set(status, 0);
check(status);
user->admin()->setEntered(status, 1);
check(status);
grantRevokeAdmin(user, true);
}
catch (const Firebird::Exception&)
@ -556,18 +562,17 @@ public:
while (rs->fetchNext(status, di.getBuffer()))
{
check(status);
listField(user->userName(), login);
listField(user->firstName(), first);
listField(user->middleName(), middle);
listField(user->lastName(), last);
listField(status, user->comment(), comment);
listField(status, user->attributes(), attr);
listField(user->comment(), comment);
listField(user->attributes(), attr);
listField(user->active(), active);
listField(user->admin(), admin);
callback->list(user);
callback->list(status, user);
check(status);
}
check(status);
@ -796,49 +801,58 @@ private:
static void listField(Auth::ICharUserField* to, Varfield& from)
{
to->setEntered(from.null ? 0 : 1);
Firebird::LocalStatus st;
to->setEntered(&st, from.null ? 0 : 1);
check(&st);
if (!from.null)
{
to->set(from);
to->set(&st, from);
check(&st);
}
}
static void listField(Auth::IIntUserField* to, Boolean& from)
{
to->setEntered(from.null ? 0 : 1);
Firebird::LocalStatus st;
to->setEntered(&st, from.null ? 0 : 1);
check(&st);
if (!from.null)
{
to->set(from);
to->set(&st, from);
check(&st);
}
}
void listField(Firebird::IStatus* st, Auth::ICharUserField* to, Blob& from)
void listField(Auth::ICharUserField* to, Blob& from)
{
to->setEntered(from.null ? 0 : 1);
Firebird::LocalStatus st;
to->setEntered(&st, from.null ? 0 : 1);
check(&st);
if (!from.null)
{
Firebird::string s;
Firebird::IBlob* blob = NULL;
try
{
blob = att->openBlob(st, tra, &from);
check(st);
blob = att->openBlob(&st, tra, &from);
check(&st);
char segbuf[256];
unsigned len;
while ( (len = blob->getSegment(st, sizeof(segbuf), segbuf)) )
while ( (len = blob->getSegment(&st, sizeof(segbuf), segbuf)) )
{
if (st->get()[1] != isc_segment)
check(st);
if (st.get()[1] != isc_segment)
check(&st);
s.append(segbuf, len);
}
if (st->get()[1] != isc_segstr_eof)
check(st);
if (st.get()[1] != isc_segstr_eof)
check(&st);
blob->close(st);
check(st);
blob->close(&st);
check(&st);
to->set(s.c_str());
to->set(&st, s.c_str());
check(&st);
}
catch (const Firebird::Exception&)
{

View File

@ -57,8 +57,12 @@ public:
: server(NULL), data(getPool()), account(getPool()),
clientPubKey(getPool()), serverPubKey(getPool()),
verifier(getPool()), salt(getPool()), sessionKey(getPool()),
config(REF_NO_INCR, par->getFirebirdConf()), secDbName(NULL)
{ }
secDbName(NULL)
{
Firebird::LocalStatus s;
config.assignRefNoIncr(par->getFirebirdConf(&s));
check(&s);
}
// IServer implementation
int FB_CARG authenticate(IStatus* status, IServerBlock* sBlock, IWriter* writerInterface);
@ -266,8 +270,16 @@ int SrpServer::authenticate(IStatus* status, IServerBlock* sb, IWriter* writerIn
if (clientProof == serverProof)
{
MasterInterfacePtr()->upgradeInterface(writerInterface, FB_AUTH_WRITER_VERSION, upInfo);
writerInterface->add(account.c_str());
writerInterface->setDb(secDbName);
writerInterface->add(status, account.c_str());
if (!status->isSuccess())
{
return AUTH_FAILED;
}
writerInterface->setDb(status, secDbName);
if (!status->isSuccess())
{
return AUTH_FAILED;
}
return AUTH_SUCCESS;
}
}

View File

@ -40,6 +40,7 @@
#include "../auth/SecurityDatabase/LegacyManagement.h"
#include "../common/classes/ImplementHelper.h"
#include "../common/classes/ClumpletWriter.h"
#include "../common/StatusHolder.h"
#include "firebird/Plugin.h"
static Firebird::MakeUpgradeInfo<> upInfo;
@ -105,8 +106,12 @@ static unsigned int secDbKey = INIT_KEY;
namespace Auth {
SecurityDatabaseManagement::SecurityDatabaseManagement(Firebird::IPluginConfig* par)
: config(Firebird::REF_NO_INCR, par->getFirebirdConf()), database(0), transaction(0)
{ }
: database(0), transaction(0)
{
Firebird::LocalStatus s;
config.assignRefNoIncr(par->getFirebirdConf(&s));
check(&s);
}
void FB_CARG SecurityDatabaseManagement::start(Firebird::IStatus* st, ILogonInfo* logonInfo)
{
@ -535,8 +540,10 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
if (!ret && !found)
ret = GsecMsg22; // gsec - record not found for user:
user->admin()->set(0);
user->admin()->setEntered(1);
user->admin()->set(st, 0);
check(st);
user->admin()->setEntered(st, 1);
check(st);
if (ret == 0 && !grantRevokeAdmin(isc_status, database, transaction, user))
{
ret = GsecMsg24;
@ -550,7 +557,11 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
found = false;
if (!user->userName()->entered())
{
Firebird::LocalStatus s2;
Firebird::IStatus* s = st;
FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
try
{
{
Firebird::string attr, a1, a2, a3;
@ -564,22 +575,37 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
a3.printf("GroupName=%s\n", U.PLG$GROUP_NAME);
attr = a1 + a2 + a3;
user->attributes()->set(attr.c_str());
user->attributes()->setEntered(attr.hasData() ? 1 : 0);
user->attributes()->set(s, attr.c_str());
check(s);
user->attributes()->setEntered(s, attr.hasData() ? 1 : 0);
check(s);
}
user->userName()->set(U.PLG$USER_NAME);
user->userName()->setEntered(U.PLG$USER_NAME.NULL ? 0 : 1);
user->password()->set("");
user->password()->setEntered(0);
user->firstName()->set(U.PLG$FIRST_NAME);
user->firstName()->setEntered(U.PLG$FIRST_NAME.NULL ? 0 : 1);
user->middleName()->set(U.PLG$MIDDLE_NAME);
user->middleName()->setEntered(U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
user->lastName()->set(U.PLG$LAST_NAME);
user->lastName()->setEntered(U.PLG$LAST_NAME.NULL ? 0 : 1);
user->userName()->set(s, U.PLG$USER_NAME);
check(s);
user->userName()->setEntered(s, U.PLG$USER_NAME.NULL ? 0 : 1);
check(s);
user->password()->set(s, "");
check(s);
user->password()->setEntered(s, 0);
check(s);
user->firstName()->set(s, U.PLG$FIRST_NAME);
check(s);
user->firstName()->setEntered(s, U.PLG$FIRST_NAME.NULL ? 0 : 1);
check(s);
user->middleName()->set(s, U.PLG$MIDDLE_NAME);
check(s);
user->middleName()->setEntered(s, U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
check(s);
user->lastName()->set(s, U.PLG$LAST_NAME);
check(s);
user->lastName()->setEntered(s, U.PLG$LAST_NAME.NULL ? 0 : 1);
check(s);
user->admin()->set(0);
user->admin()->set(s, 0);
check(s);
user->admin()->setEntered(s, 1);
check(s);
FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request2)
P IN RDB$USER_PRIVILEGES
@ -587,24 +613,39 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
P.RDB$RELATION_NAME EQ 'RDB$ADMIN' AND
P.RDB$PRIVILEGE EQ 'M'
{
user->admin()->set(1);
user->admin()->set(s, 1);
}
END_FOR
check(s);
callback->list(user);
callback->list(s, user);
check(s);
found = true;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(s);
s = &s2;
}
END_FOR
ON_ERROR
ret = GsecMsg28; // gsec - find/display record error
END_ERROR;
// real error raise - out of gpre's FOR loop
check(st);
}
else
{
Firebird::string attr, a1, a2, a3;
Firebird::LocalStatus s2;
Firebird::IStatus* s = st;
FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request) U IN PLG$VIEW_USERS
WITH U.PLG$USER_NAME EQ user->userName()->get()
try
{
if (!U.PLG$UID.NULL)
a1.printf("Uid=%d\n", U.PLG$UID);
@ -615,21 +656,37 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
a3.printf("GroupName=%s\n", U.PLG$GROUP_NAME);
attr = a1 + a2 + a3;
user->attributes()->set(attr.c_str());
user->attributes()->setEntered(attr.hasData() ? 1 : 0);
user->attributes()->set(s, attr.c_str());
check(s);
user->attributes()->setEntered(s, attr.hasData() ? 1 : 0);
check(s);
user->userName()->set(U.PLG$USER_NAME);
user->userName()->setEntered(U.PLG$USER_NAME.NULL ? 0 : 1);
user->password()->set("");
user->password()->setEntered(0);
user->firstName()->set(U.PLG$FIRST_NAME);
user->firstName()->setEntered(U.PLG$FIRST_NAME.NULL ? 0 : 1);
user->middleName()->set(U.PLG$MIDDLE_NAME);
user->middleName()->setEntered(U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
user->lastName()->set(U.PLG$LAST_NAME);
user->lastName()->setEntered(U.PLG$LAST_NAME.NULL ? 0 : 1);
user->userName()->set(s, U.PLG$USER_NAME);
check(s);
user->userName()->setEntered(s, U.PLG$USER_NAME.NULL ? 0 : 1);
check(s);
user->password()->set(s, "");
check(s);
user->password()->setEntered(s, 0);
check(s);
user->firstName()->set(s, U.PLG$FIRST_NAME);
check(s);
user->firstName()->setEntered(s, U.PLG$FIRST_NAME.NULL ? 0 : 1);
check(s);
user->middleName()->set(s, U.PLG$MIDDLE_NAME);
check(s);
user->middleName()->setEntered(s, U.PLG$MIDDLE_NAME.NULL ? 0 : 1);
check(s);
user->lastName()->set(s, U.PLG$LAST_NAME);
check(s);
user->lastName()->setEntered(s, U.PLG$LAST_NAME.NULL ? 0 : 1);
check(s);
user->admin()->set(s, 0);
check(s);
user->admin()->setEntered(s, 1);
check(s);
user->admin()->set(0);
FOR (TRANSACTION_HANDLE transaction REQUEST_HANDLE request2)
P IN RDB$USER_PRIVILEGES
@ -637,17 +694,28 @@ int FB_CARG SecurityDatabaseManagement::execute(Firebird::IStatus* st, IUser* us
P.RDB$RELATION_NAME EQ 'RDB$ADMIN' AND
P.RDB$PRIVILEGE EQ 'M'
{
user->admin()->set(1);
user->admin()->set(s, 1);
}
END_FOR
check(s);
callback->list(user);
callback->list(s, user);
check(s);
found = true;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(s);
s = &s2;
}
END_FOR
ON_ERROR
ret = GsecMsg28; // gsec - find/display record error
END_ERROR;
// real error raise - out of gpre's FOR loop
check(st);
}
break;

View File

@ -349,9 +349,12 @@ int SecurityDatabase::verify(IWriter* authBlock, IServerBlock* sBlock)
}
}
LocalStatus s;
MasterInterfacePtr()->upgradeInterface(authBlock, FB_AUTH_WRITER_VERSION, upInfo);
authBlock->add(login.c_str());
authBlock->setDb(secureDbName);
authBlock->add(&s, login.c_str());
check(&s);
authBlock->setDb(&s, secureDbName);
check(&s);
return AUTH_SUCCESS;
}
@ -426,7 +429,9 @@ int SecurityDatabase::shutdown()
{
if (curInstances[i])
{
TimerInterfacePtr()->stop(curInstances[i]);
LocalStatus s;
TimerInterfacePtr()->stop(&s, curInstances[i]);
check(&s);
curInstances[i]->release();
curInstances[i] = NULL;
}
@ -460,7 +465,9 @@ int SecurityDatabaseServer::authenticate(Firebird::IStatus* status, IServerBlock
{
PathName secDbName;
{ // config scope
RefPtr<IFirebirdConf> config(REF_NO_INCR, iParameter->getFirebirdConf());
LocalStatus s;
RefPtr<IFirebirdConf> config(REF_NO_INCR, iParameter->getFirebirdConf(&s));
check(&s);
if (secDbKey == INIT_KEY)
{
@ -501,10 +508,11 @@ int SecurityDatabaseServer::authenticate(Firebird::IStatus* status, IServerBlock
int rc = instance->verify(writerInterface, sBlock);
#define USE_ATT_RQ_CACHE
#ifdef USE_ATT_RQ_CACHE
TimerInterfacePtr()->start(instance, 10 * 1000 * 1000);
#else
instance->handler();
LocalStatus s;
TimerInterfacePtr()->start(&s, instance, 10 * 1000 * 1000);
if (!s.isSuccess())
#endif
instance->handler();
return rc;
}
catch (const Firebird::Exception& ex)

View File

@ -60,18 +60,25 @@ void WriterImplementation::reset()
sequence = 0;
}
void WriterImplementation::add(const char* name)
void WriterImplementation::add(Firebird::IStatus* st, const char* name)
{
putLevel();
current.clear();
current.insertString(AuthReader::AUTH_NAME, name);
fb_assert(plugin.hasData());
if (plugin.hasData())
try
{
current.insertString(AuthReader::AUTH_PLUGIN, plugin);
putLevel();
current.clear();
current.insertString(AuthReader::AUTH_NAME, name);
fb_assert(plugin.hasData());
if (plugin.hasData())
{
current.insertString(AuthReader::AUTH_PLUGIN, plugin);
}
type = "USER";
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(st);
}
type = "USER";
}
void WriterImplementation::setPlugin(const char* m)
@ -91,19 +98,33 @@ void WriterImplementation::putLevel()
result.insertBytes(sequence++, current.getBuffer(), current.getBufferLength());
}
void WriterImplementation::setType(const char* value)
void WriterImplementation::setType(Firebird::IStatus* st, const char* value)
{
if (value)
type = value;
try
{
if (value)
type = value;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(st);
}
}
void WriterImplementation::setDb(const char* value)
void WriterImplementation::setDb(Firebird::IStatus* st, const char* value)
{
if (value)
try
{
PathName target;
expandDatabaseName(value, target, NULL);
current.insertPath(AuthReader::AUTH_SECURE_DB, target);
if (value)
{
PathName target;
expandDatabaseName(value, target, NULL);
current.insertPath(AuthReader::AUTH_SECURE_DB, target);
}
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(st);
}
}

View File

@ -49,9 +49,9 @@ public:
// IWriter implementation
void FB_CARG reset();
void FB_CARG add(const char* name);
void FB_CARG setType(const char* value);
void FB_CARG setDb(const char* value);
void FB_CARG add(Firebird::IStatus* st, const char* name);
void FB_CARG setType(Firebird::IStatus* st, const char* value);
void FB_CARG setDb(Firebird::IStatus* st, const char* value);
private:
Firebird::ClumpletWriter current, result;

View File

@ -270,14 +270,6 @@ void MetadataBuilder::indexError(unsigned index, const char* functionName)
}
}
void check(IStatus* status)
{
if (!status->isSuccess())
{
status_exception::raise(status->get());
}
}
// Add an item based on a descriptor.
void MsgMetadata::addItem(const MetaName& name, bool nullable, const dsc& desc)

View File

@ -328,13 +328,15 @@ static void setAttr(string& a, const char* nm, Auth::IIntUserField* f)
}
static void setAttr(Auth::UserData* u)
static void setAttr(IStatus* status, Auth::UserData* u)
{
string attr;
setAttr(attr, "Uid", &u->u);
setAttr(attr, "Gid", &u->g);
u->attributes()->setEntered(attr.hasData());
u->attributes()->set(attr.c_str());
u->attributes()->set(status, attr.c_str());
if (!status->isSuccess())
return;
u->attributes()->setEntered(status, attr.hasData());
}
@ -472,8 +474,11 @@ void callRemoteServiceManager(ISC_STATUS* status,
if (uData.user.get()[0] && callback)
{
setAttr(&uData);
callback->list(&uData);
LocalStatus status;
setAttr(&status, &uData);
check(&status);
callback->list(&status, &uData);
check(&status);
}
}
else
@ -554,14 +559,20 @@ static void parseString2(const char*& p, Auth::CharField& f, size_t& loop)
p += sizeof(USHORT);
f.set(p, len);
f.setEntered(1);
p += len;
LocalStatus s;
f.setEntered(&s, 1);
check(&s);
}
static void parseLong(const char*& p, Auth::IntField& f, size_t& loop)
{
f.set(isc_vax_integer(p, sizeof(ULONG)));
f.setEntered(1);
LocalStatus s;
f.set(&s, isc_vax_integer(p, sizeof(ULONG)));
check(&s);
f.setEntered(&s, 1);
check(&s);
const size_t len2 = sizeof(ULONG) + 1;
if (len2 > loop)
@ -639,12 +650,16 @@ static int typeBuffer(ISC_STATUS* status, char* buf, int offset,
case isc_spb_sec_username:
if (uData.user.get()[0])
{
LocalStatus status;
if (callback)
{
setAttr(&uData);
callback->list(&uData);
setAttr(&status, &uData);
check(&status);
callback->list(&status, &uData);
check(&status);
}
uData.clear();
uData.clear(&status);
check(&status);
}
parseString2(p, uData.user, loop);
break;

View File

@ -49,12 +49,7 @@ public:
pluginSet.assignRefNoIncr(pluginInterface->getPlugins(&status, interfaceType,
(namesList ? namesList : Config::getDefaultConfig()->getPlugins(interfaceType)),
desiredVersion, ui, NULL));
if (!pluginSet)
{
fb_assert(!status.isSuccess());
status_exception::raise(status.get());
}
check(&status);
getPlugin();
}
@ -68,12 +63,7 @@ public:
pluginSet.assignRefNoIncr(pluginInterface->getPlugins(&status, interfaceType,
(namesList ? namesList : knownConfig->getPlugins(interfaceType)),
desiredVersion, ui, new FirebirdConf(knownConfig)));
if (!pluginSet)
{
fb_assert(!status.isSuccess());
status_exception::raise(status.get());
}
check(&status);
getPlugin();
}
@ -104,7 +94,10 @@ public:
{
pluginInterface->releasePlugin(currentPlugin);
currentPlugin = NULL;
pluginSet->next();
LocalStatus status;
pluginSet->next(&status);
check(&status);
getPlugin();
}
}
@ -116,7 +109,10 @@ public:
pluginInterface->releasePlugin(currentPlugin);
currentPlugin = NULL;
}
pluginSet->set(newName);
LocalStatus status;
pluginSet->set(&status, newName);
check(&status);
getPlugin();
}
@ -137,7 +133,9 @@ private:
void getPlugin()
{
currentPlugin = (P*) pluginSet->getPlugin();
LocalStatus status;
currentPlugin = (P*) pluginSet->getPlugin(&status);
check(&status);
}
};

View File

@ -145,11 +145,19 @@ template <class P>
class SimpleFactoryBase : public AutoIface<IPluginFactory, FB_PLUGIN_FACTORY_VERSION>
{
public:
IPluginBase* FB_CARG createPlugin(IPluginConfig* factoryParameter)
IPluginBase* FB_CARG createPlugin(IStatus* status, IPluginConfig* factoryParameter)
{
P* p = new P(factoryParameter);
p->addRef();
return p;
try
{
P* p = new P(factoryParameter);
p->addRef();
return p;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
};
@ -357,6 +365,16 @@ private:
};
// Generic status checker
inline void check(IStatus* status)
{
if (!status->isSuccess())
{
status_exception::raise(status->get());
}
}
// debugger for reference counters
#ifdef DEV_BUILD

View File

@ -129,7 +129,7 @@ namespace Firebird
memset(stringBuffer, c, sizeL);
}
void AbstractString::adjustRange(const size_type length, size_type& pos, size_type& n)
void AbstractString::adjustRange(const size_type length, size_type& pos, size_type& n) throw()
{
if (pos == npos) {
pos = length > n ? length - n : 0;
@ -174,7 +174,7 @@ namespace Firebird
return stringBuffer + p0;
}
void AbstractString::baseErase(size_type p0, size_type n)
void AbstractString::baseErase(size_type p0, size_type n) throw()
{
adjustRange(length(), p0, n);
memmove(stringBuffer + p0, stringBuffer + p0 + n, stringLength - (p0 + n) + 1);

View File

@ -151,7 +151,7 @@ namespace Firebird
stringBuffer[stringLength] = 0;
}
void shrinkBuffer()
void shrinkBuffer() throw()
{
// Shrink buffer if we decide it is beneficial
}
@ -200,7 +200,7 @@ namespace Firebird
}
// Trim the range making sure that it fits inside specified length
static void adjustRange(const size_type length, size_type& pos, size_type& n);
static void adjustRange(const size_type length, size_type& pos, size_type& n) throw();
pointer baseAssign(const size_type n);
@ -208,7 +208,7 @@ namespace Firebird
pointer baseInsert(const size_type p0, const size_type n);
void baseErase(size_type p0, size_type n);
void baseErase(size_type p0, size_type n) throw();
enum TrimType {TrimLeft, TrimRight, TrimBoth};
@ -511,17 +511,17 @@ namespace Firebird
insert(it - c_str(), first, last - first);
}
AbstractString& erase(size_type p0 = 0, size_type n = npos)
AbstractString& erase(size_type p0 = 0, size_type n = npos) throw()
{
baseErase(p0, n);
return *this;
}
iterator erase(iterator it)
iterator erase(iterator it) throw()
{
erase(it - c_str(), 1);
return it;
}
iterator erase(iterator first, iterator last)
iterator erase(iterator first, iterator last) throw()
{
erase(first - c_str(), last - first);
return first;

View File

@ -52,7 +52,7 @@ Get::Get(Config* firebirdConf)
}
}
void FB_CARG UserData::clear()
void FB_CARG UserData::clear(Firebird::IStatus*)
{
op = 0;

View File

@ -49,7 +49,7 @@ public:
return s;
}
void FB_CARG setEntered(int newValue)
void FB_CARG setEntered(Firebird::IStatus*, int newValue)
{
e = newValue;
}
@ -68,20 +68,27 @@ public:
return value.c_str();
}
void FB_CARG set(const char* newValue)
void FB_CARG set(Firebird::IStatus* status, const char* newValue)
{
value = newValue ? newValue : "";
try
{
value = newValue ? newValue : "";
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
void FB_CARG set(const char* newValue, size_t len)
void set(const char* newValue, size_t len)
{
value.assign(newValue, len);
}
void clear()
void clear() throw()
{
e = s = 0;
value = "";
value.erase(); // should not call allocation function - no throw
}
private:
@ -107,7 +114,7 @@ public:
return s;
}
void FB_CARG setEntered(int newValue)
void FB_CARG setEntered(Firebird::IStatus*, int newValue)
{
e = newValue;
}
@ -126,12 +133,12 @@ public:
return value;
}
void FB_CARG set(int newValue)
void FB_CARG set(Firebird::IStatus*, int newValue)
{
value = newValue;
}
void clear()
void clear() throw()
{
e = s = 0;
value = 0;
@ -200,7 +207,7 @@ public:
return &act;
}
void FB_CARG clear();
void FB_CARG clear(Firebird::IStatus* status);
typedef Firebird::Array<UCHAR> AuthenticationBlock;

View File

@ -9736,6 +9736,29 @@ void CreateAlterUserNode::print(string& text) const
name.c_str());
}
static void setCharField(Auth::CharField& field, const string* value)
{
if (value)
{
LocalStatus s;
if (value->hasData())
{
field.set(&s, value->c_str());
check(&s);
field.setEntered(&s, 1);
check(&s);
}
else
{
field.setEntered(&s, 0);
check(&s);
field.setSpecified(1);
}
}
}
void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jrd_tra* transaction)
{
if (mode != USER_ADD && !password && !firstName && !middleName && !lastName &&
@ -9764,10 +9787,14 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
}
text.upper();
Firebird::LocalStatus s;
userData->op = mode == USER_ADD ? Auth::ADD_OPER : mode == USER_MOD ?
Auth::MOD_OPER : Auth::ADDMOD_OPER;
userData->user.set(text.c_str());
userData->user.setEntered(1);
userData->user.set(&s, text.c_str());
check(&s);
userData->user.setEntered(&s, 1);
check(&s);
if (password)
{
@ -9777,76 +9804,28 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
status_exception::raise(Arg::PrivateDyn(250));
}
userData->pass.set(password->c_str());
userData->pass.setEntered(1);
setCharField(userData->pass, password);
}
if (firstName)
{
if (firstName->hasData())
{
userData->first.set(firstName->c_str());
userData->first.setEntered(1);
}
else
{
userData->first.setEntered(0);
userData->first.setSpecified(1);
}
}
if (middleName)
{
if (middleName->hasData())
{
userData->middle.set(middleName->c_str());
userData->middle.setEntered(1);
}
else
{
userData->middle.setEntered(0);
userData->middle.setSpecified(1);
}
}
if (lastName)
{
if (lastName->hasData())
{
userData->last.set(lastName->c_str());
userData->last.setEntered(1);
}
else
{
userData->last.setEntered(0);
userData->last.setSpecified(1);
}
}
if (comment)
{
if (comment->hasData())
{
userData->com.set(comment->c_str());
userData->com.setEntered(1);
}
else
{
userData->com.setEntered(0);
userData->com.setSpecified(1);
}
}
setCharField(userData->first, firstName);
setCharField(userData->middle, middleName);
setCharField(userData->last, lastName);
setCharField(userData->com, comment);
if (adminRole.specified)
{
userData->adm.set(adminRole.value);
userData->adm.setEntered(1);
userData->adm.set(&s, adminRole.value);
check(&s);
userData->adm.setEntered(&s, 1);
check(&s);
}
if (active.specified)
{
userData->act.set((int) active.value);
userData->act.setEntered(1);
userData->act.set(&s, (int) active.value);
check(&s);
userData->act.setEntered(&s, 1);
check(&s);
}
string attributesBuffer;
@ -9863,8 +9842,10 @@ void CreateAlterUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScra
if (attributesBuffer.hasData())
{
userData->attr.set(attributesBuffer.c_str());
userData->attr.setEntered(1);
userData->attr.set(&s, attributesBuffer.c_str());
check(&s);
userData->attr.setEntered(&s, 1);
check(&s);
}
const int ddlAction = mode == USER_ADD ? DDL_TRIGGER_CREATE_USER : DDL_TRIGGER_ALTER_USER;
@ -9901,9 +9882,11 @@ void DropUserNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsqlScratch, jr
string text = name.c_str();
text.upper();
Firebird::LocalStatus s;
userData->op = Auth::DEL_OPER;
userData->user.set(text.c_str());
userData->user.setEntered(1);
userData->user.set(&s, text.c_str());
userData->user.setEntered(&s, 1);
check(&s);
executeDdlTrigger(tdbb, dsqlScratch, transaction, DTW_BEFORE, DDL_TRIGGER_DROP_USER,
userData->user.get());

View File

@ -90,7 +90,7 @@ static void release_statement(DsqlCompiledStatement* statement);
static void sql_info(thread_db*, dsql_req*, ULONG, const UCHAR*, ULONG, UCHAR*);
static UCHAR* var_info(const dsql_msg*, const UCHAR*, const UCHAR* const, UCHAR*,
const UCHAR* const, USHORT, bool);
static void check(IStatus*);
static void checkD(IStatus*);
static inline bool reqTypeWithCursor(DsqlCompiledStatement::Type type)
{
@ -1286,7 +1286,7 @@ static USHORT parse_metadata(dsql_req* request, IMessageMetadata* meta,
LocalStatus st;
unsigned count = meta->getCount(&st);
check(&st);
checkD(&st);
if (count != parameters.getCount())
{
@ -1303,9 +1303,9 @@ static USHORT parse_metadata(dsql_req* request, IMessageMetadata* meta,
for (USHORT index = 0; index < count; index++)
{
unsigned sqlType = meta->getType(&st, index);
check(&st);
checkD(&st);
unsigned sqlLength = meta->getLength(&st, index);
check(&st);
checkD(&st);
dsc desc;
desc.dsc_flags = 0;
@ -1317,11 +1317,11 @@ static USHORT parse_metadata(dsql_req* request, IMessageMetadata* meta,
desc.dsc_length = dlength;
desc.dsc_scale = meta->getScale(&st, index);
check(&st);
checkD(&st);
desc.dsc_sub_type = meta->getSubType(&st, index);
check(&st);
checkD(&st);
unsigned textType = meta->getCharSet(&st, index);
check(&st);
checkD(&st);
desc.setTextType(textType);
desc.dsc_address = (UCHAR*)(IPTR) dataOffset;
@ -1357,7 +1357,7 @@ static USHORT parse_metadata(dsql_req* request, IMessageMetadata* meta,
// raise error if one present
static void check(IStatus* st)
static void checkD(IStatus* st)
{
if (!st->isSuccess())
{

View File

@ -46,9 +46,9 @@ class IWriter : public Firebird::IVersioned
{
public:
virtual void FB_CARG reset() = 0;
virtual void FB_CARG add(const char* name) = 0;
virtual void FB_CARG setType(const char* value) = 0;
virtual void FB_CARG setDb(const char* value) = 0;
virtual void FB_CARG add(Firebird::IStatus* status, const char* name) = 0;
virtual void FB_CARG setType(Firebird::IStatus* status, const char* value) = 0;
virtual void FB_CARG setDb(Firebird::IStatus* status, const char* value) = 0;
};
#define FB_AUTH_WRITER_VERSION (FB_VERSIONED_VERSION + 4)
@ -96,7 +96,7 @@ class IUserField : public Firebird::IVersioned
public:
virtual int FB_CARG entered() = 0;
virtual int FB_CARG specified() = 0;
virtual void FB_CARG setEntered(int newValue) = 0;
virtual void FB_CARG setEntered(Firebird::IStatus* status, int newValue) = 0;
};
#define FB_AUTH_FIELD_VERSION (FB_VERSIONED_VERSION + 3)
@ -104,7 +104,7 @@ class ICharUserField : public IUserField
{
public:
virtual const char* FB_CARG get() = 0;
virtual void FB_CARG set(const char* newValue) = 0;
virtual void FB_CARG set(Firebird::IStatus* status, const char* newValue) = 0;
};
#define FB_AUTH_CHAR_FIELD_VERSION (FB_AUTH_FIELD_VERSION + 2)
@ -112,7 +112,7 @@ class IIntUserField : public IUserField
{
public:
virtual int FB_CARG get() = 0;
virtual void FB_CARG set(int newValue) = 0;
virtual void FB_CARG set(Firebird::IStatus* status, int newValue) = 0;
};
#define FB_AUTH_INT_FIELD_VERSION (FB_AUTH_FIELD_VERSION + 2)
@ -134,14 +134,14 @@ public:
virtual IIntUserField* FB_CARG admin() = 0;
virtual void FB_CARG clear() = 0;
virtual void FB_CARG clear(Firebird::IStatus* status) = 0;
};
#define FB_AUTH_USER_VERSION (FB_VERSIONED_VERSION + 11)
class IListUsers : public Firebird::IVersioned
{
public:
virtual void FB_CARG list(IUser* user) = 0;
virtual void FB_CARG list(Firebird::IStatus* status, IUser* user) = 0;
};
#define FB_AUTH_LIST_USERS_VERSION (FB_VERSIONED_VERSION + 1)

View File

@ -90,9 +90,9 @@ class IPluginSet : public IRefCounted
public:
virtual const char* FB_CARG getName() const = 0;
virtual const char* FB_CARG getModuleName() const = 0;
virtual IPluginBase* FB_CARG getPlugin() = 0;
virtual void FB_CARG next() = 0;
virtual void FB_CARG set(const char*) = 0;
virtual IPluginBase* FB_CARG getPlugin(IStatus* status) = 0;
virtual void FB_CARG next(IStatus* status) = 0;
virtual void FB_CARG set(IStatus* status, const char*) = 0;
};
#define FB_PLUGIN_SET_VERSION (FB_REFCOUNTED_VERSION + 5)
@ -105,9 +105,9 @@ class IConfigEntry : public IRefCounted
public:
virtual const char* FB_CARG getName() = 0;
virtual const char* FB_CARG getValue() = 0;
virtual IConfig* FB_CARG getSubConfig() = 0;
virtual ISC_INT64 FB_CARG getIntValue() = 0;
virtual FB_BOOLEAN FB_CARG getBoolValue() = 0;
virtual IConfig* FB_CARG getSubConfig(IStatus* status) = 0;
};
#define FB_CONFIG_PARAMETER_VERSION (FB_REFCOUNTED_VERSION + 5)
@ -115,9 +115,9 @@ public:
class IConfig : public IRefCounted
{
public:
virtual IConfigEntry* FB_CARG find(const char* name) = 0;
virtual IConfigEntry* FB_CARG findValue(const char* name, const char* value) = 0;
virtual IConfigEntry* FB_CARG findPos(const char* name, unsigned int pos) = 0;
virtual IConfigEntry* FB_CARG find(IStatus* status, const char* name) = 0;
virtual IConfigEntry* FB_CARG findValue(IStatus* status, const char* name, const char* value) = 0;
virtual IConfigEntry* FB_CARG findPos(IStatus* status, const char* name, unsigned int pos) = 0;
};
#define FB_CONFIG_VERSION (FB_REFCOUNTED_VERSION + 3)
@ -144,9 +144,9 @@ class IPluginConfig : public IRefCounted
{
public:
virtual const char* FB_CARG getConfigFileName() = 0;
virtual IConfig* FB_CARG getDefaultConfig() = 0;
virtual IFirebirdConf* FB_CARG getFirebirdConf() = 0;
virtual void FB_CARG setReleaseDelay(ISC_UINT64 microSeconds) = 0;
virtual IConfig* FB_CARG getDefaultConfig(IStatus* status) = 0;
virtual IFirebirdConf* FB_CARG getFirebirdConf(IStatus* status) = 0;
virtual void FB_CARG setReleaseDelay(IStatus* status, ISC_UINT64 microSeconds) = 0;
};
#define FB_PLUGIN_CONFIG_VERSION (FB_REFCOUNTED_VERSION + 4)
@ -154,7 +154,7 @@ public:
class IPluginFactory : public IVersioned
{
public:
virtual IPluginBase* FB_CARG createPlugin(IPluginConfig* factoryParameter) = 0;
virtual IPluginBase* FB_CARG createPlugin(IStatus* status, IPluginConfig* factoryParameter) = 0;
};
#define FB_PLUGIN_FACTORY_VERSION (FB_VERSIONED_VERSION + 1)
@ -195,7 +195,7 @@ public:
const char* namesList, int desiredVersion,
UpgradeInfo* ui, IFirebirdConf* firebirdConf) = 0;
// Get generic config interface for given file
virtual IConfig* FB_CARG getConfig(const char* filename) = 0;
virtual IConfig* FB_CARG getConfig(IStatus* status, const char* filename) = 0;
// Plugins must be released using this function - use of plugin's release()
// will cause resources leak
virtual void FB_CARG releasePlugin(IPluginBase* plugin) = 0;
@ -216,20 +216,18 @@ struct FbCryptKey
typedef void PluginEntrypoint(IMaster* masterInterface);
namespace PluginType {
static const unsigned int YValve = 1;
static const unsigned int Provider = 2;
// leave space for may be some more super-std plugins
static const unsigned int FirstNonLibPlugin = 11;
static const unsigned int AuthServer = 11;
static const unsigned int AuthClient = 12;
static const unsigned int AuthUserManagement = 13;
static const unsigned int ExternalEngine = 14;
static const unsigned int Trace = 15;
static const unsigned int WireCrypt = 16;
static const unsigned int DbCrypt = 17;
static const unsigned int KeyHolder = 18;
static const unsigned int Provider = 1;
static const unsigned int FirstNonLibPlugin = 2;
static const unsigned int AuthServer = 3;
static const unsigned int AuthClient = 4;
static const unsigned int AuthUserManagement = 5;
static const unsigned int ExternalEngine = 6;
static const unsigned int Trace = 7;
static const unsigned int WireCrypt = 8;
static const unsigned int DbCrypt = 9;
static const unsigned int KeyHolder = 10;
static const unsigned int MaxType = 19; // keep in sync please
static const unsigned int MaxType = 11; // keep in sync please
}

View File

@ -41,6 +41,8 @@ class ICryptKeyCallback; // From Crypt.h
class IEventCallback : public IRefCounted
{
public:
// eventCallbackFunction is missing error status cause it's always called from places
// where an ability to report an error to the user is missing
virtual void FB_CARG eventCallbackFunction(unsigned int length, const unsigned char* events) = 0;
};
#define FB_EVENT_CALLBACK_VERSION (FB_REFCOUNTED_VERSION + 1)

View File

@ -49,9 +49,9 @@ class ITimerControl : public IVersioned
{
public:
// Set timer
virtual void FB_CARG start(ITimer* timer, TimerDelay microSeconds) = 0;
virtual void FB_CARG start(IStatus* status, ITimer* timer, TimerDelay microSeconds) = 0;
// Stop timer
virtual void FB_CARG stop(ITimer* timer) = 0;
virtual void FB_CARG stop(IStatus* status, ITimer* timer) = 0;
};
#define FB_TIMER_CONTROL_VERSION (FB_VERSIONED_VERSION + 2)

View File

@ -36,7 +36,7 @@ namespace Firebird {
class IVersionCallback : public IVersioned
{
public:
virtual void FB_CARG callback(const char* text) = 0;
virtual void FB_CARG callback(IStatus* status, const char* text) = 0;
};
#define FB_VERSION_CALLBACK_VERSION (FB_VERSIONED_VERSION + 1)

View File

@ -125,7 +125,7 @@ class VersionCallback : public Firebird::AutoIface<Firebird::IVersionCallback, F
{
public:
// IVersionCallback implementation
void FB_CARG callback(const char* text)
void FB_CARG callback(Firebird::IStatus*, const char* text)
{
isqlGlob.printf("%s%s", text, NEWLINE);
}

View File

@ -339,16 +339,20 @@ namespace Jrd
{
if (active)
{
TimerInterfacePtr()->stop(this);
active = false;
Firebird::LocalStatus s;
TimerInterfacePtr()->stop(&s, this);
if (s.isSuccess())
active = false;
}
}
void Database::Linger::set(unsigned seconds)
{
if (dbb)
if (dbb && !active)
{
TimerInterfacePtr()->start(this, seconds * 1000 * 1000);
Firebird::LocalStatus s;
TimerInterfacePtr()->start(&s, this, seconds * 1000 * 1000);
check(&s);
active = true;
}
}

View File

@ -217,8 +217,10 @@ void UserManagement::execute(USHORT id)
{
Auth::StackUserData cmd;
cmd.op = Auth::DIS_OPER;
cmd.user.set(command->userName()->get());
cmd.user.setEntered(1);
cmd.user.set(&status, command->userName()->get());
check(&status);
cmd.user.setEntered(&status, 1);
check(&status);
class OldAttributes : public Firebird::AutoIface<Auth::IListUsers, FB_AUTH_LIST_USERS_VERSION>
{
@ -228,10 +230,17 @@ void UserManagement::execute(USHORT id)
{ }
// IListUsers implementation
void FB_CARG list(Auth::IUser* data)
void FB_CARG list(IStatus* status, Auth::IUser* data)
{
value = data->attributes()->entered() ? data->attributes()->get() : "";
present = true;
try
{
value = data->attributes()->entered() ? data->attributes()->get() : "";
present = true;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
string value;
@ -305,13 +314,16 @@ void UserManagement::execute(USHORT id)
if (merged.hasData())
{
command->attr.set(merged.c_str());
command->attr.set(&status, merged.c_str());
check(&status);
}
else
{
command->attr.setEntered(0);
command->attr.setEntered(&status, 0);
check(&status);
command->attr.setSpecified(1);
command->attr.set("");
command->attr.set(&status, "");
check(&status);
}
}
}
@ -320,8 +332,10 @@ void UserManagement::execute(USHORT id)
{
if (!command->act.entered())
{
command->act.set(1);
command->act.setEntered(1);
command->act.set(&status, 1);
check(&status);
command->act.setEntered(&status, 1);
check(&status);
}
}
@ -447,10 +461,17 @@ RecordBuffer* UserManagement::getList(thread_db* tdbb, jrd_rel* relation)
{ }
// IListUsers implementation
void FB_CARG list(Auth::IUser* user)
void FB_CARG list(IStatus* status, Auth::IUser* user)
{
MasterInterfacePtr()->upgradeInterface(user, FB_AUTH_USER_VERSION, upInfo);
userManagement->list(user);
try
{
MasterInterfacePtr()->upgradeInterface(user, FB_AUTH_USER_VERSION, upInfo);
userManagement->list(user);
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
private:

View File

@ -371,16 +371,24 @@ class EngineFactory : public AutoIface<IPluginFactory, FB_PLUGIN_FACTORY_VERSION
{
public:
// IPluginFactory implementation
IPluginBase* FB_CARG createPlugin(IPluginConfig* factoryParameter)
IPluginBase* FB_CARG createPlugin(IStatus* status, IPluginConfig* factoryParameter)
{
if (myModule->unloadStarted())
try
{
return NULL;
}
if (myModule->unloadStarted())
{
Arg::Gds(isc_shutdown).raise();
}
IPluginBase* p = new JProvider(factoryParameter);
p->addRef();
return p;
IPluginBase* p = new JProvider(factoryParameter);
p->addRef();
return p;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
};
@ -6405,7 +6413,9 @@ static void setEngineReleaseDelay(Database* dbb)
++maxLinger; // avoid rounding errors
time_t t = time(NULL);
dbb->dbb_plugin_config->setReleaseDelay(maxLinger > t ? (maxLinger - t) * 1000 * 1000 : 0);
LocalStatus s;
dbb->dbb_plugin_config->setReleaseDelay(&s, maxLinger > t ? (maxLinger - t) * 1000 * 1000 : 0);
check(&s);
}

View File

@ -581,18 +581,24 @@ bool ConfigStorage::getItemLength(ITEM& tag, ULONG& len)
void FB_CARG ConfigStorage::TouchFile::handler()
{
os_utils::touchFile(fileName);
TimerInterfacePtr()->start(this, TOUCH_INTERVAL * 1000 * 1000);
LocalStatus s;
TimerInterfacePtr()->start(&s, this, TOUCH_INTERVAL * 1000 * 1000);
// ignore error in handler
}
void ConfigStorage::TouchFile::start(const char* fName)
{
fileName = fName;
TimerInterfacePtr()->start(this, TOUCH_INTERVAL * 1000 * 1000);
LocalStatus s;
TimerInterfacePtr()->start(&s, this, TOUCH_INTERVAL * 1000 * 1000);
check(&s);
}
void ConfigStorage::TouchFile::stop()
{
TimerInterfacePtr()->stop(this);
LocalStatus s;
TimerInterfacePtr()->stop(&s, this);
// ignore error in stop timer
}
int FB_CARG ConfigStorage::TouchFile::release()

View File

@ -86,7 +86,9 @@ public:
procedures(getPool()),
triggers(getPool())
{
RefPtr<IConfig> defaultConfig(REF_NO_INCR, par->getDefaultConfig());
LocalStatus s;
RefPtr<IConfig> defaultConfig(REF_NO_INCR, par->getDefaultConfig(&s));
check(&s);
if (defaultConfig)
{
@ -95,10 +97,11 @@ public:
RefPtr<IConfigEntry> icp;
for (int n = 0; icp.assignRefNoIncr(defaultConfig->findPos("path", n)); ++n)
for (int n = 0; icp.assignRefNoIncr(defaultConfig->findPos(&s, "path", n)); ++n)
{
PathName newPath(icp->getValue());
check(&s);
PathName newPath(icp->getValue());
bool found = false;
for (ObjectsArray<PathName>::iterator i = paths->begin(); i != paths->end(); ++i)

View File

@ -33,19 +33,6 @@
using namespace Firebird;
namespace
{
void checkStatus(IStatus* st)
{
if (!st->isSuccess())
{
status_exception::raise(st->get());
}
}
}
namespace Remote
{
@ -79,7 +66,7 @@ void BlrFromMessage::buildBlr(IMessageMetadata* metadata)
LocalStatus st;
expectedMessageLength = metadata->getMessageLength(&st);
checkStatus(&st);
check(&st);
getBlrData().clear();
@ -100,15 +87,15 @@ void BlrFromMessage::buildBlr(IMessageMetadata* metadata)
for (unsigned i = 0; i < count; ++i)
{
unsigned dtype = metadata->getType(&st, i) & ~1;
checkStatus(&st);
check(&st);
unsigned len = metadata->getLength(&st, i);
checkStatus(&st);
check(&st);
int scale = metadata->getScale(&st, i);
checkStatus(&st);
check(&st);
unsigned charSet = metadata->getCharSet(&st, i);
checkStatus(&st);
check(&st);
int subType = metadata->getSubType(&st, i);
checkStatus(&st);
check(&st);
switch (dtype)
{

View File

@ -139,8 +139,11 @@ static void merge(IIntUserField* to, IIntUserField* from)
return;
if (from->entered())
{
to->set(from->get());
to->setEntered(1);
Firebird::LocalStatus s;
to->set(&s, from->get());
check(&s);
to->setEntered(&s, 1);
check(&s);
}
}
@ -223,7 +226,9 @@ int gsec(Firebird::UtilSvc* uSvc)
{
serverName = "";
}
user_data->database.set(databaseName.c_str());
Firebird::LocalStatus s;
user_data->database.set(&s, databaseName.c_str());
check(&s);
Firebird::RefPtr<IManagement> manager;
ISC_STATUS_ARRAY status;
@ -398,8 +403,11 @@ int gsec(Firebird::UtilSvc* uSvc)
const Parameter* p = findParameter(name);
if (p)
{
field->set(p->asInteger());
field->setEntered(1);
Firebird::LocalStatus s;
field->set(&s, p->asInteger());
check(&s);
field->setEntered(&s, 1);
check(&s);
}
}
};
@ -412,44 +420,51 @@ int gsec(Firebird::UtilSvc* uSvc)
{ }
// IListUsers implementation
void FB_CARG list(IUser* data)
void FB_CARG list(Firebird::IStatus* status, IUser* data)
{
Attributes attr(data);
try
{
Attributes attr(data);
if (data->active()->entered() && data->active()->get() == 0)
{
// skip inactive users
return;
}
if (tdsec->utilSvc->isService())
{
tdsec->utilSvc->putLine(isc_spb_sec_username, data->userName()->get());
tdsec->utilSvc->putLine(isc_spb_sec_firstname, data->firstName()->entered() ? data->firstName()->get() : "");
tdsec->utilSvc->putLine(isc_spb_sec_middlename, data->middleName()->entered() ? data->middleName()->get() : "");
tdsec->utilSvc->putLine(isc_spb_sec_lastname, data->lastName()->entered() ? data->lastName()->get() : "");
tdsec->utilSvc->putSLong(isc_spb_sec_userid, attr["uid"]);
tdsec->utilSvc->putSLong(isc_spb_sec_groupid, attr["gid"]);
if (data->operation() == DIS_OPER)
if (data->active()->entered() && data->active()->get() == 0)
{
tdsec->utilSvc->putSLong(isc_spb_sec_admin, data->admin()->get());
}
}
else
{
if (first)
{
GSEC_message(GsecMsg26);
GSEC_message(GsecMsg27);
// msg26: " user name uid gid admin full name"
// msg27: "-------------------------------------------------------------------------------------------------"
first = false;
// skip inactive users
return;
}
util_output(false, "%-*.*s %5d %5d %-5.5s %s %s %s\n",
USERNAME_LENGTH, USERNAME_LENGTH, data->userName()->get(),
attr["uid"], attr["gid"], data->admin()->get() ? "admin" : "",
data->firstName()->get(), data->middleName()->get(), data->lastName()->get());
if (tdsec->utilSvc->isService())
{
tdsec->utilSvc->putLine(isc_spb_sec_username, data->userName()->get());
tdsec->utilSvc->putLine(isc_spb_sec_firstname, data->firstName()->entered() ? data->firstName()->get() : "");
tdsec->utilSvc->putLine(isc_spb_sec_middlename, data->middleName()->entered() ? data->middleName()->get() : "");
tdsec->utilSvc->putLine(isc_spb_sec_lastname, data->lastName()->entered() ? data->lastName()->get() : "");
tdsec->utilSvc->putSLong(isc_spb_sec_userid, attr["uid"]);
tdsec->utilSvc->putSLong(isc_spb_sec_groupid, attr["gid"]);
if (data->operation() == DIS_OPER)
{
tdsec->utilSvc->putSLong(isc_spb_sec_admin, data->admin()->get());
}
}
else
{
if (first)
{
GSEC_message(GsecMsg26);
GSEC_message(GsecMsg27);
// msg26: " user name uid gid admin full name"
// msg27: "-------------------------------------------------------------------------------------------------"
first = false;
}
util_output(false, "%-*.*s %5d %5d %-5.5s %s %s %s\n",
USERNAME_LENGTH, USERNAME_LENGTH, data->userName()->get(),
attr["uid"], attr["gid"], data->admin()->get() ? "admin" : "",
data->firstName()->get(), data->middleName()->get(), data->lastName()->get());
}
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
@ -467,12 +482,19 @@ int gsec(Firebird::UtilSvc* uSvc)
{ }
// IListUsers implementation
void FB_CARG list(IUser* data)
void FB_CARG list(Firebird::IStatus* status, IUser* data)
{
Attributes attr(data);
try
{
Attributes attr(data);
attr.set(&u->u, "uid");
attr.set(&u->g, "gid");
attr.set(&u->u, "uid");
attr.set(&u->g, "gid");
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
private:
@ -498,8 +520,10 @@ int gsec(Firebird::UtilSvc* uSvc)
if (user_data->operation() == ADD_OPER)
{
user_data->act.set(1);
user_data->act.setEntered(1);
user_data->act.set(&s, 1);
check(&s);
user_data->act.setEntered(&s, 1);
check(&s);
}
if (user_data->operation() == MOD_OPER && user_data->userName()->entered() &&
@ -507,8 +531,10 @@ int gsec(Firebird::UtilSvc* uSvc)
{
StackUserData u;
u.op = OLD_DIS_OPER;
u.user.set(user_data->userName()->get());
u.user.setEntered(1);
u.user.set(&s, user_data->userName()->get());
check(&s);
u.user.setEntered(&s, 1);
check(&s);
Callback cb(&u);
ret = manager->execute(&st, &u, &cb);
@ -539,8 +565,8 @@ int gsec(Firebird::UtilSvc* uSvc)
setAttr(attr, "uid", &user_data->u);
setAttr(attr, "gid", &user_data->g);
setAttr(attr, "groupName", &user_data->group);
user_data->attributes()->set(attr.c_str());
user_data->attributes()->setEntered(attr.hasData() ? 1 : 0);
user_data->attributes()->set(&s, attr.c_str());
user_data->attributes()->setEntered(&s, attr.hasData() ? 1 : 0);
ret = manager->execute(&st, user_data, &disp);
@ -581,7 +607,8 @@ int gsec(Firebird::UtilSvc* uSvc)
{
MOVE_CLEAR(status, sizeof(ISC_STATUS_ARRAY));
// Clear out user data each time through this loop.
user_data->clear();
user_data->clear(&s);
check(&s);
if (get_line(local_argv, stuff, sizeof(stuff)))
break;
if (local_argv.getCount() > 1)
@ -605,10 +632,14 @@ int gsec(Firebird::UtilSvc* uSvc)
continue;
}
user_data->database.set(databaseName.c_str());
user_data->database.setEntered(databaseNameEntered);
user_data->role.set(sqlRoleName.c_str());
user_data->role.setEntered(sqlRoleName.hasData());
user_data->database.set(&s, databaseName.c_str());
check(&s);
user_data->database.setEntered(&s, databaseNameEntered);
check(&s);
user_data->role.set(&s, sqlRoleName.c_str());
check(&s);
user_data->role.setEntered(&s, sqlRoleName.hasData());
check(&s);
if (ret == 0)
{
@ -739,6 +770,17 @@ static bool get_line(Firebird::UtilSvc::ArgvType& argv, TEXT* stuff, size_t maxs
}
template <typename F, typename V>
static void setSwitch(F& field, V v)
{
Firebird::LocalStatus s;
field.set(&s, v);
check(&s);
field.setEntered(&s, 1);
check(&s);
}
static bool get_switches(Firebird::UtilSvc::ArgvType& argv,
const Switches& switches,
tsec* tdsec, bool* quitflag)
@ -804,53 +846,42 @@ static bool get_switches(Firebird::UtilSvc::ArgvType& argv,
return false;
}
uname.upper();
user_data->user.set(uname.c_str());
user_data->user.setEntered(1);
setSwitch(user_data->user, uname.c_str());
break;
case IN_SW_GSEC_PASSWORD:
uname = string;
user_data->pass.set(uname.c_str());
user_data->pass.setEntered(1);
setSwitch(user_data->pass, uname.c_str());
break;
case IN_SW_GSEC_UID:
user_data->u.set(atoi(string));
user_data->u.setEntered(1);
setSwitch(user_data->u, atoi(string));
break;
case IN_SW_GSEC_GID:
user_data->g.set(atoi(string));
user_data->g.setEntered(1);
setSwitch(user_data->g, atoi(string));
break;
case IN_SW_GSEC_SYSUSER:
// ignore it
break;
case IN_SW_GSEC_GROUP:
user_data->group.set(string);
user_data->group.setEntered(1);
setSwitch(user_data->group, string);
break;
case IN_SW_GSEC_FNAME:
user_data->first.set(string);
user_data->first.setEntered(1);
setSwitch(user_data->first, string);
break;
case IN_SW_GSEC_MNAME:
user_data->middle.set(string);
user_data->middle.setEntered(1);
setSwitch(user_data->middle, string);
break;
case IN_SW_GSEC_LNAME:
user_data->last.set(string);
user_data->last.setEntered(1);
setSwitch(user_data->last, string);
break;
case IN_SW_GSEC_DATABASE:
user_data->database.set(string);
user_data->database.setEntered(1);
setSwitch(user_data->database, string);
break;
case IN_SW_GSEC_DBA_USER_NAME:
user_data->dba.set(string);
user_data->dba.setEntered(1);
setSwitch(user_data->dba, string);
break;
case IN_SW_GSEC_DBA_PASSWORD:
tdsec->utilSvc->hidePasswd(argv, argc);
user_data->dbaPassword.set(argv[argc]);
user_data->dbaPassword.setEntered(1);
setSwitch(user_data->dbaPassword, argv[argc]);
break;
case IN_SW_GSEC_FETCH_PASSWORD:
{
@ -864,13 +895,11 @@ static bool get_switches(Firebird::UtilSvc::ArgvType& argv,
// error fetching password from file
return false;
}
user_data->dbaPassword.set(passwd);
user_data->dbaPassword.setEntered(1);
setSwitch(user_data->dbaPassword, passwd);
break;
}
case IN_SW_GSEC_SQL_ROLE_NAME:
user_data->role.set(string);
user_data->role.setEntered(1);
setSwitch(user_data->role, string);
break;
case IN_SW_GSEC_MAPPING:
{
@ -896,13 +925,14 @@ static bool get_switches(Firebird::UtilSvc::ArgvType& argv,
{
Firebird::string val(string);
val.upper();
int iVal;
if (val == "YES")
{
user_data->adm.set(1);
iVal = 1;
}
else if (val == "NO") {
user_data->adm.set(0);
iVal = 0;
}
else
{
@ -910,7 +940,7 @@ static bool get_switches(Firebird::UtilSvc::ArgvType& argv,
// invalid parameter for -ADMIN, only YES or NO is accepted
return false;
}
user_data->adm.setEntered(1);
setSwitch(user_data->adm, iVal);
}
break;
case IN_SW_GSEC_Z:
@ -1360,7 +1390,9 @@ static SSHORT parse_cmd_line(Firebird::UtilSvc::ArgvType& argv, tsec* tdsec)
**************************************/
bool quitflag = false;
UserData* user_data = tdsec->tsec_user_data;
user_data->clear();
Firebird::LocalStatus s;
user_data->clear(&s);
check(&s);
// Call a subroutine to process the input line.

View File

@ -606,51 +606,65 @@ class TimerImplementation : public AutoIface<ITimerControl, FB_TIMER_CONTROL_VER
{
public:
// ITimerControl implementation
void FB_CARG start(ITimer* timer, TimerDelay microSeconds)
void FB_CARG start(IStatus* status, ITimer* timer, TimerDelay microSeconds)
{
MutexLockGuard guard(timerAccess, FB_FUNCTION);
if (stopTimerThread.value() != 0)
try
{
// Ignore an attempt to start timer - anyway thread to make it fire is down
MutexLockGuard guard(timerAccess, FB_FUNCTION);
// We must leave timerAccess mutex here to avoid deadlocks
MutexUnlockGuard ug(timerAccess, FB_FUNCTION);
if (stopTimerThread.value() != 0)
{
// Ignore an attempt to start timer - anyway thread to make it fire is down
timer->addRef();
timer->release();
return;
// We must leave timerAccess mutex here to avoid deadlocks
MutexUnlockGuard ug(timerAccess, FB_FUNCTION);
timer->addRef();
timer->release();
return;
}
timerHolder.init();
TimerEntry* curTimer = getTimer(timer);
if (!curTimer)
{
TimerEntry newTimer;
newTimer.timer = timer;
newTimer.fireTime = curTime() + microSeconds;
timerQueue->add(newTimer);
timer->addRef();
}
else
{
curTimer->fireTime = curTime() + microSeconds;
}
timerWakeup->release();
}
timerHolder.init();
TimerEntry* curTimer = getTimer(timer);
if (!curTimer)
catch(const Firebird::Exception& ex)
{
TimerEntry newTimer;
newTimer.timer = timer;
newTimer.fireTime = curTime() + microSeconds;
timerQueue->add(newTimer);
timer->addRef();
ex.stuffException(status);
}
else
{
curTimer->fireTime = curTime() + microSeconds;
}
timerWakeup->release();
}
void FB_CARG stop(ITimer* timer)
void FB_CARG stop(IStatus* status, ITimer* timer)
{
MutexLockGuard guard(timerAccess, FB_FUNCTION);
TimerEntry* curTimer = getTimer(timer);
if (curTimer)
try
{
curTimer->timer->release();
timerQueue->remove(curTimer);
MutexLockGuard guard(timerAccess, FB_FUNCTION);
TimerEntry* curTimer = getTimer(timer);
if (curTimer)
{
curTimer->timer->release();
timerQueue->remove(curTimer);
}
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
};

View File

@ -190,7 +190,7 @@ namespace
return par ? par->asInteger() : 0;
}
IConfig* FB_CARG getSubConfig();
IConfig* FB_CARG getSubConfig(IStatus* status);
int FB_CARG release()
{
@ -214,36 +214,60 @@ namespace
ConfigAccess(RefPtr<ConfigFile> c) : confFile(c) { }
// IConfig implementation
IConfigEntry* FB_CARG find(const char* name)
IConfigEntry* FB_CARG find(IStatus* status, const char* name)
{
return confFile.hasData() ? newParam(confFile->findParameter(name)) : NULL;
try
{
return confFile.hasData() ? newParam(confFile->findParameter(name)) : NULL;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
IConfigEntry* FB_CARG findValue(const char* name, const char* value)
IConfigEntry* FB_CARG findValue(IStatus* status, const char* name, const char* value)
{
return confFile.hasData() ? newParam(confFile->findParameter(name, value)) : NULL;
try
{
return confFile.hasData() ? newParam(confFile->findParameter(name, value)) : NULL;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
IConfigEntry* FB_CARG findPos(const char* name, unsigned int n)
IConfigEntry* FB_CARG findPos(IStatus* status, const char* name, unsigned int n)
{
if (!confFile.hasData())
try
{
return NULL;
}
if (!confFile.hasData())
{
return NULL;
}
const ConfigFile::Parameters& p = confFile->getParameters();
size_t pos;
if (!p.find(name, pos))
const ConfigFile::Parameters& p = confFile->getParameters();
size_t pos;
if (!p.find(name, pos))
{
return NULL;
}
if (n + pos >= p.getCount() || p[n + pos].name != name)
{
return NULL;
}
return newParam(&p[n + pos]);
}
catch(const Firebird::Exception& ex)
{
return NULL;
ex.stuffException(status);
}
if (n + pos >= p.getCount() || p[n + pos].name != name)
{
return NULL;
}
return newParam(&p[n + pos]);
return NULL;
}
int FB_CARG release()
@ -273,13 +297,20 @@ namespace
}
};
IConfig* ConfigParameterAccess::getSubConfig()
IConfig* ConfigParameterAccess::getSubConfig(IStatus* status)
{
if (par && par->sub.hasData())
try
{
IConfig* rc = new ConfigAccess(par->sub);
rc->addRef();
return rc;
if (par && par->sub.hasData())
{
IConfig* rc = new ConfigAccess(par->sub);
rc->addRef();
return rc;
}
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
@ -287,6 +318,7 @@ namespace
IConfig* findDefConfig(ConfigFile* defaultConfig, const PathName& confName)
{
Firebird::LocalStatus s;
if (defaultConfig)
{
const ConfigFile::Parameter* p = defaultConfig->findParameter("Config");
@ -295,7 +327,8 @@ namespace
return rc;
}
IConfig* rc = PluginManagerInterfacePtr()->getConfig(confName.nullStr());
IConfig* rc = PluginManagerInterfacePtr()->getConfig(&s, confName.nullStr());
check(&s);
return rc;
}
@ -362,7 +395,7 @@ namespace
return NULL;
}
const char* getName() const
const char* getName() const throw()
{
return name.nullStr();
}
@ -491,7 +524,7 @@ namespace
return findDefConfig(defaultConfig, confName);
}
const PluginModule* getPluggedModule() const
const PluginModule* getPluggedModule() const throw()
{
return module;
}
@ -505,7 +538,7 @@ namespace
return plugName.c_str();
}
void setReleaseDelay(ISC_UINT64 microSeconds)
void setReleaseDelay(ISC_UINT64 microSeconds) throw()
{
#ifdef DEBUG_PLUGINS
fprintf(stderr, "Set delay for ConfiguredPlugin %s:%p\n", plugName.c_str(), this);
@ -549,24 +582,40 @@ namespace
return configuredPlugin->getConfigFileName();
}
IConfig* FB_CARG getDefaultConfig()
IConfig* FB_CARG getDefaultConfig(IStatus* status)
{
return configuredPlugin->getDefaultConfig();
}
IFirebirdConf* FB_CARG getFirebirdConf()
{
if (!firebirdConf.hasData())
try
{
RefPtr<Config> specificConf(Config::getDefaultConfig());
firebirdConf = new FirebirdConf(specificConf);
return configuredPlugin->getDefaultConfig();
}
catch(const Exception& ex)
{
ex.stuffException(status);
return NULL;
}
firebirdConf->addRef();
return firebirdConf;
}
void FB_CARG setReleaseDelay(ISC_UINT64 microSeconds)
IFirebirdConf* FB_CARG getFirebirdConf(IStatus* status)
{
try
{
if (!firebirdConf.hasData())
{
RefPtr<Config> specificConf(Config::getDefaultConfig());
firebirdConf = new FirebirdConf(specificConf);
}
firebirdConf->addRef();
return firebirdConf;
}
catch(const Exception& ex)
{
ex.stuffException(status);
return NULL;
}
}
void FB_CARG setReleaseDelay(IStatus*, ISC_UINT64 microSeconds)
{
configuredPlugin->setReleaseDelay(microSeconds);
}
@ -589,7 +638,9 @@ namespace
fprintf(stderr, "~FactoryParameter places configuredPlugin %s in unload query for %d seconds\n",
configuredPlugin->getPlugName(), configuredPlugin->getReleaseDelay() / 1000000);
#endif
TimerInterfacePtr()->start(configuredPlugin, configuredPlugin->getReleaseDelay());
LocalStatus s;
TimerInterfacePtr()->start(&s, configuredPlugin, configuredPlugin->getReleaseDelay());
// errors are ignored here - configuredPlugin will be released at once
}
RefPtr<ConfiguredPlugin> configuredPlugin;
@ -600,14 +651,19 @@ namespace
{
FactoryParameter* par = new FactoryParameter(this, firebirdConf);
par->addRef();
IPluginBase* plugin = module->getPlugin(regPlugin).factory->createPlugin(par);
if (plugin)
Firebird::LocalStatus s;
IPluginBase* plugin = module->getPlugin(regPlugin).factory->createPlugin(&s, par);
if (s.isSuccess())
{
plugin->setOwner(par);
else
par->release();
return plugin;
}
return plugin;
par->release();
check(&s);
return NULL;
}
@ -730,15 +786,22 @@ namespace
return currentPlugin.hasData() ? currentPlugin->getPluggedModule()->getName() : NULL;
}
void FB_CARG set(const char* newName)
void FB_CARG set(IStatus* status, const char* newName)
{
namesList = newName;
namesList.alltrim(" \t");
next();
try
{
namesList = newName;
namesList.alltrim(" \t");
next(status);
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
}
IPluginBase* FB_CARG getPlugin();
void FB_CARG next();
IPluginBase* FB_CARG getPlugin(IStatus* status);
void FB_CARG next(IStatus* status);
PluginSet(unsigned int pinterfaceType, const char* pnamesList,
int pdesiredVersion, UpgradeInfo* pui,
@ -750,7 +813,9 @@ namespace
{
namesList.assign(pnamesList);
namesList.alltrim(" \t");
next();
Firebird::LocalStatus s;
next(&s);
check(&s);
}
int FB_CARG release()
@ -780,7 +845,6 @@ namespace
void loadError(const Arg::StatusVector& error)
{
iscLogStatus("PluginSet", error.value());
error.raise();
}
};
@ -788,53 +852,60 @@ namespace
// ************************************* //
// ** next() - core of plugin manager ** //
// ************************************* //
void FB_CARG PluginSet::next()
void FB_CARG PluginSet::next(IStatus* status)
{
if (currentPlugin.hasData())
try
{
currentPlugin = NULL;
if (currentPlugin.hasData())
{
currentPlugin = NULL;
}
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
while (namesList.hasData())
{
splitWord(currentName, namesList);
// First check - may be currentName is present among already configured plugins
ConfiguredPlugin* tmp = NULL;
if (plugins->get(MapKey(interfaceType, currentName), tmp))
{
currentPlugin = tmp;
break;
}
// setup loadinfo
PluginLoadInfo info(currentName.c_str());
// Check if module is loaded and load it if needed
RefPtr<PluginModule> m(modules->findModule(info.curModule));
if (!m.hasData() && !flShutdown)
{
m = loadModule(info.curModule);
}
if (!m.hasData())
{
continue;
}
int r = m->findPlugin(interfaceType, info.regName);
if (r < 0)
{
gds__log("Misconfigured: module %s does not contain plugin %s type %d",
info.curModule.c_str(), info.regName.c_str(), interfaceType);
continue;
}
currentPlugin = new ConfiguredPlugin(m, r, info.conf, info.plugConfigFile, currentName);
plugins->put(MapKey(interfaceType, currentName), currentPlugin);
return;
}
}
MutexLockGuard g(plugins->mutex, FB_FUNCTION);
while (namesList.hasData())
catch(const Firebird::Exception& ex)
{
splitWord(currentName, namesList);
// First check - may be currentName is present among already configured plugins
ConfiguredPlugin* tmp = NULL;
if (plugins->get(MapKey(interfaceType, currentName), tmp))
{
currentPlugin = tmp;
break;
}
// setup loadinfo
PluginLoadInfo info(currentName.c_str());
// Check if module is loaded and load it if needed
RefPtr<PluginModule> m(modules->findModule(info.curModule));
if (!m.hasData() && !flShutdown)
{
m = loadModule(info.curModule);
}
if (!m.hasData())
{
continue;
}
int r = m->findPlugin(interfaceType, info.regName);
if (r < 0)
{
gds__log("Misconfigured: module %s does not contain plugin %s type %d",
info.curModule.c_str(), info.regName.c_str(), interfaceType);
continue;
}
currentPlugin = new ConfiguredPlugin(m, r, info.conf, info.plugConfigFile, currentName);
plugins->put(MapKey(interfaceType, currentName), currentPlugin);
return;
ex.stuffException(status);
}
}
@ -874,25 +945,32 @@ namespace
return RefPtr<PluginModule>(NULL); // compiler warning silencer
}
IPluginBase* FB_CARG PluginSet::getPlugin()
IPluginBase* FB_CARG PluginSet::getPlugin(IStatus* status)
{
while (currentPlugin.hasData())
try
{
IPluginBase* p = currentPlugin->factory(firebirdConf);
if (p)
while (currentPlugin.hasData())
{
if (masterInterface->upgradeInterface(p, desiredVersion, ui) >= 0)
IPluginBase* p = currentPlugin->factory(firebirdConf);
if (p)
{
return p;
if (masterInterface->upgradeInterface(p, desiredVersion, ui) >= 0)
{
return p;
}
PluginManagerInterfacePtr()->releasePlugin(p);
}
PluginManagerInterfacePtr()->releasePlugin(p);
next(status);
if (!status->isSuccess())
break;
}
next();
}
//currentPlugin->addRef();
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}
@ -1027,12 +1105,20 @@ void FB_CARG PluginManager::releasePlugin(IPluginBase* plugin)
}
IConfig* FB_CARG PluginManager::getConfig(const char* filename)
IConfig* FB_CARG PluginManager::getConfig(IStatus* status, const char* filename)
{
IConfig* rc = new ConfigAccess(RefPtr<ConfigFile>(
FB_NEW(*getDefaultMemoryPool()) ConfigFile(*getDefaultMemoryPool(), filename)));
rc->addRef();
return rc;
try
{
IConfig* rc = new ConfigAccess(RefPtr<ConfigFile>(
FB_NEW(*getDefaultMemoryPool()) ConfigFile(*getDefaultMemoryPool(), filename)));
rc->addRef();
return rc;
}
catch(const Firebird::Exception& ex)
{
ex.stuffException(status);
}
return NULL;
}

View File

@ -46,7 +46,7 @@ public:
IFirebirdConf* firebirdConf);
void FB_CARG registerPluginFactory(unsigned int interfaceType, const char* defaultName,
IPluginFactory* factory);
IConfig* FB_CARG getConfig(const char* filename);
IConfig* FB_CARG getConfig(IStatus* status, const char* filename);
void FB_CARG releasePlugin(IPluginBase* plugin);
void FB_CARG registerModule(IPluginModule* module);
void FB_CARG unregisterModule(IPluginModule* module);

View File

@ -827,14 +827,18 @@ namespace {
template <typename T1, typename T2>
void copyField(T1& f, T2 from, short flag)
{
Firebird::LocalStatus s;
if (flag && from)
{
f.set(from);
f.setEntered(1);
f.set(&s, from);
check(&s);
f.setEntered(&s, 1);
check(&s);
}
else
{
f.setEntered(0);
f.setEntered(&s, 0);
check(&s);
}
}
@ -859,6 +863,7 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp
Auth::StackUserData userInfo;
userInfo.op = Auth::ADD_OPER;
Firebird::string work;
Firebird::LocalStatus s;
if (input_user_data->user_name)
{
@ -872,8 +877,10 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp
work.resize(l);
}
userInfo.user.set(work.c_str());
userInfo.user.setEntered(1);
userInfo.user.set(&s, work.c_str());
Firebird::check(&s);
userInfo.user.setEntered(&s, 1);
Firebird::check(&s);
}
else {
return user_error(status, isc_usrname_required);
@ -892,8 +899,10 @@ ISC_STATUS API_ROUTINE isc_add_user(ISC_STATUS* status, const USER_SEC_DATA* inp
work.resize(l);
}
userInfo.pass.set(work.c_str());
userInfo.pass.setEntered(1);
userInfo.pass.set(&s, work.c_str());
Firebird::check(&s);
userInfo.pass.setEntered(&s, 1);
Firebird::check(&s);
}
else {
return user_error(status, isc_password_required);
@ -928,6 +937,7 @@ ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS* status, const USER_SEC_DATA*
Auth::StackUserData userInfo;
userInfo.op = Auth::DEL_OPER;
Firebird::string work;
Firebird::LocalStatus s;
if (input_user_data->user_name)
{
@ -941,8 +951,10 @@ ISC_STATUS API_ROUTINE isc_delete_user(ISC_STATUS* status, const USER_SEC_DATA*
work.resize(l);
}
userInfo.user.set(work.c_str());
userInfo.user.setEntered(1);
userInfo.user.set(&s, work.c_str());
Firebird::check(&s);
userInfo.user.setEntered(&s, 1);
Firebird::check(&s);
}
else {
return user_error(status, isc_usrname_required);
@ -970,6 +982,7 @@ ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA*
Auth::StackUserData userInfo;
userInfo.op = Auth::MOD_OPER;
Firebird::string work;
Firebird::LocalStatus s;
if (input_user_data->user_name)
{
@ -983,8 +996,10 @@ ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA*
work.resize(l);
}
userInfo.user.set(work.c_str());
userInfo.user.setEntered(1);
userInfo.user.set(&s, work.c_str());
check(&s);
userInfo.user.setEntered(&s, 1);
check(&s);
}
else {
return user_error(status, isc_usrname_required);
@ -1003,8 +1018,10 @@ ISC_STATUS API_ROUTINE isc_modify_user(ISC_STATUS* status, const USER_SEC_DATA*
work.resize(l);
}
userInfo.pass.set(work.c_str());
userInfo.pass.setEntered(1);
userInfo.pass.set(&s, work.c_str());
check(&s);
userInfo.pass.setEntered(&s, 1);
check(&s);
}
else {
return user_error(status, isc_password_required);

View File

@ -158,7 +158,7 @@ public:
{ }
// IVersionCallback implementation
void FB_CARG callback(const char* text)
void FB_CARG callback(IStatus*, const char* text)
{
func(arg, text);
}
@ -544,7 +544,9 @@ void UtlInterface::getFbVersion(IStatus* status, IAttachment* att,
s.printf("%s (%s), version \"%.*s\"", implementation_string, class_string, l, versions);
callback->callback(s.c_str());
callback->callback(status, s.c_str());
if (!status->isSuccess())
return;
versions += l;
}
@ -554,7 +556,7 @@ void UtlInterface::getFbVersion(IStatus* status, IAttachment* att,
return;
s.printf("on disk structure version %d.%d", ods_version, ods_minor_version);
callback->callback(s.c_str());
callback->callback(status, s.c_str());
}
catch (const Exception& ex)
{

View File

@ -2864,8 +2864,13 @@ namespace
// IEventCallback implementation
virtual void FB_CARG eventCallbackFunction(unsigned int length, const UCHAR* events)
{
memcpy(buffer, events, length);
sem.release();
try
{
memcpy(buffer, events, length);
sem.release();
}
catch(const Firebird::Exception&)
{ }
}
int FB_CARG release()
@ -2936,7 +2941,12 @@ namespace
// IEventCallback implementation
virtual void FB_CARG eventCallbackFunction(unsigned int length, const UCHAR* events)
{
ast(arg, length, events);
try
{
ast(arg, length, events);
}
catch(const Firebird::Exception&)
{ }
}
int FB_CARG release()