Author: kpvdr
Date: 2007-11-08 10:25:15 -0500 (Thu, 08 Nov 2007)
New Revision: 1269
Modified:
store/trunk/cpp/lib/JournalImpl.cpp
store/trunk/cpp/lib/JournalImpl.h
Log:
Fixed memory leak associated with new JournalImpl::loadMsgContent() function
Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp 2007-11-08 14:55:16 UTC (rev 1268)
+++ store/trunk/cpp/lib/JournalImpl.cpp 2007-11-08 15:25:15 UTC (rev 1269)
@@ -43,6 +43,7 @@
getEventsTimerSetFlag(false),
writeActivityFlag(false),
flushTriggeredFlag(true),
+ _xidp(0),
_datap(0),
_dlen(0),
_dtok(),
@@ -58,6 +59,13 @@
{
(dynamic_cast<GetEventsFireEvent*>(getEventsFireEventsPtr.get()))->cancel();
(dynamic_cast<InactivityFireEvent*>(inactivityFireEventPtr.get()))->cancel();
+ if (_xidp) {
+ ::free(_xidp);
+ _xidp = 0;
+ } else if (_datap) {
+ ::free(_datap);
+ _datap = 0;
+ }
}
void
@@ -104,20 +112,27 @@
{
if (_dtok.rid() != rid)
{
- _datap = 0;
+ // Free any previous msg
+ if (_xidp) {
+ ::free(_xidp);
+ _xidp = 0;
+ } else if (_datap) {
+ ::free(_datap);
+ _datap = 0;
+ }
_dlen = 0;
_dtok.reset();
_dtok.set_rid(rid);
_dtok.set_wstate(journal::data_tok::ENQ);
_external = false;
- void* xidp = 0;
size_t xlen = 0;
bool transient = false;
bool done = false;
unsigned aio_sleep_cnt = 0;
while (!done)
{
- iores res = read_data_record(&_datap, _dlen, &xidp, xlen, transient,
_external, &_dtok);
+ iores res = read_data_record(&_datap, _dlen, &_xidp, xlen, transient,
_external,
+ &_dtok);
if (res == journal::RHM_IORES_SUCCESS) {
done = true;
} else if (res == journal::RHM_IORES_AIO_WAIT) {
@@ -136,12 +151,6 @@
throw jexception(ss.str());
}
}
- // set correct pointer for deletion by boost::shared_ptr
- if (xlen) {
- _master = boost::shared_ptr<char>((char*)xidp);
- } else {
- _master = boost::shared_ptr<char>((char*)_datap);
- }
}
if (_external)
return true;
Modified: store/trunk/cpp/lib/JournalImpl.h
===================================================================
--- store/trunk/cpp/lib/JournalImpl.h 2007-11-08 14:55:16 UTC (rev 1268)
+++ store/trunk/cpp/lib/JournalImpl.h 2007-11-08 15:25:15 UTC (rev 1269)
@@ -75,7 +75,7 @@
qpid::broker::TimerTaskA::intrusive_ptr inactivityFireEventPtr;
// temp local vars for loadMsgContent below
- boost::shared_ptr<char> _master;
+ void* _xidp;
void* _datap;
size_t _dlen;
journal::data_tok _dtok;
Show replies by date