Browse files

solving #443 by deleting the mDelegateODPService in ~HostedObject plu…

…s by invalidating the mSSTDatagramLayers on ~HostedObject. If an object simply disconnects and reconnects to a space, however, this solution will not kick in since these things happen at the Destructor. Will work on more fine grained solution next
  • Loading branch information...
1 parent 1f53163 commit b66392ef085f0efed61e9c1c142e502847805ff6 @danielrh danielrh committed Sep 12, 2011
Showing with 27 additions and 5 deletions.
  1. +17 −4 libcore/include/sirikata/core/network/SSTImpl.hpp
  2. +10 −1 liboh/src/HostedObject.cpp
View
21 libcore/include/sirikata/core/network/SSTImpl.hpp
@@ -207,7 +207,7 @@ class SIRIKATA_EXPORT BaseDatagramLayer
}
BaseDatagramLayerPtr datagramLayer(
- new BaseDatagramLayer(sstConnVars, ctx, odp)
+ new BaseDatagramLayer(sstConnVars, ctx, odp, endPoint)
);
datagramLayerMap[endPoint] = datagramLayer;
@@ -267,13 +267,24 @@ class SIRIKATA_EXPORT BaseDatagramLayer
uint32 getUnusedPort(const EndPointType& ep) {
return mODP->unusedODPPort(ep);
}
-
+ void invalidate() {
+ mODP=NULL;
+ std::map<EndPointType, BaseDatagramLayerPtr >& datagramLayerMap = mSSTConnVars->sDatagramLayerMap;
+ std::map<EndPointType, BaseDatagramLayerPtr >::iterator wherei=datagramLayerMap.find(mEndpoint);
+ if (wherei!=datagramLayerMap.end()) {
+ datagramLayerMap.erase(wherei);
+ }else {
+ SILOG(sst,error,"FATAL: Invalidating BaseDatagramLayer that's invalid");
+ }
+ }
private:
- BaseDatagramLayer(SSTConnectionVariables<EndPointType>* sstConnVars, const Context* ctx, ODP::Service* odpservice)
+ BaseDatagramLayer(SSTConnectionVariables<EndPointType>* sstConnVars, const Context* ctx, ODP::Service* odpservice, const EndPointType&ep)
: mContext(ctx),
mODP(odpservice),
- mSSTConnVars(sstConnVars)
+ mSSTConnVars(sstConnVars),
+ mEndpoint(ep)
{
+
}
ODP::Port* allocatePort(const EndPoint<EndPointType>& ep) {
@@ -328,6 +339,8 @@ class SIRIKATA_EXPORT BaseDatagramLayer
boost::mutex mMutex;
SSTConnectionVariables<EndPointType>* mSSTConnVars;
+ EndPointType mEndpoint;
+
};
#if SIRIKATA_PLATFORM == SIRIKATA_WINDOWS
View
11 liboh/src/HostedObject.cpp
@@ -131,9 +131,12 @@ HostedObject::~HostedObject() {
if (mPresenceData != NULL)
delete mPresenceData;
-
+ delete mDelegateODPService;
getObjectHost()->hostedObjectDestroyed(id());
stop();
+ for (size_t i=0;i<mSSTDatagramLayers.size();++i) {
+ mSSTDatagramLayers[i]->invalidate();
+ }
}
const UUID& HostedObject::id() const {
@@ -624,6 +627,12 @@ void HostedObject::handleDisconnected(const HostedObjectWPtr& weakSelf, const Sp
assert(self->mPresenceData->find(spaceobj)==self->mPresenceData->end());
self->mObjectHost->unregisterHostedObject(spaceobj, self.get());
}
+ for (size_t i=0;i<self->mSSTDatagramLayers.size();++i) {
+ BaseDatagramLayerPtr pt=self->mSSTDatagramLayers[i];
+ if (pt.get()) {
+ SILOG(ho,error,"Trying to deallocate datagram");
+ }
+ }
}

0 comments on commit b66392e

Please sign in to comment.