[Nginx] epoll event Driver Module

Source: Internet
Author: User
Tags epoll

When a process calls the epoll_create method, the Linux kernel creates an eventpoll struct, which has two Members closely related to epoll usage.

Struct eventpoll

{

Struct rb_root RBR; // root node of the red/black tree, which stores all the events added to epoll, that is, the epoll monitoring event.

Struct list_head rdllist; // two-way linked list rdllist stores the events that meet the conditions to be returned to the user through epoll_wait

};

Each epoll object has an independent eventpoll structure. This structure creates an independent memory in the kernel space to store events added to the epoll object using the epoll_ctl method. These events are all mounted to the RBR red/black tree. In this way, repeated events can be efficiently identified by the red/black tree.

When an event occurs, the callback method is called here. This callback method is called ep_poll_callback in the kernel. It stores such an event in the preceding rdllist bidirectional linked list. When epoll_wait is called to check whether there is an event connection, it only checks whether the rdllist bidirectional linked list in the eventepoll object has an epitem element. If the rdllist linked list is not empty, copy the event to the user memory and return the event count to the user.

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.