mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-1563 thrift: make serve() throw an exception if it fails
Patch: Dave Watson git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1325026 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ec8027ffad
commit
d8f50f3ffe
@ -1024,9 +1024,8 @@ void TNonblockingServer::createAndListenOnSocket() {
|
||||
// Wildcard address
|
||||
error = getaddrinfo(NULL, port, &hints, &res0);
|
||||
if (error) {
|
||||
string errStr = "TNonblockingServer::serve() getaddrinfo " + string(gai_strerror(error));
|
||||
GlobalOutput(errStr.c_str());
|
||||
return;
|
||||
throw TException("TNonblockingServer::serve() getaddrinfo " +
|
||||
string(gai_strerror(error)));
|
||||
}
|
||||
|
||||
// Pick the ipv6 address first since ipv4 addresses can be mapped
|
||||
@ -1061,7 +1060,9 @@ void TNonblockingServer::createAndListenOnSocket() {
|
||||
if (::bind(s, res->ai_addr, res->ai_addrlen) == -1) {
|
||||
::close(s);
|
||||
freeaddrinfo(res0);
|
||||
throw TException("TNonblockingServer::serve() bind");
|
||||
throw TTransportException(TTransportException::NOT_OPEN,
|
||||
"TNonblockingServer::serve() bind",
|
||||
errno);
|
||||
}
|
||||
|
||||
// Done with the addr info
|
||||
|
@ -42,14 +42,8 @@ void TSimpleServer::serve() {
|
||||
shared_ptr<TProtocol> inputProtocol;
|
||||
shared_ptr<TProtocol> outputProtocol;
|
||||
|
||||
try {
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
} catch (TTransportException& ttx) {
|
||||
string errStr = string("TSimpleServer::run() listen(): ") + ttx.what();
|
||||
GlobalOutput(errStr.c_str());
|
||||
return;
|
||||
}
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
|
||||
// Run the preServe event
|
||||
if (eventHandler_ != NULL) {
|
||||
|
@ -121,14 +121,8 @@ void TThreadPoolServer::serve() {
|
||||
shared_ptr<TProtocol> inputProtocol;
|
||||
shared_ptr<TProtocol> outputProtocol;
|
||||
|
||||
try {
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
} catch (TTransportException& ttx) {
|
||||
string errStr = string("TThreadPoolServer::run() listen(): ") + ttx.what();
|
||||
GlobalOutput(errStr.c_str());
|
||||
return;
|
||||
}
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
|
||||
// Run the preServe event
|
||||
if (eventHandler_ != NULL) {
|
||||
|
@ -139,14 +139,8 @@ void TThreadedServer::serve() {
|
||||
shared_ptr<TProtocol> inputProtocol;
|
||||
shared_ptr<TProtocol> outputProtocol;
|
||||
|
||||
try {
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
} catch (TTransportException& ttx) {
|
||||
string errStr = string("TThreadedServer::run() listen(): ") +ttx.what();
|
||||
GlobalOutput(errStr.c_str());
|
||||
return;
|
||||
}
|
||||
// Start the server listening
|
||||
serverTransport_->listen();
|
||||
|
||||
// Run the preServe event
|
||||
if (eventHandler_ != NULL) {
|
||||
|
@ -342,7 +342,8 @@ void TServerSocket::listen() {
|
||||
}
|
||||
GlobalOutput(errbuf);
|
||||
close();
|
||||
throw TTransportException(TTransportException::NOT_OPEN, "Could not bind");
|
||||
throw TTransportException(TTransportException::NOT_OPEN, "Could not bind",
|
||||
errno);
|
||||
}
|
||||
|
||||
// Call listen
|
||||
|
Loading…
Reference in New Issue
Block a user