a lot of CLOSE_WAIT in fbthrift server,How to fix it #610
Open
Description
version 2022.10.10.00
server code
namespace apache {
namespace thrift {
template <typename T> class MyEvbAsyncProcessorFactory : public AsyncProcessorFactory {
public:
explicit MyEvbAsyncProcessorFactory(std::shared_ptr<T> t) { svIf_ = t; }
std::unique_ptr<apache::thrift::AsyncProcessor> getProcessor() override
{
return std::unique_ptr<apache::thrift::AsyncProcessor>(new typename T::ProcessorType(svIf_.get()));
}
std::vector<ServiceHandlerBase*> getServiceHandlers() override { return {svIf_.get()}; }
CreateMethodMetadataResult createMethodMetadata() override
{
WildcardMethodMetadataMap wildcardMap;
wildcardMap.wildcardMetadata =
std::make_shared<WildcardMethodMetadata>(AsyncProcessorFactory::MethodMetadata::ExecutorType::EVB);
wildcardMap.knownMethods = {};
return wildcardMap;
}
private:
std::shared_ptr<T> svIf_;
};
} // namespace thrift
} // namespace apache
auto handler = std::make_shared<Handler>();
auto procFactory = std::make_shared<apache::thrift::MyEvbAsyncProcessorFactory<Handler>>(handler);
int ret = handler->init(*initParam_);
if (ret != 0) {
std::cout << "handler init failed" << endl;
return nullptr;
}
auto server = std::make_unique<ThriftServer>();
server->setPort(initParam_->common.port);
server->setProcessorFactory(procFactory);
server->setMaxConnections(param.common.maxConn);
server->setNumIOWorkerThreads(param.common.maxConn);
server->setNumCPUWorkerThreads(param.common.workerCount);
server->setIdleTimeout(std::chrono::milliseconds(0));
server->setConnectionAgeTimeout(std::chrono::milliseconds(0));
server->setStreamExpireTime(std::chrono::milliseconds(0));
[root@]# netstat -ae|grep "CLOSE_WAIT" | wc -l
897
Metadata
Assignees
Labels
No labels