mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 18:43:03 +01:00
Fixed bug CORE-2934 : Memory leak in FB2.5 trace plugin
This commit is contained in:
parent
75bfabff97
commit
26faad378b
@ -26,11 +26,9 @@
|
||||
*/
|
||||
|
||||
#include "TraceConfiguration.h"
|
||||
#include "../../jrd/intl_classes.h"
|
||||
#include "TraceUnicodeUtils.h"
|
||||
#include "../../jrd/evl_string.h"
|
||||
#include "../../jrd/TextType.h"
|
||||
#include "../../jrd/SimilarToMatcher.h"
|
||||
#include "../../jrd/unicode_util.h"
|
||||
#include "../../jrd/isc_f_proto.h"
|
||||
|
||||
using namespace Firebird;
|
||||
@ -103,19 +101,6 @@ void TraceCfgReader::readConfig()
|
||||
m_subpatterns[i].end = -1;
|
||||
}
|
||||
|
||||
charset cs;
|
||||
IntlUtil::initUtf8Charset(&cs);
|
||||
|
||||
UCharBuffer collAttributesBuffer;
|
||||
IntlUtil::getDefaultCollationAttributes(collAttributesBuffer, cs);
|
||||
|
||||
texttype tt;
|
||||
if (!IntlUtil::initUnicodeCollation(&tt, &cs, "UNICODE", 0, collAttributesBuffer, string()))
|
||||
fatal_exception::raiseFmt("cannot initialize UNICODE collation to use in trace plugin");
|
||||
|
||||
AutoPtr<Jrd::CharSet> charSet(Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs));
|
||||
Jrd::TextType textType(0, &tt, charSet);
|
||||
|
||||
bool defDB = false, defSvc = false, exactMatch = false;
|
||||
const ConfigFile::Parameters& params = cfgFile.getParameters();
|
||||
for (size_t n = 0; n < params.getCount() && !exactMatch; ++n)
|
||||
@ -166,8 +151,10 @@ void TraceCfgReader::readConfig()
|
||||
#else
|
||||
typedef SystemToUtf8Converter<> SimilarConverter;
|
||||
#endif
|
||||
Jrd::TextType *textType = GetUnicodeTextType();
|
||||
|
||||
SimilarToMatcher<ULONG, Jrd::CanonicalConverter<SimilarConverter> > matcher(
|
||||
*getDefaultMemoryPool(), &textType, (const UCHAR*) pattern.c_str(),
|
||||
*getDefaultMemoryPool(), textType, (const UCHAR*) pattern.c_str(),
|
||||
pattern.length(), '\\', true, false);
|
||||
|
||||
regExpOk = true;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "TracePluginImpl.h"
|
||||
#include "TraceUnicodeUtils.h"
|
||||
#include "PluginLogWriter.h"
|
||||
#include "os/platform.h"
|
||||
#include "../../jrd/req.h"
|
||||
@ -139,16 +140,7 @@ TracePluginImpl::TracePluginImpl(const TracePluginConfig &configuration, TraceIn
|
||||
PluginLogWriter(logname.c_str(), config.max_log_size * 1024 * 1024);
|
||||
}
|
||||
|
||||
IntlUtil::initUtf8Charset(&cs);
|
||||
|
||||
UCharBuffer collAttributesBuffer;
|
||||
IntlUtil::getDefaultCollationAttributes(collAttributesBuffer, cs);
|
||||
|
||||
if (!IntlUtil::initUnicodeCollation(&tt, &cs, "UNICODE", 0, collAttributesBuffer, string()))
|
||||
fatal_exception::raiseFmt("cannot initialize UNICODE collation to use in trace plugin");
|
||||
|
||||
charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs);
|
||||
textType = FB_NEW(*getDefaultMemoryPool()) Jrd::TextType(0, &tt, charSet);
|
||||
Jrd::TextType *textType = GetUnicodeTextType();
|
||||
|
||||
// Compile filtering regular expressions
|
||||
if (config.include_filter.hasData())
|
||||
|
@ -165,11 +165,6 @@ private:
|
||||
// Lock for log rotation
|
||||
Firebird::RWLock renameLock;
|
||||
|
||||
charset cs;
|
||||
texttype tt;
|
||||
Firebird::AutoPtr<Jrd::CharSet> charSet;
|
||||
Firebird::AutoPtr<Jrd::TextType> textType;
|
||||
|
||||
Firebird::AutoPtr<Firebird::SimilarToMatcher<UCHAR, Jrd::UpcaseConverter<> > >
|
||||
include_matcher, exclude_matcher;
|
||||
|
||||
|
82
src/utilities/ntrace/TraceUnicodeUtils.cpp
Normal file
82
src/utilities/ntrace/TraceUnicodeUtils.cpp
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* PROGRAM: Firebird Trace Services
|
||||
* MODULE: TraceUnicodeUtils.cpp
|
||||
* DESCRIPTION: Unicode support for trace needs
|
||||
*
|
||||
* The contents of this file are subject to the Initial
|
||||
* Developer's 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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
|
||||
*
|
||||
* Software distributed under the License is distributed AS IS,
|
||||
* 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 Khorsun Vladyslav
|
||||
* for the Firebird Open Source RDBMS project.
|
||||
*
|
||||
* Copyright (c) 2010 Khorsun Vladyslav <hvlad@users.sourceforge.net>
|
||||
* and all contributors signed below.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "TraceUnicodeUtils.h"
|
||||
#include "../../common/classes/init.h"
|
||||
#include "../../jrd/unicode_util.h"
|
||||
|
||||
using namespace Firebird;
|
||||
|
||||
namespace
|
||||
{
|
||||
class UnicodeCollationHolder
|
||||
{
|
||||
private:
|
||||
charset cs;
|
||||
texttype tt;
|
||||
Jrd::CharSet *charSet;
|
||||
Jrd::TextType *textType;
|
||||
|
||||
public:
|
||||
UnicodeCollationHolder(MemoryPool&)
|
||||
{
|
||||
IntlUtil::initUtf8Charset(&cs);
|
||||
|
||||
string collAttributes("ICU-VERSION=");
|
||||
collAttributes += Jrd::UnicodeUtil::DEFAULT_ICU_VERSION;
|
||||
IntlUtil::setupIcuAttributes(&cs, collAttributes, "", collAttributes);
|
||||
|
||||
UCharBuffer collAttributesBuffer;
|
||||
collAttributesBuffer.push(reinterpret_cast<const UCHAR*>(collAttributes.c_str()),
|
||||
collAttributes.length());
|
||||
|
||||
if (!IntlUtil::initUnicodeCollation(&tt, &cs, "UNICODE", 0, collAttributesBuffer, string()))
|
||||
fatal_exception::raiseFmt("cannot initialize UNICODE collation to use in trace plugin");
|
||||
|
||||
|
||||
charSet = Jrd::CharSet::createInstance(*getDefaultMemoryPool(), 0, &cs);
|
||||
textType = FB_NEW(*getDefaultMemoryPool()) Jrd::TextType(0, &tt, charSet);
|
||||
}
|
||||
|
||||
~UnicodeCollationHolder()
|
||||
{
|
||||
delete textType;
|
||||
delete charSet;
|
||||
}
|
||||
|
||||
Jrd::TextType* getTextType() const { return textType; };
|
||||
};
|
||||
}
|
||||
|
||||
static InitInstance<UnicodeCollationHolder> unicodeCollation;
|
||||
|
||||
|
||||
Jrd::TextType* GetUnicodeTextType()
|
||||
{
|
||||
return unicodeCollation().getTextType();
|
||||
}
|
38
src/utilities/ntrace/TraceUnicodeUtils.h
Normal file
38
src/utilities/ntrace/TraceUnicodeUtils.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* PROGRAM: Firebird Trace Services
|
||||
* MODULE: TraceUnicodeUtils.h
|
||||
* DESCRIPTION: Unicode support for trace needs
|
||||
*
|
||||
* The contents of this file are subject to the Initial
|
||||
* Developer's 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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
|
||||
*
|
||||
* Software distributed under the License is distributed AS IS,
|
||||
* 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 Khorsun Vladyslav
|
||||
* for the Firebird Open Source RDBMS project.
|
||||
*
|
||||
* Copyright (c) 2010 Khorsun Vladyslav <hvlad@users.sourceforge.net>
|
||||
* and all contributors signed below.
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef TRACE_UNICODE_UTILS_H
|
||||
#define TRACE_UNICODE_UTILS_H
|
||||
|
||||
#include "firebird.h"
|
||||
#include "../../common/classes/fb_string.h"
|
||||
#include "../../jrd/intl_classes.h"
|
||||
#include "../../jrd/TextType.h"
|
||||
|
||||
Jrd::TextType* GetUnicodeTextType();
|
||||
|
||||
#endif // TRACE_UNICODE_UTILS_H
|
Loading…
Reference in New Issue
Block a user