summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2008-06-03 18:19:29 +0000
committerTed Ross <tross@apache.org>2008-06-03 18:19:29 +0000
commita60d332b358f41205f1f862dc2de9d15b2802ded (patch)
tree06bfef6ae94b880f675b04130e1d9ae1688c0ab8 /qpid/cpp/src
parentc2774f9db2ae2c5fdf339ac6ec4e40d35dea24bf (diff)
downloadqpid-python-a60d332b358f41205f1f862dc2de9d15b2802ded.tar.gz
QPID-1114 Change defaults for data-dir and pid-dir to /home/ross/.qpidd
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@662854 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/DataDir.cpp14
-rw-r--r--qpid/cpp/src/qpid/broker/Broker.cpp9
-rw-r--r--qpid/cpp/src/qpidd.cpp10
3 files changed, 27 insertions, 6 deletions
diff --git a/qpid/cpp/src/qpid/DataDir.cpp b/qpid/cpp/src/qpid/DataDir.cpp
index 5fa26082b3..e9c6aaad53 100644
--- a/qpid/cpp/src/qpid/DataDir.cpp
+++ b/qpid/cpp/src/qpid/DataDir.cpp
@@ -41,8 +41,14 @@ DataDir::DataDir (std::string path) :
const char *cpath = dirPath.c_str ();
struct stat s;
- if (::stat (cpath, &s))
- throw Exception ("Data directory not found: " + path);
+ if (::stat(cpath, &s)) {
+ if (errno == ENOENT) {
+ if (::mkdir(cpath, 0755))
+ throw Exception ("Can't create data directory: " + path);
+ }
+ else
+ throw Exception ("Data directory not found: " + path);
+ }
std::string lockFile (path);
lockFile = lockFile + "/lock";
@@ -51,9 +57,9 @@ DataDir::DataDir (std::string path) :
if (fd == -1)
{
if (errno == EEXIST)
- throw Exception ("Data directory is locked by another process");
+ throw Exception ("Data directory is locked by another process: " + path);
if (errno == EACCES)
- throw Exception ("Insufficient privileges for data directory");
+ throw Exception ("Insufficient privileges for data directory: " + path);
throw Exception(
QPID_MSG("Error locking " << lockFile << ": " << strError(errno)));
}
diff --git a/qpid/cpp/src/qpid/broker/Broker.cpp b/qpid/cpp/src/qpid/broker/Broker.cpp
index 2992ea45cf..4636b94371 100644
--- a/qpid/cpp/src/qpid/broker/Broker.cpp
+++ b/qpid/cpp/src/qpid/broker/Broker.cpp
@@ -76,7 +76,6 @@ namespace broker {
Broker::Options::Options(const std::string& name) :
qpid::Options(name),
noDataDir(0),
- dataDir("/var/lib/qpidd"),
port(DEFAULT_PORT),
workerThreads(5),
maxConnections(500),
@@ -90,6 +89,14 @@ Broker::Options::Options(const std::string& name) :
{
int c = sys::SystemInfo::concurrency();
workerThreads=c+1;
+ char *home = ::getenv("HOME");
+
+ if (home == 0)
+ home = "/tmp";
+
+ dataDir += home;
+ dataDir += "/.qpidd";
+
addOptions()
("data-dir", optValue(dataDir,"DIR"), "Directory to contain persistent data generated by the broker")
("no-data-dir", optValue(noDataDir), "Don't use a data directory. No persistent configuration will be loaded or stored")
diff --git a/qpid/cpp/src/qpidd.cpp b/qpid/cpp/src/qpidd.cpp
index d5f570b458..ab4de50a2d 100644
--- a/qpid/cpp/src/qpidd.cpp
+++ b/qpid/cpp/src/qpidd.cpp
@@ -62,8 +62,16 @@ struct DaemonOptions : public qpid::Options {
int wait;
std::string piddir;
- DaemonOptions() : qpid::Options("Daemon options"), daemon(false), quit(false), check(false), wait(10), piddir("/tmp")
+ DaemonOptions() : qpid::Options("Daemon options"), daemon(false), quit(false), check(false), wait(10)
{
+ char *home = ::getenv("HOME");
+
+ if (home == 0)
+ home = "/tmp";
+
+ piddir += home;
+ piddir += "/.qpidd";
+
addOptions()
("daemon,d", optValue(daemon), "Run as a daemon.")
("pid-dir", optValue(piddir, "DIR"), "Directory where port-specific PID file is stored")