diff options
author | Stephen D. Huston <shuston@apache.org> | 2008-10-07 15:19:50 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2008-10-07 15:19:50 +0000 |
commit | 4eb2dca5b9ae07228f542cd798b44cc44ea96c09 (patch) | |
tree | 9d1de3abe8bca9ff0617432056217bfab12b00f5 /cpp/src/qpid/broker/Daemon.cpp | |
parent | cdae2a877123056b69a91dd8ca2196577654de2d (diff) | |
download | qpid-python-4eb2dca5b9ae07228f542cd798b44cc44ea96c09.tar.gz |
Abstract native file-locking and directory detection/creation to portable classes LockFile and FileSysDir; resolves QPID-1148
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@702513 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/Daemon.cpp')
-rw-r--r-- | cpp/src/qpid/broker/Daemon.cpp | 23 |
1 files changed, 3 insertions, 20 deletions
diff --git a/cpp/src/qpid/broker/Daemon.cpp b/cpp/src/qpid/broker/Daemon.cpp index 1796c8db04..8790653c8d 100644 --- a/cpp/src/qpid/broker/Daemon.cpp +++ b/cpp/src/qpid/broker/Daemon.cpp @@ -168,22 +168,14 @@ void Daemon::ready(uint16_t port) { // child LockFile lf(lockFile, true); /* - * Rewritten using low-level IO, for compatibility - * with earlier Boost versions, i.e. 103200. - */ - /* * Write the PID to the lockfile. */ - pid_t pid = getpid(); - int desired_write = sizeof(pid_t); - if ( desired_write > ::write(lf.fd, & pid, desired_write) ) { - throw Exception("Cannot write lock file "+lockFile); - } + lf.writePid(); /* * Write the port number to the parent. */ - desired_write = sizeof(uint16_t); + int desired_write = sizeof(uint16_t); if ( desired_write > ::write(pipeFds[1], & port, desired_write) ) { throw Exception("Error writing to parent." ); } @@ -198,16 +190,7 @@ void Daemon::ready(uint16_t port) { // child pid_t Daemon::getPid(string _pidDir, uint16_t port) { string name = pidFile(_pidDir, port); LockFile lf(name, false); - pid_t pid; - - /* - * Rewritten using low-level IO, for compatibility - * with earlier Boost versions, i.e. 103200. - */ - int desired_read = sizeof(pid_t); - if ( desired_read > ::read(lf.fd, & pid, desired_read) ) { - throw Exception("Cannot read lock file " + name); - } + pid_t pid = lf.readPid(); if (kill(pid, 0) < 0 && errno != EPERM) { unlink(name.c_str()); throw Exception("Removing stale lock file "+name); |