summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-12-13 18:22:50 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-12-13 18:22:50 +0000
commitbc5160534bc886da1612f4d76e40784c3651fc84 (patch)
treee7fd1f277b262f83013a8b43da4725412f82c144 /cpp/src
parent- Adding file list for 'ca' scripts. (diff)
downloadice-bc5160534bc886da1612f4d76e40784c3651fc84.tar.bz2
ice-bc5160534bc886da1612f4d76e40784c3651fc84.tar.xz
ice-bc5160534bc886da1612f4d76e40784c3651fc84.zip
Fixed bug 1617
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/AdminSessionI.cpp2
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp2
-rw-r--r--cpp/src/IceGrid/FileCache.cpp31
3 files changed, 28 insertions, 7 deletions
diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp
index 00f4439fb31..387a55c7533 100644
--- a/cpp/src/IceGrid/AdminSessionI.cpp
+++ b/cpp/src/IceGrid/AdminSessionI.cpp
@@ -28,7 +28,7 @@ FileIteratorI::FileIteratorI(const AdminSessionIPtr& session,
_reader(reader),
_filename(filename),
_offset(offset),
- _messageSizeMax(messageSizeMax)
+ _messageSizeMax(messageSizeMax - 256) // Room for the header
{
}
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 6ce57529e98..ba297e1c244 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -1764,7 +1764,7 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
for(PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin();
p != _def.servicePropertySets.end(); ++p)
{
- _instance.servicePropertySets.insert(make_pair(p->first, svrResolve(p->second)));
+ _instance.servicePropertySets.insert(make_pair(svrResolve(p->first), svrResolve(p->second)));
}
}
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index f6cbce81264..4f03160eeea 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -19,8 +19,8 @@
using namespace std;
using namespace IceGrid;
-FileCache::FileCache(const Ice::CommunicatorPtr& communicator) :
- _messageSizeMax(communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024)
+FileCache::FileCache(const Ice::CommunicatorPtr& com) :
+ _messageSizeMax(com->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024 - 256)
{
}
@@ -119,6 +119,11 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
size = _messageSizeMax;
}
+ if(size <= 5)
+ {
+ throw FileNotAvailableException("maximum bytes per read request is too low");
+ }
+
ifstream is(file.c_str());
if(is.fail())
{
@@ -148,12 +153,28 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
#else
is.seekg(static_cast<streampos>(offset));
#endif
- int totalSize = 1024; // Some room for the message header.
+ int totalSize = 0;
string line;
- for(int i = 0; is.good() && totalSize < size; ++i)
+ for(int i = 0; is.good(); ++i)
{
getline(is, line);
- totalSize += line.size() + 5; // 5 bytes for the encoding of the string size (worst case scenario)
+ int lineSize = line.size() + 5; // 5 bytes for the encoding of the string size (worst case scenario)
+ if(lineSize + totalSize > size)
+ {
+ if(size - totalSize - 5) // If there's some room left for a part of the string, return a partial string
+ {
+ line.substr(0, size - totalSize - 5);
+ lines.push_back(line);
+ newOffset += line.size();
+ }
+ else
+ {
+ lines.push_back("");
+ }
+ break;
+ }
+
+ totalSize += lineSize;
if(!is.fail())
{
newOffset = is.tellg();