summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier2/RequestQueue.cpp69
-rw-r--r--cpp/src/Glacier2/RequestQueue.h2
-rw-r--r--cpp/src/IceGrid/Database.cpp2
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp4
4 files changed, 58 insertions, 19 deletions
diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp
index ef0beeb6b3b..f9b53f30e39 100644
--- a/cpp/src/Glacier2/RequestQueue.cpp
+++ b/cpp/src/Glacier2/RequestQueue.cpp
@@ -213,7 +213,8 @@ Glacier2::Response::invoke()
Glacier2::RequestQueue::RequestQueue(const IceUtil::Time& sleepTime) :
_sleepTime(sleepTime),
- _destroy(false)
+ _destroy(false),
+ _sleep(false)
{
}
@@ -234,6 +235,7 @@ Glacier2::RequestQueue::destroy()
assert(!_destroy);
_destroy = true;
+ _sleep = false;
notify();
}
@@ -274,7 +276,14 @@ Glacier2::RequestQueue::addRequest(const RequestPtr& request)
// No override, we add the new request.
//
_requests.push_back(request);
- notify();
+ if(!_sleep)
+ {
+ //
+ // No need to notify if the request queue thread is sleeping,
+ // once it wakes up it will check if there's requests to send.
+ //
+ notify();
+ }
return false;
}
@@ -305,9 +314,28 @@ Glacier2::RequestQueue::run()
// wait until all the responses for twoway requests are
// received.
//
- while((!_destroy || dispatchCount != 0) && _requests.empty() && _responses.empty())
- {
- wait();
+ while((!_destroy || dispatchCount != 0) && _responses.empty() && (_requests.empty() || _sleep))
+ {
+ if(_sleep)
+ {
+ IceUtil::Time now = IceUtil::Time::now();
+ if(!timedWait(_sleepDuration))
+ {
+ _sleepDuration = IceUtil::Time();
+ }
+ else
+ {
+ _sleepDuration -= IceUtil::Time::now() - now;
+ }
+ if(_sleepDuration <= IceUtil::Time())
+ {
+ _sleep = false;
+ }
+ }
+ else
+ {
+ wait();
+ }
}
//
@@ -320,8 +348,26 @@ Glacier2::RequestQueue::run()
return;
}
- requests.swap(_requests);
- responses.swap(_responses);
+ //
+ // If there's requests to sent and we're not sleeping,
+ // send the requests. If a sleep time is configured, we
+ // set the sleep duration and set the sleep flag to make
+ // sure we'll sleep again once we're done sending requests
+ // and responses.
+ //
+ if(!_requests.empty() && !_sleep)
+ {
+ requests.swap(_requests);
+ if(_sleepTime > IceUtil::Time())
+ {
+ _sleep = true;
+ _sleepDuration = _sleepTime;
+ }
+ }
+ if(!_responses.empty())
+ {
+ responses.swap(_responses);
+ }
}
//
@@ -378,14 +424,5 @@ Glacier2::RequestQueue::run()
(*r)->invoke();
}
dispatchCount -= responses.size();
-
- //
- // In order to avoid flooding, we add a delay, if so
- // requested.
- //
- if(_sleepTime > IceUtil::Time())
- {
- IceUtil::ThreadControl::sleep(_sleepTime);
- }
}
}
diff --git a/cpp/src/Glacier2/RequestQueue.h b/cpp/src/Glacier2/RequestQueue.h
index 2404ef61689..b09a8de3fa4 100644
--- a/cpp/src/Glacier2/RequestQueue.h
+++ b/cpp/src/Glacier2/RequestQueue.h
@@ -84,6 +84,8 @@ private:
std::vector<RequestPtr> _requests;
std::vector<ResponsePtr> _responses;
bool _destroy;
+ bool _sleep;
+ IceUtil::Time _sleepDuration;
};
}
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index 4f8c65bcdb0..523d6ec077c 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -1259,7 +1259,7 @@ Database::load(const ApplicationHelper& app, ServerEntrySeq& entries)
{
ObjectInfo info;
info.type = o->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
_objectCache.add(info, application);
}
}
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 3f64c713abd..8754d40f179 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -165,7 +165,7 @@ ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const Server
{
ObjectInfo info;
info.type = r->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(r->id) + "@" + q->id);
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
_objectCache.add(info, application);
}
@@ -173,7 +173,7 @@ ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm, const Server
{
ObjectInfo info;
info.type = r->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(r->id) + "@" + q->id);
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
_allocatableObjectCache.add(info, server);
}
}