Net-snmp code analysis: fd_event_manager.c

Source: Internet
Author: User

The fd_event_manager.c module is used to manage read, write, and abnormal file descriptors.

Directory/net-snmp-5.4.2.1/snmplib/fd_event_manager.c

 

Used to store three different types of descriptors

Int external_readfd [num_external_fds], external_readfdlen = 0;
Int external_writefd [num_external_fds], external_writefdlen = 0;
Int external_effectfd [num_external_fds], external_effectfdlen = 0;

 

Stores the processing functions corresponding to the three descriptors.
Void (* external_readfdfunc [num_external_fds]) (INT, void *);
Void (* external_writefdfunc [num_external_fds]) (INT, void *);
Void (* external_effectfdfunc [num_external_fds]) (INT, void *);

Storage data to be processed

Void * external_readfd_data [num_external_fds];
Void * external_writefd_data [num_external_fds];
Void * external_exceptfd_data [num_external_fds];

 

Static int external_fd_unregistered;

 

It is equivalent to three initialization functions. The parameters in the functions are assigned to the above data structure respectively.

Int
Register_readfd (int fd, void (* func) (INT, void *), void * Data)

Int
Register_writefd (int fd, void (* func) (INT, void *), void * Data)

Int
Register_effectfd (int fd, void (* func) (INT, void *), void * Data)

 

 

Deletes the specified file descriptor from the data structure.

Int
Unregister_readfd (int fd)

Int
Unregister_writefd (int fd)

Int
Unregister_exceptfd (int fd)

 

Add the file descriptor registered in the data structure to the corresponding file descriptor set

Void netsnmp_external_event_info (int * numfds, fd_set * readfds, fd_set * writefds, fd_set * limit TFDs)

Test whether the file descriptor in the data structure is added to the corresponding file descriptor set and the corresponding function is called for processing.

Void netsnmp_dispatch_external_events (int * count, fd_set * readfds, fd_set * writefds, fd_set * limit TFDs)

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.