From 4b5a66d78efd8e9bed92a68ceb6eb49cbd7cc292 Mon Sep 17 00:00:00 2001 From: "Stephen D. Huston" Date: Wed, 5 Aug 2009 17:17:30 +0000 Subject: Try to create piddir if needed; on error throw a useful message. Fixes QPID-2030 git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@801315 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/windows/QpiddBroker.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cpp/src/windows') diff --git a/cpp/src/windows/QpiddBroker.cpp b/cpp/src/windows/QpiddBroker.cpp index a22ccba63f..5c6eef48f8 100644 --- a/cpp/src/windows/QpiddBroker.cpp +++ b/cpp/src/windows/QpiddBroker.cpp @@ -223,6 +223,17 @@ int QpiddBroker::execute (QpiddOptions *options) { options->broker.port = brokerPtr->getPort(""); std::cout << options->broker.port << std::endl; + // Make sure the pid directory exists, creating if needed. LockFile + // will throw an exception that makes little sense if it can't create + // the file. + if (!CreateDirectory(myOptions->control.piddir.c_str(), 0)) { + DWORD err = GetLastError(); + if (err != ERROR_ALREADY_EXISTS) + throw qpid::Exception(QPID_MSG("Can't create pid-dir " + + myOptions->control.piddir + + ": " + + qpid::sys::strError(err))); + } qpid::sys::LockFile myPid(brokerPidFile(myOptions->control.piddir, options->broker.port), true); -- cgit v1.2.1