Author: gsim
Date: Tue May 13 09:44:59 2008
New Revision: 655944
URL: http://svn.apache.org/viewvc?rev=655944&view=rev
Log:
QPID-1054: Fixed reporting of startup failures in daemon mode.
Modified:
incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Daemon.cpp
Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Daemon.cpp
URL:
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Daemon.cpp?rev=655944&r1=655943&r2=655944&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Daemon.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/broker/Daemon.cpp Tue May 13
09:44:59 2008
@@ -118,11 +118,13 @@
}
catch (const exception& e) {
QPID_LOG(critical, "Daemon startup failed: " << e.what());
- stringstream pipeFailureMessage;
- pipeFailureMessage << "0 " << e.what() << endl;
+ uint16_t port = 0;
+ write(pipeFds[1], &port, sizeof(uint16_t));
+
+ std::string pipeFailureMessage = e.what();
write ( pipeFds[1],
- pipeFailureMessage.str().c_str(),
- strlen(pipeFailureMessage.str().c_str())
+ pipeFailureMessage.c_str(),
+ strlen(pipeFailureMessage.c_str())
);
}
}
@@ -176,11 +178,11 @@
// Get Message
string errmsg;
- while ( 1 ) {
- if ( 1 > ::read(pipeFds[0], &c, 1) )
- throw Exception("Daemon startup failed"+
- (errmsg.empty() ? string(".") : ": " + errmsg));
- }
+ do {
+ errmsg += c;
+ } while (::read(pipeFds[0], &c, 1));
+ throw Exception("Daemon startup failed"+
+ (errmsg.empty() ? string(".") : ": " + errmsg));
}
return port;