shared_ptr<BoostThread> thread = *(shared_ptr<BoostThread>*)arg;
delete reinterpret_cast<shared_ptr<BoostThread>*>(arg);
- if (thread == NULL) {
+ if (!thread) {
return (void*)0;
}
}
}
- if (task != NULL) {
+ if (task) {
if (task->state_ == ThreadManager::Task::EXECUTING) {
try {
task->run();
{
Synchronized s(monitor_);
if (state_ == ThreadManager::UNINITIALIZED) {
- if (threadFactory_ == NULL) {
+ if (!threadFactory_) {
throw InvalidArgumentException();
}
state_ = ThreadManager::STARTED;
bool doStart = false;
{
Synchronized s(monitor_);
- if (threadFactory_ == NULL) {
+ if (!threadFactory_) {
throw InvalidArgumentException();
}
if (state_ == TimerManager::UNINITIALIZED) {
void run() {
try {
for (;;) {
- if (serverEventHandler_ != NULL) {
+ if (serverEventHandler_) {
serverEventHandler_->processContext(connectionContext_, connection_->getTSocket());
}
if (!processor_->process(input_, output_, connectionContext_) ||
// Set up for any server event handler
serverEventHandler_ = server_->getEventHandler();
- if (serverEventHandler_ != NULL) {
+ if (serverEventHandler_) {
connectionContext_ = serverEventHandler_->createContext(inputProtocol_,
outputProtocol_);
} else {
return;
} else {
try {
- if (serverEventHandler_ != NULL) {
- serverEventHandler_->processContext(connectionContext_,
- getTSocket());
- }
+ if (serverEventHandler_) {
+ serverEventHandler_->processContext(connectionContext_,
+ getTSocket());
+ }
// Invoke the processor
processor_->process(inputProtocol_, outputProtocol_,
connectionContext_);
GlobalOutput.perror("TConnection::close() event_del", THRIFT_GET_SOCKET_ERROR);
}
- if (serverEventHandler_ != NULL) {
+ if (serverEventHandler_) {
serverEventHandler_->deleteContext(connectionContext_, inputProtocol_, outputProtocol_);
}
ioThread_ = NULL;
void TNonblockingServer::setThreadManager(boost::shared_ptr<ThreadManager> threadManager) {
threadManager_ = threadManager;
- if (threadManager != NULL) {
+ if (threadManager) {
threadManager->setExpireCallback(apache::thrift::stdcxx::bind(&TNonblockingServer::expireClose, this, apache::thrift::stdcxx::placeholders::_1));
threadPoolProcessing_ = true;
} else {
}
// Notify handler of the preServe event
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->preServe();
}
serverTransport_->listen();
// Run the preServe event
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->preServe();
}
inputProtocol = inputProtocolFactory_->getProtocol(inputTransport);
outputProtocol = outputProtocolFactory_->getProtocol(outputTransport);
} catch (TTransportException& ttx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
string errStr = string("TServerTransport died on accept: ") + ttx.what();
GlobalOutput(errStr.c_str());
}
continue;
} catch (TException& tx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = string("Some kind of accept exception: ") + tx.what();
GlobalOutput(errStr.c_str());
continue;
} catch (string s) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = string("Some kind of accept exception: ") + s;
GlobalOutput(errStr.c_str());
break;
outputProtocol, client);
void* connectionContext = NULL;
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
connectionContext = eventHandler_->createContext(inputProtocol, outputProtocol);
}
try {
for (;;) {
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->processContext(connectionContext, client);
}
if (!processor->process(inputProtocol, outputProtocol,
} catch (...) {
GlobalOutput("TSimpleServer uncaught exception.");
}
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->deleteContext(connectionContext, inputProtocol, outputProtocol);
}
boost::shared_ptr<TServerEventHandler> eventHandler =
server_.getEventHandler();
void* connectionContext = NULL;
- if (eventHandler != NULL) {
+ if (eventHandler) {
connectionContext = eventHandler->createContext(input_, output_);
}
try {
for (;;) {
- if (eventHandler != NULL) {
+ if (eventHandler) {
eventHandler->processContext(connectionContext, transport_);
}
if (!processor_->process(input_, output_, connectionContext) ||
"TThreadPoolServer::Task::run()");
}
- if (eventHandler != NULL) {
+ if (eventHandler) {
eventHandler->deleteContext(connectionContext, input_, output_);
}
serverTransport_->listen();
// Run the preServe event
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->preServe();
}
threadManager_->add(task, timeout_, taskExpiration_);
} catch (TTransportException& ttx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
string errStr = string("TThreadPoolServer: TServerTransport died on accept: ") + ttx.what();
GlobalOutput(errStr.c_str());
}
continue;
} catch (TException& tx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = string("TThreadPoolServer: Caught TException: ") + tx.what();
GlobalOutput(errStr.c_str());
continue;
} catch (string s) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = "TThreadPoolServer: Unknown exception: " + s;
GlobalOutput(errStr.c_str());
break;
boost::shared_ptr<TServerEventHandler> eventHandler =
server_.getEventHandler();
void* connectionContext = NULL;
- if (eventHandler != NULL) {
+ if (eventHandler) {
connectionContext = eventHandler->createContext(input_, output_);
}
try {
for (;;) {
- if (eventHandler != NULL) {
+ if (eventHandler) {
eventHandler->processContext(connectionContext, transport_);
}
if (!processor_->process(input_, output_, connectionContext) ||
} catch (...) {
GlobalOutput("TThreadedServer uncaught exception.");
}
- if (eventHandler != NULL) {
+ if (eventHandler) {
eventHandler->deleteContext(connectionContext, input_, output_);
}
serverTransport_->listen();
// Run the preServe event
- if (eventHandler_ != NULL) {
+ if (eventHandler_) {
eventHandler_->preServe();
}
thread->start();
} catch (TTransportException& ttx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
if (!stop_ || ttx.getType() != TTransportException::INTERRUPTED) {
string errStr = string("TThreadedServer: TServerTransport died on accept: ") + ttx.what();
GlobalOutput(errStr.c_str());
}
continue;
} catch (TException& tx) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = string("TThreadedServer: Caught TException: ") + tx.what();
GlobalOutput(errStr.c_str());
continue;
} catch (string s) {
- if (inputTransport != NULL) { inputTransport->close(); }
- if (outputTransport != NULL) { outputTransport->close(); }
- if (client != NULL) { client->close(); }
+ if (inputTransport) { inputTransport->close(); }
+ if (outputTransport) { outputTransport->close(); }
+ if (client) { client->close(); }
string errStr = "TThreadedServer: Unknown exception: " + s;
GlobalOutput(errStr.c_str());
break;
*/
boost::shared_ptr<TTransport> accept() {
boost::shared_ptr<TTransport> result = acceptImpl();
- if (result == NULL) {
+ if (!result) {
throw TTransportException("accept() may not return NULL");
}
return result;