summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2004-02-26 15:43:05 +0000
committerMarc Laukien <marc@zeroc.com>2004-02-26 15:43:05 +0000
commit6bb0946b318353303a8029d27015db906aafaac9 (patch)
treee816a90f60e49fad8a3e5afeee54012100d2a0fc /cpp/src
parentfix (diff)
downloadice-6bb0946b318353303a8029d27015db906aafaac9.tar.bz2
ice-6bb0946b318353303a8029d27015db906aafaac9.tar.xz
ice-6bb0946b318353303a8029d27015db906aafaac9.zip
fixes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Connection.cpp21
-rw-r--r--cpp/src/Ice/Connection.h11
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp20
3 files changed, 21 insertions, 31 deletions
diff --git a/cpp/src/Ice/Connection.cpp b/cpp/src/Ice/Connection.cpp
index 8ee44c819f6..38fd60820fb 100644
--- a/cpp/src/Ice/Connection.cpp
+++ b/cpp/src/Ice/Connection.cpp
@@ -328,9 +328,9 @@ IceInternal::Connection::monitor()
//
// Check for timed out async requests.
//
- for(map<Int, OutgoingAsyncPtr>::iterator p = _asyncRequests.begin(); p != _asyncRequests.end(); ++p)
+ for(map<Int, AsyncRequest>::iterator p = _asyncRequests.begin(); p != _asyncRequests.end(); ++p)
{
- if(p->second->__timedOut())
+ if(p->second.t > IceUtil::Time() && p->second.t < IceUtil::Time::now())
{
setState(StateClosed, TimeoutException(__FILE__, __LINE__));
return;
@@ -565,8 +565,11 @@ IceInternal::Connection::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPt
//
// Add to the async requests map.
//
+ struct AsyncRequest asyncRequest;
+ asyncRequest.p = out;
+ asyncRequest.t = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_endpoint->timeout());
_asyncRequestsHint = _asyncRequests.insert(_asyncRequests.end(),
- pair<const Int, OutgoingAsyncPtr>(requestId, out));
+ pair<const Int, AsyncRequest>(requestId, asyncRequest));
if(_acmTimeout > 0)
{
@@ -656,7 +659,7 @@ IceInternal::Connection::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPt
// without a very elaborate and complex design, which would be
// bad for performance.
//
- map<Int, OutgoingAsyncPtr>::iterator p = _asyncRequests.find(requestId);
+ map<Int, AsyncRequest>::iterator p = _asyncRequests.find(requestId);
if(p != _asyncRequests.end())
{
if(p == _asyncRequestsHint)
@@ -1183,7 +1186,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
stream.read(requestId);
map<Int, Outgoing*>::iterator p = _requests.end();
- map<Int, OutgoingAsyncPtr>::iterator q = _asyncRequests.end();
+ map<Int, AsyncRequest>::iterator q = _asyncRequests.end();
if(_requestsHint != _requests.end())
{
@@ -1237,7 +1240,7 @@ IceInternal::Connection::message(BasicStream& stream, const ThreadPoolPtr& threa
{
assert(q != _asyncRequests.end());
- outAsync = q->second;
+ outAsync = q->second.p;
if(q == _asyncRequestsHint)
{
@@ -1348,7 +1351,7 @@ IceInternal::Connection::finished(const ThreadPoolPtr& threadPool)
auto_ptr<LocalException> exception;
map<Int, Outgoing*> requests;
- map<Int, OutgoingAsyncPtr> asyncRequests;
+ map<Int, AsyncRequest> asyncRequests;
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
@@ -1394,9 +1397,9 @@ IceInternal::Connection::finished(const ThreadPoolPtr& threadPool)
p->second->finished(*_exception.get()); // The exception is immutable at this point.
}
- for(map<Int, OutgoingAsyncPtr>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
+ for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
{
- q->second->__finished(*_exception.get()); // The exception is immutable at this point.
+ q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
}
if(exception.get())
diff --git a/cpp/src/Ice/Connection.h b/cpp/src/Ice/Connection.h
index e8a3eba7882..c5a716f56d8 100644
--- a/cpp/src/Ice/Connection.h
+++ b/cpp/src/Ice/Connection.h
@@ -150,10 +150,17 @@ private:
const std::vector<Ice::Byte> _replyHdr;
Ice::Int _nextRequestId;
+
std::map<Ice::Int, Outgoing*> _requests;
std::map<Ice::Int, Outgoing*>::iterator _requestsHint;
- std::map<Ice::Int, OutgoingAsyncPtr> _asyncRequests;
- std::map<Ice::Int, OutgoingAsyncPtr>::iterator _asyncRequestsHint;
+
+ struct AsyncRequest
+ {
+ OutgoingAsyncPtr p;
+ IceUtil::Time t;
+ };
+ std::map<Ice::Int, AsyncRequest> _asyncRequests;
+ std::map<Ice::Int, AsyncRequest>::iterator _asyncRequestsHint;
std::auto_ptr<Ice::LocalException> _exception;
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index 3b47a1bf490..905a80571b6 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -219,21 +219,6 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
cleanup();
}
-bool
-IceInternal::OutgoingAsync::__timedOut() const
-{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_monitor);
-
- if(_connection && _connection->timeout() >= 0)
- {
- return IceUtil::Time::now() >= _absoluteTimeout;
- }
- else
- {
- return false;
- }
-}
-
void
IceInternal::OutgoingAsync::__prepare(const ReferencePtr& ref, const string& operation, OperationMode mode,
const Context& context)
@@ -297,11 +282,6 @@ IceInternal::OutgoingAsync::__send()
_connection = _reference->getConnection();
}
- if(_connection->timeout() >= 0)
- {
- _absoluteTimeout = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_connection->timeout());
- }
-
try
{
_connection->sendAsyncRequest(__os, this);