diff options
Diffstat (limited to 'cpp/src/qpid')
| -rw-r--r-- | cpp/src/qpid/DataDir.cpp | 14 | ||||
| -rw-r--r-- | cpp/src/qpid/broker/Broker.cpp | 9 |
2 files changed, 18 insertions, 5 deletions
diff --git a/cpp/src/qpid/DataDir.cpp b/cpp/src/qpid/DataDir.cpp index 5fa26082b3..e9c6aaad53 100644 --- a/cpp/src/qpid/DataDir.cpp +++ b/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/cpp/src/qpid/broker/Broker.cpp b/cpp/src/qpid/broker/Broker.cpp index 2992ea45cf..4636b94371 100644 --- a/cpp/src/qpid/broker/Broker.cpp +++ b/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") |
