場景
C++服務器端爲每一個客戶端建立多線程發送,沒有添加鎖,會觸發異常:received invalid message type 3 from client。導致服務器端主動斷開跟客戶端的連接
打印出錯的代碼在TDispatchProcessor.h文件
相關堆棧代碼:
apache::thrift::TOutput::errorTimeWrapper(const char * msg) 行 134 C++
apache::thrift::TOutput::printf(const char * message, ...) 行 42 C++
apache::thrift::TDispatchProcessor::process(boost::shared_ptr<apache::thrift::protocol::TProtocol> in,boost::shared_ptr<apache::thrift::protocol::TProtocol> out, void * connectionContext) 行 116 C++
結論
調用發送的接口最好加鎖,或者是單線程發送