Thrift lesson 7 server multithreading sends exception

Scenes

The C++ server side establishes multi-threaded sending for each client, without adding a lock, an exception will be triggered: received invalid message type 3 from client. Causes the server to actively disconnect from the client

The code that prints the error is in the TDispatchProcessor.h file

Relevant stack code:

  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++


in conclusion

It is best to lock the interface that calls the send, or send it in a single thread


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325163118&siteId=291194637
Recommended