Skip to content

Commit 3b63fb2

Browse files
committed
Bug#33855045 Test ndbinfo_upgrade fails on valgrind builds [#4]
The NdbEventOperationImpl owns a NdbDictionary::Event by having a pointer to the Event's implementation. Make sure the pointer is always initialized in constructor and mark the pointer const. Also mark NdbEventImpl's pointer to the Event as const. Thus the m_eventImpl->m_facade pointer path should now be enforced by compiler. Change-Id: I469b39d66a4d83daf08307d980d555da1ab79827
1 parent bbafd3c commit 3b63fb2

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

storage/ndb/src/ndbapi/NdbDictionaryImpl.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class NdbEventImpl : public NdbDictionary::Event, public NdbDictObjectImpl {
519519

520520
static NdbEventImpl & getImpl(NdbDictionary::Event & t);
521521
static NdbEventImpl & getImpl(const NdbDictionary::Event & t);
522-
NdbDictionary::Event * m_facade;
522+
NdbDictionary::Event * const m_facade;
523523
private:
524524
NdbTableImpl *m_tableImpl;
525525
void setTable(NdbTableImpl *tableImpl);

storage/ndb/src/ndbapi/NdbEventOperationImpl.cpp

+10-11
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,35 @@ NdbEventOperationImpl::NdbEventOperationImpl(NdbEventOperation &f,
9797
NdbEventOperation(*this),
9898
m_facade(&f),
9999
m_ndb(ndb),
100+
m_eventImpl(&event->m_impl),
100101
m_state(EO_ERROR),
101102
m_oid(~(Uint32)0),
102103
m_stop_gci(),
103104
m_allow_empty_update(false)
104105
{
105106
DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl");
106-
init(event->m_impl);
107+
init();
107108
DBUG_VOID_RETURN;
108109
}
109110

110111
NdbEventOperationImpl::NdbEventOperationImpl(Ndb *theNdb,
111-
NdbEventImpl& evnt) :
112+
NdbEventImpl* evnt) :
112113
NdbEventOperation(*this),
113114
m_facade(this),
114115
m_ndb(theNdb),
116+
m_eventImpl(evnt),
115117
m_state(EO_ERROR),
116118
m_oid(~(Uint32)0),
117119
m_stop_gci(),
118120
m_allow_empty_update(false)
119121
{
120122
DBUG_ENTER("NdbEventOperationImpl::NdbEventOperationImpl [evnt]");
121-
init(evnt);
123+
init();
122124
DBUG_VOID_RETURN;
123125
}
124126

125127
void
126-
NdbEventOperationImpl::init(NdbEventImpl& evnt)
128+
NdbEventOperationImpl::init()
127129
{
128130
DBUG_ENTER("NdbEventOperationImpl::init");
129131

@@ -152,16 +154,13 @@ NdbEventOperationImpl::init(NdbEventImpl& evnt)
152154
theBlobVersion = 0;
153155

154156
m_data_item= NULL;
155-
m_eventImpl = NULL;
156157

157158
m_custom_data= 0;
158159
m_has_error= 1;
159160

160161
// we should lookup id in Dictionary, TODO
161162
// also make sure we only have one listener on each event
162163

163-
m_eventImpl = &evnt;
164-
165164
m_oid= m_ndb->theImpl->mapRecipient(this);
166165

167166
m_state= EO_CREATED;
@@ -211,8 +210,8 @@ NdbEventOperationImpl::~NdbEventOperationImpl()
211210

212211
if (m_eventImpl)
213212
{
213+
// NOTE! Destroys the Event which is owned by the NdbEventImpl pointer
214214
delete m_eventImpl->m_facade;
215-
m_eventImpl= 0;
216215
}
217216

218217
DBUG_VOID_RETURN;
@@ -408,7 +407,7 @@ NdbEventOperationImpl::getBlobHandle(const NdbColumnImpl *tAttrInfo, int n)
408407

409408
// create blob event operation
410409
tBlobOp =
411-
m_ndb->theEventBuffer->createEventOperationImpl(*blobEvnt, m_error);
410+
m_ndb->theEventBuffer->createEventOperationImpl(blobEvnt, m_error);
412411
if (tBlobOp == NULL)
413412
DBUG_RETURN(NULL);
414413

@@ -4303,11 +4302,11 @@ NdbEventBuffer::createEventOperation(const char* eventName,
43034302
}
43044303

43054304
NdbEventOperationImpl*
4306-
NdbEventBuffer::createEventOperationImpl(NdbEventImpl& evnt,
4305+
NdbEventBuffer::createEventOperationImpl(NdbEventImpl* event,
43074306
NdbError &theError)
43084307
{
43094308
DBUG_ENTER("NdbEventBuffer::createEventOperationImpl");
4310-
NdbEventOperationImpl* tOp= new NdbEventOperationImpl(m_ndb, evnt);
4309+
NdbEventOperationImpl* tOp= new NdbEventOperationImpl(m_ndb, event);
43114310
if (tOp == 0)
43124311
{
43134312
theError.code= 4000;

storage/ndb/src/ndbapi/NdbEventOperationImpl.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,9 @@ class NdbEventOperationImpl : public NdbEventOperation {
557557
NdbEventOperationImpl(NdbEventOperation &f,
558558
Ndb *ndb,
559559
const NdbDictionary::Event *myEvnt);
560-
NdbEventOperationImpl(Ndb *theNdb,
561-
NdbEventImpl& evnt);
562-
void init(NdbEventImpl& evnt);
560+
NdbEventOperationImpl(Ndb *theNdb,
561+
NdbEventImpl *evnt);
562+
void init();
563563
NdbEventOperationImpl(NdbEventOperationImpl&); //unimplemented
564564
NdbEventOperationImpl& operator=(const NdbEventOperationImpl&); //unimplemented
565565
~NdbEventOperationImpl();
@@ -602,7 +602,8 @@ class NdbEventOperationImpl : public NdbEventOperation {
602602
NdbError m_error;
603603

604604
Ndb *const m_ndb;
605-
NdbEventImpl *m_eventImpl;
605+
// The Event is owned by pointer to NdbEventImpl->m_facade
606+
NdbEventImpl *const m_eventImpl;
606607

607608
NdbRecAttr *theFirstPkAttrs[2];
608609
NdbRecAttr *theCurrentPkAttrs[2];
@@ -844,7 +845,7 @@ class NdbEventBuffer {
844845

845846
NdbEventOperation *createEventOperation(const char* eventName,
846847
NdbError &);
847-
NdbEventOperationImpl *createEventOperationImpl(NdbEventImpl& evnt,
848+
NdbEventOperationImpl *createEventOperationImpl(NdbEventImpl* evnt,
848849
NdbError &);
849850
void dropEventOperation(NdbEventOperation *);
850851
static NdbEventOperationImpl* getEventOperationImpl(NdbEventOperation* tOp);

0 commit comments

Comments
 (0)