diff options
author | Marc Laukien <marc@zeroc.com> | 2001-09-16 20:11:25 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-09-16 20:11:25 +0000 |
commit | c4fc439d096dc506c503b5cecb2e9a3cf86f6276 (patch) | |
tree | 53e755a2c697eebc0163668a7390fd615cc2b968 /cpp/src | |
parent | fixes for windows (diff) | |
download | ice-c4fc439d096dc506c503b5cecb2e9a3cf86f6276.tar.bz2 ice-c4fc439d096dc506c503b5cecb2e9a3cf86f6276.tar.xz ice-c4fc439d096dc506c503b5cecb2e9a3cf86f6276.zip |
fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Freeze/DBI.cpp | 61 | ||||
-rw-r--r-- | cpp/src/Freeze/DBI.h | 2 | ||||
-rw-r--r-- | cpp/src/Freeze/Makefile | 3 | ||||
-rw-r--r-- | cpp/src/IcePack/Client.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/Server.cpp | 2 |
5 files changed, 67 insertions, 3 deletions
diff --git a/cpp/src/Freeze/DBI.cpp b/cpp/src/Freeze/DBI.cpp index 1874803d7fd..6dda091275a 100644 --- a/cpp/src/Freeze/DBI.cpp +++ b/cpp/src/Freeze/DBI.cpp @@ -13,6 +13,7 @@ #include <Ice/Logger.h> #include <Ice/LocalException.h> #include <Freeze/DBI.h> +#include <sys/stat.h> using namespace std; using namespace Ice; @@ -49,6 +50,65 @@ Freeze::DBFactoryI::DBFactoryI(const CommunicatorPtr& communicator, const Proper _properties(properties), _destroy(false) { + string directory = _properties->getProperty("Freeze.Directory"); + +// +// TODO: Should we really try to create the directory? Perhaps we +// better leave this task to the administrator, and simply let DB fail +// in case the directory does not exist. +// +/* + if(!directory.empty()) + { + // + // Check whether the directory exists. If yes, we don't need + // to create it. Note that we don't further check the type of + // the file, DB will fail appropriately if it's the wrong + // time. + // + struct stat sb; + if (stat(directory.c_str(), &sb) == 0) + { + // + // Directory does not exist, create it. + // + if (mkdir(directory.c_str(), S_IRWXU) != 0) + { + throw SystemException(__FILE__, __LINE__); + } + } + } +*/ + + int ret; + + if ((ret = db_env_create(&_dbenv, 0)) != 0) + { + DBException ex; + ex.message = db_strerror(ret); + throw ex; + } + + const char* dir = 0; + if (!directory.empty()) + { + dir = directory.c_str(); + } + + if ((ret = _dbenv->open(_dbenv, dir, + DB_CREATE | + DB_INIT_LOCK | + DB_INIT_LOG | + DB_INIT_MPOOL | + DB_INIT_TXN | + DB_RECOVER | + DB_THREAD, + S_IRUSR | S_IWUSR)) != 0) + { + DBException ex; + ex.message = db_strerror(ret); + throw ex; + } } Freeze::DBFactoryI::~DBFactoryI() @@ -70,3 +130,4 @@ Freeze::initializeWithProperties(const CommunicatorPtr& communicator, const Prop { return new DBFactoryI(communicator, properties); } + diff --git a/cpp/src/Freeze/DBI.h b/cpp/src/Freeze/DBI.h index 2c8c7f7ec3e..60f41a95a3d 100644 --- a/cpp/src/Freeze/DBI.h +++ b/cpp/src/Freeze/DBI.h @@ -13,6 +13,7 @@ #include <Freeze/Initialize.h> #include <Freeze/DB.h> +#include <db.h> namespace Freeze { @@ -36,6 +37,7 @@ private: ::Ice::CommunicatorPtr _communicator; ::Ice::PropertiesPtr _properties; bool _destroy; + DB_ENV* _dbenv; }; } diff --git a/cpp/src/Freeze/Makefile b/cpp/src/Freeze/Makefile index cfec4712aed..a5462526aaf 100644 --- a/cpp/src/Freeze/Makefile +++ b/cpp/src/Freeze/Makefile @@ -29,7 +29,8 @@ SLICECMD = $(SLICE) --include-dir Freeze --dll-export FREEZE_API -I$(slicedir) include $(top_srcdir)/config/Make.rules -CPPFLAGS := -I.. $(CPPFLAGS) +CPPFLAGS := -I.. $(CPPFLAGS) -I$(DB)/include +LDLAGS := $(LDFLAGS) -I$(DB)/lib $(VERSIONED_NAME): $(OBJS) rm -f $@ diff --git a/cpp/src/IcePack/Client.cpp b/cpp/src/IcePack/Client.cpp index 8b2c461a0fe..c4853e153d1 100644 --- a/cpp/src/IcePack/Client.cpp +++ b/cpp/src/IcePack/Client.cpp @@ -34,7 +34,7 @@ usage(const char* n) } int -run(int argc, char* argv[], CommunicatorPtr communicator) +run(int argc, char* argv[], const CommunicatorPtr& communicator) { string cpp("cpp"); string commands; diff --git a/cpp/src/IcePack/Server.cpp b/cpp/src/IcePack/Server.cpp index e48c8725751..d9e35785e68 100644 --- a/cpp/src/IcePack/Server.cpp +++ b/cpp/src/IcePack/Server.cpp @@ -29,7 +29,7 @@ usage(const char* n) } int -run(int argc, char* argv[], CommunicatorPtr communicator) +run(int argc, char* argv[], const CommunicatorPtr& communicator) { bool nowarn = false; for (int i = 1; i < argc; ++i) |