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

Fixed bug CORE-5993 : When creation of audit log file fails, there is no error message in firebird.log

This commit is contained in:
hvlad 2019-01-25 12:28:14 +02:00
parent 15e6315342
commit 5b8e562c80
6 changed files with 77 additions and 2 deletions

View File

@ -1295,6 +1295,8 @@ interface TraceSweepInfo : Versioned
interface TraceLogWriter : ReferenceCounted
{
uint write(const void* buf, uint size);
version: // 3.0.4 -> 3.0.5
uint write_s(Status status, const void* buf, uint size);
}
interface TraceInitInfo : Versioned

View File

@ -5229,6 +5229,7 @@ namespace Firebird
struct VTable : public IReferenceCounted::VTable
{
unsigned (CLOOP_CARG *write)(ITraceLogWriter* self, const void* buf, unsigned size) throw();
unsigned (CLOOP_CARG *write_s)(ITraceLogWriter* self, IStatus* status, const void* buf, unsigned size) throw();
};
protected:
@ -5242,13 +5243,27 @@ namespace Firebird
}
public:
static const unsigned VERSION = 3;
static const unsigned VERSION = 4;
unsigned write(const void* buf, unsigned size)
{
unsigned ret = static_cast<VTable*>(this->cloopVTable)->write(this, buf, size);
return ret;
}
template <typename StatusType> unsigned write_s(StatusType* status, const void* buf, unsigned size)
{
if (cloopVTable->version < 4)
{
StatusType::setVersionError(status, "ITraceLogWriter", cloopVTable->version, 4);
StatusType::checkException(status);
return 0;
}
StatusType::clearException(status);
unsigned ret = static_cast<VTable*>(this->cloopVTable)->write_s(this, status, buf, size);
StatusType::checkException(status);
return ret;
}
};
class ITraceInitInfo : public IVersioned
@ -16787,6 +16802,7 @@ namespace Firebird
this->addRef = &Name::cloopaddRefDispatcher;
this->release = &Name::cloopreleaseDispatcher;
this->write = &Name::cloopwriteDispatcher;
this->write_s = &Name::cloopwrite_sDispatcher;
}
} vTable;
@ -16806,6 +16822,21 @@ namespace Firebird
}
}
static unsigned CLOOP_CARG cloopwrite_sDispatcher(ITraceLogWriter* self, IStatus* status, const void* buf, unsigned size) throw()
{
StatusType status2(status);
try
{
return static_cast<Name*>(self)->Name::write_s(&status2, buf, size);
}
catch (...)
{
StatusType::catchException(&status2);
return static_cast<unsigned>(0);
}
}
static void CLOOP_CARG cloopaddRefDispatcher(IReferenceCounted* self) throw()
{
try
@ -16846,6 +16877,7 @@ namespace Firebird
}
virtual unsigned write(const void* buf, unsigned size) = 0;
virtual unsigned write_s(StatusType* status, const void* buf, unsigned size) = 0;
};
template <typename Name, typename StatusType, typename Base>

View File

@ -506,6 +506,7 @@ public:
// TraceLogWriter implementation
FB_SIZE_T write(const void* buf, FB_SIZE_T size);
FB_SIZE_T write_s(CheckStatusWrapper* status, const void* buf, FB_SIZE_T size);
int release()
{
@ -559,6 +560,20 @@ FB_SIZE_T TraceLogWriterImpl::write(const void* buf, FB_SIZE_T size)
return size;
}
FB_SIZE_T TraceLogWriterImpl::write_s(CheckStatusWrapper* status, const void* buf, FB_SIZE_T size)
{
try
{
return write(buf, size);
}
catch (Exception &ex)
{
ex.stuffException(status);
}
return 0;
}
/// TraceInitInfoImpl

View File

@ -61,7 +61,10 @@ PluginLogWriter::PluginLogWriter(const char* fileName, size_t maxSize) :
mutexName.append(m_fileName);
checkMutex("init", ISC_mutex_init(&m_mutex, mutexName.c_str()));
Guard guard(this);
#endif
reopen();
}
PluginLogWriter::~PluginLogWriter()
@ -183,6 +186,20 @@ FB_SIZE_T PluginLogWriter::write(const void* buf, FB_SIZE_T size)
return written;
}
FB_SIZE_T PluginLogWriter::write_s(CheckStatusWrapper* status, const void* buf, FB_SIZE_T size)
{
try
{
return write(buf, size);
}
catch (Exception &ex)
{
ex.stuffException(status);
}
return 0;
}
void PluginLogWriter::checkErrno(const char* operation)
{
if (errno == 0)

View File

@ -56,6 +56,7 @@ public:
// TraceLogWriter implementation
virtual FB_SIZE_T write(const void* buf, FB_SIZE_T size);
virtual FB_SIZE_T write_s(Firebird::CheckStatusWrapper* status, const void* buf, unsigned size);
virtual int release()
{

View File

@ -236,7 +236,15 @@ void TracePluginImpl::logRecord(const char* action)
// TODO: implement adjusting of line breaks
// line.adjustLineBreaks();
logWriter->write(record.c_str(), record.length());
LocalStatus ls;
CheckStatusWrapper status(&ls);
logWriter->write_s(&status, record.c_str(), record.length());
if (ls.getState() & IStatus::STATE_ERRORS && ls.getErrors()[1] == isc_interface_version_too_old)
logWriter->write(record.c_str(), record.length());
else
check(&status);
record = "";
}