Thrift Sixth session connection interruption does not clean worker threads properly

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.