"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "reflector/DataNode.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

DataNode.cpp  (muscle8.20):DataNode.cpp  (muscle8.30)
skipping to change at line 452 skipping to change at line 452
{ {
const char * slash = strchr(subPath, '/'); const char * slash = strchr(subPath, '/');
if (slash) if (slash)
{ {
DataNodeRef child = GetChild(String(subPath, (uint32)(slash-subPath))); DataNodeRef child = GetChild(String(subPath, (uint32)(slash-subPath)));
return child() ? child()->GetDescendantAux(slash+1) : DataNodeRef(); return child() ? child()->GetDescendantAux(slash+1) : DataNodeRef();
} }
else return GetChild(subPath); else return GetChild(subPath);
} }
DataNodeSubscribersTable :: DataNodeSubscribersTable(const DataNodeSubscribersTa
ble * optCopyMe, const String & sessionIDString, int32 delta)
{
if (delta < 0)
{
const uint32 * c = optCopyMe ? optCopyMe->_subscribers.Get(sessionIDString
) : NULL;
delta = c ? muscleMax(delta, -((int32)(*c))) : 0; // so we won't have to
deal with underflow cases, below
}
if (optCopyMe)
{
// This will allow _subscribers to avoid an array-reallocation when we cal
l GetOrPut() below
if ((delta > 0)&&(optCopyMe->_subscribers.ContainsKey(sessionIDString) ==
false)) (void) _subscribers.EnsureSize(optCopyMe->_subscribers.GetNumItems()+1);
_subscribers = optCopyMe->_subscribers;
}
_hashCode = DataNodeSubscribersTable::HashCodeAfterModification(optCopyMe?opt
CopyMe->HashCode():0, sessionIDString, delta);
if (delta > 0)
{
uint32 * c = _subscribers.GetOrPut(sessionIDString);
if (c) (*c) += delta;
else MWARN_OUT_OF_MEMORY;
}
else if (delta < 0)
{
uint32 * c = _subscribers.Get(sessionIDString); // guaranteed not to be N
ULL, because we checked above and if it was, we would've set (delta) to zero and
wouldn't be here
(*c) -= delta;
if ((*c) == 0) (void) _subscribers.Remove(sessionIDString);
}
}
// This method should only be called if we know that the proposed modification w
on't change the number of key-value pairs in the table
bool DataNodeSubscribersTable :: IsEqualToAfterModificationAux(const DataNodeSub
scribersTable & toMe, const String & sessionIDString, int32 delta) const
{
if (_subscribers.GetNumItems() != toMe._subscribers.GetNumItems()) return fal
se;
for (HashtableIterator<String, uint32> iter(_subscribers); iter.HasData(); it
er++)
{
const String & key = iter.GetKey();
const uint32 myCount = iter.GetValue();
const uint32 * hisCount = toMe._subscribers.Get(key);
if ((hisCount == NULL)||((myCount+((key==sessionIDString)?delta:0)) != *hi
sCount)) return false;
}
return true;
}
bool DataNodeSubscribersTable :: IsEqualToAfterModification(const DataNodeSubscr
ibersTable & toMe, const String & sessionIDString, int32 delta) const
{
if (delta == 0) return (*this == toMe);
else if (delta > 0)
{
if (_subscribers.ContainsKey(sessionIDString)) return IsEqualToAfterModifi
cationAux(toMe, sessionIDString, delta);
else
{
// In this case, after our modification we'll have one more key-value p
air in our table than we do now
if (toMe._subscribers.GetNumItems() != (_subscribers.GetNumItems()+1))
return false;
const uint32 uDelta = delta;
for (HashtableIterator<String, uint32> hisIter(toMe._subscribers); hisI
ter.HasData(); hisIter++)
{
const String & key = hisIter.GetKey();
const uint32 hisCount = hisIter.GetValue();
const uint32 * myCount = (key == sessionIDString) ? &uDelta : _subsc
ribers.Get(key);
if ((myCount == NULL)||(*myCount != hisCount)) return false;
}
return true;
}
}
else
{
const uint32 * myCurCount = _subscribers.Get(sessionIDString);
if (myCurCount)
{
const uint32 uDelta = (uint32)(-delta); // how many to deduct
if (*myCurCount > uDelta) return IsEqualToAfterModificationAux(toMe, se
ssionIDString, delta);
else
{
// In this case, after our modification we'll have one less key-valu
e pair in our table than we do now
if (toMe._subscribers.GetNumItems() != (_subscribers.GetNumItems()-1
)) return false;
for (HashtableIterator<String, uint32> hisIter(toMe._subscribers); h
isIter.HasData(); hisIter++)
{
const String & key = hisIter.GetKey();
if (key == sessionIDString) return false; // After our modificat
ion we shouldn't have this key anymore!
const uint32 hisCount = hisIter.GetValue();
const uint32 * myCount = _subscribers.Get(key);
if ((myCount == NULL)||(*myCount != hisCount)) return false;
}
return true;
}
}
else return (*this == toMe);
}
}
} // end namespace muscle } // end namespace muscle
 End of changes. 1 change blocks. 
120 lines changed or deleted 0 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)