summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Glacier2/RoutingTable.h1
-rw-r--r--cpp/src/IceGrid/Cache.h6
-rw-r--r--cpp/src/IceGrid/ObjectCache.cpp2
-rw-r--r--cpp/src/IceGrid/ServerI.cpp47
-rw-r--r--cpp/src/IcePatch2/Util.cpp2
5 files changed, 44 insertions, 14 deletions
diff --git a/cpp/src/Glacier2/RoutingTable.h b/cpp/src/Glacier2/RoutingTable.h
index 816ae360f61..42f65de7e22 100644
--- a/cpp/src/Glacier2/RoutingTable.h
+++ b/cpp/src/Glacier2/RoutingTable.h
@@ -42,6 +42,7 @@ private:
typedef std::map<Ice::Identity, EvictorEntryPtr> EvictorMap;
typedef std::list<EvictorMap::iterator> EvictorQueue;
+ friend struct EvictorEntry;
struct EvictorEntry : public IceUtil::Shared
{
Ice::ObjectPrx proxy;
diff --git a/cpp/src/IceGrid/Cache.h b/cpp/src/IceGrid/Cache.h
index 2480f4b1807..51d7e9dcc57 100644
--- a/cpp/src/IceGrid/Cache.h
+++ b/cpp/src/IceGrid/Cache.h
@@ -63,7 +63,7 @@ protected:
getImpl(const Key& key) const
{
typename ValueMap::iterator p = const_cast<ValueMap&>(_entries).end();
- if(_entriesHint != _entries.end())
+ if(_entriesHint != p)
{
if(_entriesHint->first == key)
{
@@ -71,12 +71,12 @@ protected:
}
}
- if(p == _entries.end())
+ if(p == const_cast<ValueMap&>(_entries).end())
{
p = const_cast<ValueMap&>(_entries).find(key);
}
- if(p != _entries.end())
+ if(p != const_cast<ValueMap&>(_entries).end())
{
const_cast<typename ValueMap::iterator&>(_entriesHint) = p;
return p->second;
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp
index 95f98c99742..18aaee8964d 100644
--- a/cpp/src/IceGrid/ObjectCache.cpp
+++ b/cpp/src/IceGrid/ObjectCache.cpp
@@ -161,7 +161,7 @@ ObjectCache::add(const ObjectInfo& info, const string& application, bool allocat
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- p = _types.insert(p, make_pair(entry->getType(), TypeEntry()));
+ p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
}
p->second.add(entry);
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 2544c99dad5..08b8015d2cd 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -24,14 +24,14 @@
#include <sys/stat.h>
#ifdef _WIN32
-# include <direct.h>
-# include <signal.h>
+# include <direct.h>
+# include <signal.h>
#else
-# include <sys/wait.h>
-# include <pwd.h> // for getpwnam
-# include <signal.h>
-# include <unistd.h>
-# include <dirent.h>
+# include <sys/wait.h>
+# include <pwd.h> // for getpwnam
+# include <signal.h>
+# include <unistd.h>
+# include <dirent.h>
#endif
#include <fstream>
@@ -46,9 +46,36 @@ namespace IceGrid
void
chownRecursive(const string& path, uid_t uid, gid_t gid)
{
- struct dirent **namelist;
- int n = scandir(path.c_str(), &namelist, 0, alphasort);
- if(n < 0)
+ struct dirent **namelist = 0;
+ DIR* d;
+ if((d = opendir(path.c_str())) == 0)
+ {
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ }
+
+ struct dirent* entry;
+ int n = 0;
+ while((entry = readdir(d)) != 0)
+ {
+ namelist = (struct dirent**)realloc((void*)namelist, (size_t)((n + 1) * sizeof(struct dirent*)));
+ if(namelist == 0)
+ {
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ }
+
+ size_t entrysize = sizeof(struct dirent) - sizeof(entry->d_name) + strlen(entry->d_name) + 1;
+ namelist[n] = (struct dirent*)malloc(entrysize);
+ if(namelist[n] == 0)
+ {
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ }
+ memcpy(namelist[n], entry, entrysize);
+ ++n;
+ }
+
+ if(closedir(d))
{
throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index fc59fd6393e..6d50e29f14c 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -64,6 +64,7 @@ scandir(const char* dir, struct dirent*** namelist,
*namelist = (struct dirent**)realloc((void*)(*namelist), (size_t)((i + 1) * sizeof(struct dirent*)));
if(*namelist == 0)
{
+ closedir(d);
return -1;
}
@@ -71,6 +72,7 @@ scandir(const char* dir, struct dirent*** namelist,
(*namelist)[i] = (struct dirent*)malloc(entrysize);
if((*namelist)[i] == 0)
{
+ closedir(d);
return -1;
}
memcpy((*namelist)[i], entry, entrysize);