summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2012-01-26 14:26:40 -0800
committerMark Spruiell <mes@zeroc.com>2012-01-26 14:26:40 -0800
commit6860c703d70e02692c33db1d4453fb8c16589039 (patch)
tree8f11a367009f508f29c972891d73895eb958a567 /cpp
parentminor fix to Ice.Application in C#/Mono (diff)
downloadice-6860c703d70e02692c33db1d4453fb8c16589039.tar.bz2
ice-6860c703d70e02692c33db1d4453fb8c16589039.tar.xz
ice-6860c703d70e02692c33db1d4453fb8c16589039.zip
ICE-4775 - memory leak in Glacier2
Diffstat (limited to 'cpp')
-rwxr-xr-xcpp/src/Glacier2/Blobject.cpp9
-rw-r--r--cpp/src/Glacier2/Blobject.h2
-rwxr-xr-xcpp/src/Glacier2/RequestQueue.cpp44
-rw-r--r--cpp/src/Glacier2/RequestQueue.h5
-rw-r--r--cpp/src/Glacier2/RouterI.cpp6
5 files changed, 65 insertions, 1 deletions
diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp
index 2776e6b9ec9..7366590304b 100755
--- a/cpp/src/Glacier2/Blobject.cpp
+++ b/cpp/src/Glacier2/Blobject.cpp
@@ -171,6 +171,15 @@ Glacier2::Blobject::~Blobject()
}
void
+Glacier2::Blobject::destroy()
+{
+ if(_requestQueue)
+ {
+ _requestQueue->destroy();
+ }
+}
+
+void
Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB,
const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current)
{
diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h
index f3ea67ddece..1a97cd080c4 100644
--- a/cpp/src/Glacier2/Blobject.h
+++ b/cpp/src/Glacier2/Blobject.h
@@ -24,6 +24,8 @@ public:
Blobject(const InstancePtr&, const Ice::ConnectionPtr&, const Ice::Context&);
virtual ~Blobject();
+ void destroy();
+
protected:
void invoke(Ice::ObjectPrx&, const Ice::AMD_Object_ice_invokePtr&,
diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp
index 3cd660df007..55fd019d131 100755
--- a/cpp/src/Glacier2/RequestQueue.cpp
+++ b/cpp/src/Glacier2/RequestQueue.cpp
@@ -185,7 +185,8 @@ Glacier2::RequestQueue::RequestQueue(const RequestQueueThreadPtr& requestQueueTh
_callback(newCallback_Object_ice_invoke(this, &RequestQueue::response, &RequestQueue::exception,
&RequestQueue::sent)),
_flushCallback(newCallback_Connection_flushBatchRequests(this, &RequestQueue::exception, &RequestQueue::sent)),
- _pendingSend(false)
+ _pendingSend(false),
+ _destroyed(false)
{
}
@@ -241,6 +242,37 @@ Glacier2::RequestQueue::flushRequests(set<Ice::ObjectPrx>& batchProxies)
}
void
+Glacier2::RequestQueue::destroy()
+{
+ IceUtil::Mutex::Lock lock(*this);
+
+ _destroyed = true;
+
+ //
+ // Although the session has been destroyed, we cannot destroy this queue
+ // until all requests have completed.
+ //
+ if(_requests.empty())
+ {
+ destroyInternal();
+ }
+}
+
+void
+Glacier2::RequestQueue::destroyInternal()
+{
+ //
+ // Must be called with the mutex locked.
+ //
+
+ //
+ // Remove cyclic references.
+ //
+ const_cast<Ice::Callback_Object_ice_invokePtr&>(_callback) = 0;
+ const_cast<Ice::Callback_Connection_flushBatchRequestsPtr&>(_flushCallback) = 0;
+}
+
+void
Glacier2::RequestQueue::flush()
{
assert(_connection);
@@ -289,6 +321,11 @@ Glacier2::RequestQueue::flush()
_pendingSendRequest = 0;
}
}
+
+ if(_destroyed && _requests.empty())
+ {
+ destroyInternal();
+ }
}
void
@@ -312,6 +349,11 @@ Glacier2::RequestQueue::flush(set<Ice::ObjectPrx>& batchProxies)
}
}
_requests.clear();
+
+ if(_destroyed)
+ {
+ destroyInternal();
+ }
}
void
diff --git a/cpp/src/Glacier2/RequestQueue.h b/cpp/src/Glacier2/RequestQueue.h
index 8466d3f9b6d..1862177ac1f 100644
--- a/cpp/src/Glacier2/RequestQueue.h
+++ b/cpp/src/Glacier2/RequestQueue.h
@@ -65,8 +65,12 @@ public:
bool addRequest(const RequestPtr&);
void flushRequests(std::set<Ice::ObjectPrx>&);
+ void destroy();
+
private:
+ void destroyInternal();
+
void flush();
void flush(std::set<Ice::ObjectPrx>&);
@@ -83,6 +87,7 @@ private:
std::deque<RequestPtr> _requests;
bool _pendingSend;
RequestPtr _pendingSendRequest;
+ bool _destroyed;
};
typedef IceUtil::Handle<RequestQueue> RequestQueuePtr;
diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp
index 7d40434eb8d..b2c1faabe41 100644
--- a/cpp/src/Glacier2/RouterI.cpp
+++ b/cpp/src/Glacier2/RouterI.cpp
@@ -98,6 +98,12 @@ Glacier2::RouterI::destroy(const AMI_Session_destroyPtr& amiCB)
_session->destroy_async(amiCB);
}
}
+
+ _clientBlobject->destroy();
+ if(_serverBlobject)
+ {
+ _serverBlobject->destroy();
+ }
}
ObjectPrx