1) inherit the Tservereventhandler class, get the basic information of the connecting user including IP and port, so as to monitor whether to save the connection without purging
The Tservereventhandler class provides a way for the socket to be processed when the user connects and disconnects, which provides two functions
Createcontext is called when a new user is connected
Deletecontext is called when the user finishes the request processing
The detailed process can be viewed Tthreadpoolserver::task,task as the inner class of the tthreadpoolserver, within the Task::run function, when there is a connection coming in, Gets the object of the Tservereventhandler class, determines whether there is an instantiation, processes the connection, and the detailed code
Boost::shared_ptr<tservereventhandler>eventhandler =
Server_.geteventhandler ();
void* connectioncontext = NULL;
if (eventHandler! = NULL)
{
ConnectionContext =eventhandler->createcontext (Input_, output_);
}
Reference
http://blog.csdn.net/hbuxiaoshe/article/details/38942869
2) in the actual application, create a certain number of worker threads for the user to connect to the service, found that after the user abnormal interruption, the worker thread can not be properly deconstructed, resulting in the worker thread running out of the thread pool
Problem
1) The client does not call the close interface, close the connection, the server side only a unique closesocket code, the output string is \x1, currently do not know where to close the socket
2) How the thread waits for an event request when it is idle
3) What is the specific meaning of the Pendingtaskcountmax_ parameter?
4) IsOpen function is only to ensure that the connection is successful, if the connection succeeds, if the server is disconnected or the client disconnects, this time to determine the return value of the IsOpen function is not any effect, this time only through the thrift of its own disconnected detection mechanism, It is not yet known what time the connection will be released
Thrift Sixth session connection interruption does not clean worker threads properly