summaryrefslogtreecommitdiff
path: root/cpp/src/Glacier2/RequestQueue.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/src/Glacier2/RequestQueue.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/src/Glacier2/RequestQueue.cpp')
-rwxr-xr-xcpp/src/Glacier2/RequestQueue.cpp44
1 files changed, 43 insertions, 1 deletions
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