Commit 7150244e authored by unknown's avatar unknown

bug#9282 - ndb

  big delete from causing NdbObjectIdMap::expand at same time 
  as receiver thread perform getObjectId 


ndb/src/ndbapi/Ndbinit.cpp:
  Protect NdbObjectIdMap::expand from getObjectId
ndb/src/ndbapi/ObjectMap.hpp:
  Protect NdbObjectIdMap::expand from getObjectId
parent 4014d76c
...@@ -296,7 +296,8 @@ NdbImpl::NdbImpl(Ndb_cluster_connection *ndb_cluster_connection, ...@@ -296,7 +296,8 @@ NdbImpl::NdbImpl(Ndb_cluster_connection *ndb_cluster_connection,
: m_ndb_cluster_connection(ndb_cluster_connection->m_impl), : m_ndb_cluster_connection(ndb_cluster_connection->m_impl),
m_dictionary(ndb), m_dictionary(ndb),
theCurrentConnectIndex(0), theCurrentConnectIndex(0),
theNdbObjectIdMap(1024,1024), theNdbObjectIdMap(ndb_cluster_connection->m_impl.m_transporter_facade->theMutexPtr,
1024,1024),
theNoOfDBnodes(0) theNoOfDBnodes(0)
{ {
int i; int i;
......
...@@ -30,7 +30,7 @@ class NdbObjectIdMap //: NdbLockable ...@@ -30,7 +30,7 @@ class NdbObjectIdMap //: NdbLockable
{ {
public: public:
STATIC_CONST( InvalidId = ~(Uint32)0 ); STATIC_CONST( InvalidId = ~(Uint32)0 );
NdbObjectIdMap(Uint32 initalSize = 128, Uint32 expandSize = 10); NdbObjectIdMap(NdbMutex*, Uint32 initalSize = 128, Uint32 expandSize = 10);
~NdbObjectIdMap(); ~NdbObjectIdMap();
Uint32 map(void * object); Uint32 map(void * object);
...@@ -46,14 +46,16 @@ private: ...@@ -46,14 +46,16 @@ private:
void * m_obj; void * m_obj;
} * m_map; } * m_map;
NdbMutex * m_mutex;
void expand(Uint32 newSize); void expand(Uint32 newSize);
}; };
inline inline
NdbObjectIdMap::NdbObjectIdMap(Uint32 sz, Uint32 eSz) { NdbObjectIdMap::NdbObjectIdMap(NdbMutex* mutex, Uint32 sz, Uint32 eSz) {
m_size = 0; m_size = 0;
m_firstFree = InvalidId; m_firstFree = InvalidId;
m_map = 0; m_map = 0;
m_mutex = mutex;
m_expandSize = eSz; m_expandSize = eSz;
expand(sz); expand(sz);
#ifdef DEBUG_OBJECTMAP #ifdef DEBUG_OBJECTMAP
...@@ -131,13 +133,12 @@ NdbObjectIdMap::getObject(Uint32 id){ ...@@ -131,13 +133,12 @@ NdbObjectIdMap::getObject(Uint32 id){
inline void inline void
NdbObjectIdMap::expand(Uint32 incSize){ NdbObjectIdMap::expand(Uint32 incSize){
NdbMutex_Lock(m_mutex);
Uint32 newSize = m_size + incSize; Uint32 newSize = m_size + incSize;
MapEntry * tmp = (MapEntry*)malloc(newSize * sizeof(MapEntry)); MapEntry * tmp = (MapEntry*)realloc(m_map, newSize * sizeof(MapEntry));
if (m_map) { if (likely(tmp != 0))
memcpy(tmp, m_map, m_size * sizeof(MapEntry)); {
free((void*)m_map);
}
m_map = tmp; m_map = tmp;
for(Uint32 i = m_size; i<newSize; i++){ for(Uint32 i = m_size; i<newSize; i++){
...@@ -146,6 +147,12 @@ NdbObjectIdMap::expand(Uint32 incSize){ ...@@ -146,6 +147,12 @@ NdbObjectIdMap::expand(Uint32 incSize){
m_firstFree = m_size; m_firstFree = m_size;
m_map[newSize-1].m_next = InvalidId; m_map[newSize-1].m_next = InvalidId;
m_size = newSize; m_size = newSize;
}
else
{
ndbout_c("NdbObjectIdMap::expand unable to expand!!");
}
NdbMutex_Unlock(m_mutex);
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment