Network Event Processing Method, Apparatus, and Electronic Device
By establishing the association relationship between parent and child connection in Nginx, Nginx solves the connection management problem of Nginx when handling network events, improves processing efficiency and success rate, and enhances network security.
Patent Information
- Application Number
- CN202310186471.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-20
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2043-02-20
AI Technical Summary
Nginx is difficult to effectively manage and control connections in network events, resulting in inefficient processing.
By establishing an association relationship between the parent connection and the child connection, the parent connection creates and manages the child connection to achieve efficient processing of network events.
It improves the processing efficiency and success rate of network events, reduces the difficulty of development of upper-level applications, and improves network security.
Smart Images

Figure CN116192609B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network technologies, and in particular, to a network event processing method, apparatus, and electronic device. Background Art
[0002] Nginx is a high-performance open-source proxy server, which is widely used due to its advantages such as good stability, rich function sets, simple configuration files, and low system resource consumption.
[0003] In some application scenarios, Nginx can process network events. For example, it can forward the data information corresponding to the network events to the upstream server. However, in the related art, Nginx usually uniformly forwards the data information of the network events processed by the parent connection and the child connection, which is not conducive to the management and control of the connections by Nginx, and thus is not conducive to processing network events. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a network event processing method, apparatus, and electronic device, which can manage and control the child connection and the parent connection through the association relationship between the parent connection and the child connection, and improve the processing of network events.
[0005] In a first aspect, the embodiments of this application provide a network event processing method, which can be applied to an Nginx proxy server, and includes: in response to detecting a network event, creating a parent connection for processing the network event; obtaining child connection information from the event information corresponding to the network event through the parent connection, and creating a child connection corresponding to the child connection information; processing the network event through the child connection. In this way, Nginx can create a parent connection when detecting a network event, and then can create an associated child connection through the parent connection. Therefore, there is a clear and distinct association relationship between the parent connection and the child connection, that is, the management and control of the child connection and the parent connection can be realized through this association relationship, and the processing of network events is improved.
[0006] Optionally, the event information includes multiple pieces of child connection information, and creating a child connection corresponding to the child connection information includes: for each piece of child connection information, creating a child connection corresponding to the child connection information. In this way, the parent connection can create multiple child connections to process network events through the resources corresponding to the multiple child connections, improving the processing efficiency and success rate of network events.
[0007] Optionally, creating the sub-connection corresponding to the sub-connection information includes: creating the structure of the sub-connection; creating the listening event of the sub-connection; if the structure and the listening event are successfully created, determining that the sub-connection is created successfully. In this way, the parent connection can realize the creation of the sub-connection by creating the structure of the sub-connection and the listening event, which is beneficial to the management of the connection by Nginx.
[0008] Optionally, creating the structure of the sub-connection includes: setting, through the parent connection, the processing function and configuration information for processing the network event; creating the structure of the sub-connection according to the processing function and the configuration information. In this way, it is possible to more conveniently monitor and manage the sub-connection through the structure of the sub-connection. Moreover, since the sub-connection is created relying on the parent connection, when the parent connection sets the configuration information, it can use the configuration information that has already been set, so that the sub-connection can inherit and apply the relevant configuration.
[0009] Optionally, creating the listening event of the sub-connection includes: obtaining the interface information provided by the system kernel and creating the listening event through the interface information. Here, a method for facilitating the creation of the listening event is provided.
[0010] Optionally, processing the network event through the sub-connection includes: filtering the data packet corresponding to the network event by using the preset filtering function of the sub-connection; if the data packet passes the filtering process, forwarding it; if the data packet does not pass the filtering process, blocking it. In this way, it is possible to determine whether to forward the data packet through the filtering process of the data packet of the network event by the filtering function, achieving the purpose of quickly and accurately processing the network event.
[0011] Optionally, before obtaining the sub-connection information from the event information corresponding to the network event through the parent connection and creating the sub-connection corresponding to the sub-connection information, the network event processing method may further include: obtaining, through the parent connection, the event information corresponding to the network event from the application layer. In this way, the parent connection can obtain the sub-connection information from the application layer, and then can play a certain supporting role for the application layer based on the parent-child connection relationship, facilitating the application layer to process the network event.
[0012] Second aspect, an embodiment of the present application provides a network event processing device, which is applied to an Nginx proxy server and includes: a parent connection creation module, configured to create a parent connection for processing the network event in response to detecting a network event; a child connection creation module, configured to create a child connection corresponding to the child connection information through the parent connection when the parent connection obtains the child connection information from the event information corresponding to the network event; and a processing module, configured to process the network event through the child connection. In this way, Nginx can create a parent connection when detecting a network event, and then can create an associated child connection through the parent connection. Therefore, there is a clear and distinct association relationship between the parent connection and the child connection, that is, the management and control of the child connection and the parent connection can be realized through this association relationship, improving the processing of network events.
[0013] Third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory, where the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect as described above are run.
[0014] Fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the method provided in the first aspect as described above are run.
[0015] Other features and advantages of the present application will be described in the subsequent description, and part of them will become obvious from the description, or can be understood by implementing the embodiments of the present application. The purpose and other advantages of the present application can be realized and obtained through the structures specifically pointed out in the written description, claims, and drawings. Description of the Drawings
[0016] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation of the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 It is a flowchart of a network event processing method provided by an embodiment of the present application;
[0018] Figure 2 It is a schematic diagram of the architecture of an Nginx provided by an embodiment of the present application;
[0019] Figure 3 It is a block diagram of the structure of a network event processing device provided by an embodiment of the present application;
[0020] Figure 4 This is a schematic structural diagram of an electronic device for executing a network event processing method provided by an embodiment of the present application. Detailed implementation manners
[0021] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Usually, the components of the embodiments of the present application described and shown in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application claimed, but only represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative efforts belong to the scope of protection of the present application.
[0022] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of the present application, the terms "first", "second", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0023] It should be noted that, without conflict, the embodiments in the present application or the technical features in the embodiments can be combined.
[0024] In the related art, there is a problem that since Nginx cannot manage and control connections well, it is not conducive to its processing of network events. To solve this problem, the present application provides a network event processing method, device, and electronic device. Further, by constructing the association relationship between the parent connection and the child connection, Nginx's management and control of connections are realized, so as to facilitate its processing of network events.
[0025] All the defects existing in the above solutions in the related art are the results obtained by the inventors through practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed by the embodiments of the present invention below for the above problems should be the contributions made by the inventors to the present invention during the process of the present invention.
[0026] Please refer to Figure 1 , which shows a flowchart of a network event processing method provided by an embodiment of the present application. As Figure 1 shown, the network event processing method may include the following steps 101 to 103.
[0027] Step 101, in response to detecting a network event, create a parent connection for processing the network event;
[0028] In some application scenarios, Nginx can receive requests for processing network events and can create a parent connection to handle it based on the request. The above network events can include, for example, a request to obtain Web page A, and then the processing request for the network event can include, for example, the address information, transmission protocol information, etc. corresponding to Web page A. In this way, when Nginx receives a processing request for a network event, it can be regarded as detecting the network event, and then can create a corresponding parent connection.
[0029] In some application scenarios, a listening port, a processing function, and related flag bits for use by the parent connection can be created, so as to achieve the purpose of creating the parent connection. It should be noted that the process of creating the parent connection (including creating the listening port, the processing function, the flag bits, etc.) is a prior art and will not be elaborated here.
[0030] Step 102, obtain sub-connection information from the event information corresponding to the network event through the parent connection, and create a sub-connection corresponding to the sub-connection information;
[0031] After Nginx creates a parent connection, the parent connection can obtain sub-connection information from the event information corresponding to the network event. The above event information can include, for example, the address information, transmission protocol information, etc. in the above processing request.
[0032] In some application scenarios, the transmission protocol information can include information such as an IP address (Internet Protocol Address, abbreviated as IP address), port information, source address, etc. Then, the parent connection can obtain this information from the transmission protocol information and use this information as the sub-connection information. The transmission protocol here can include protocols such as FTP (File Transfer Protocol, abbreviated as FTP), SIP (Session Initialization Protocol, abbreviated as SIP), etc.
[0033] After Nginx obtains the sub-connection information, it can create a corresponding sub-connection according to the sub-connection information. In some application scenarios, the parent connection can, for example, first perform operations such as registering sub-connection events and allocating resources for the sub-connection, so as to facilitate the creation of the sub-connection.
[0034] Step 103, process the network event through the sub-connection.
[0035] After the parent connection creates a sub-connection, it can process the network event through the sub-connection. In some application scenarios, the sub-connection can, for example, forward data packets related to the network event to an upstream server, so as to achieve the purpose of processing the network event.
[0036] In this embodiment, Nginx can create a parent connection when detecting a network event, and then create an associated sub-connection through the parent connection. In this way, there is a clear and distinct association relationship between the parent connection and the sub-connection, that is, the management and control of the sub-connection and the parent connection can be realized through this association relationship, improving the handling of network events.
[0037] In addition, the sub-connection can provide sub-connection services for the upper-layer application, and then, to a certain extent, reduce the number of parameters that the upper-layer application needs to pay attention to when calling the sub-connection interface, achieving the purpose of reducing the development difficulty of the upper-layer application. And when the parent connection is closed, the resources of the sub-connection can be recycled, and the traffic of the parent and sub-connections can also be counted and controlled, achieving the purpose of enhancing network security.
[0038] In some alternative implementation manners, before the above step 102, the network event processing method may further include: obtaining event information corresponding to the network event from the application layer through the parent connection.
[0039] Nginx can receive the event information of the network event through the application layer, and then, after creating the parent connection, obtain the event information from the application layer through the parent connection, so as to be able to obtain sub-connection information from the event information.
[0040] The stream module included in Nginx can provide the four-layer proxy function of data. Therefore, the sub-connection can be extended based on this stream module.
[0041] In some application scenarios, for example, the position of the sub-connection can be set through the Figure 2 schematic architecture diagram shown. Among them, since Nginx has a highly modular architecture, the created sub-connection can also be encapsulated into a module and then set in the architecture of Nginx. Among them, the protocol module 201 can be regarded as a module for processing the transmission protocol, and this transmission protocol can include, for example, HTTP (Hyper Text Transfer Protocol, abbreviated as HTTP); the application layer module 202 can be regarded as a module for enabling the application layer to process network events; the four-layer proxy module 203 can also be regarded as the above-mentioned stream module, and the sub-connection module 204 can be regarded as a module for the sub-connection to process network events; the network event module 205 can be regarded as a module for Nginx to detect network events and obtain or send relevant data outward.
[0042] Based on Figure 2It can be known that after Nginx creates a parent connection triggered by a network event, it can perform callback processing through the four-layer proxy module 203, and then can call hook functions such as those at the transport layer to enter the network seven-layer application model to parse and process network events. After the parent connection obtains the event information of the network event from the application layer, it can obtain the sub-connection information therefrom and create a sub-connection. After the sub-connection is created, the network event can be processed through the sub-connection without indirectly processing through the transport layer.
[0043] In addition, Nginx belongs to a user-mode process, which can be conveniently re-developed and debugged, and the protocol can be conveniently extended, and the extended protocol can include a custom application-layer protocol. Therefore, the application-layer module 202 of Nginx and the sub-connection module 204 can be arranged in parallel, so as to make the communication between the two more convenient to a certain extent.
[0044] In this implementation manner, the parent connection can obtain the sub-connection information from the application layer, and then can play a certain supporting role in the application layer based on the parent-child connection relationship, which is convenient for the application layer to process network events.
[0045] In some alternative implementation manners, the event information includes a plurality of sub-connection information, and creating the sub-connection corresponding to the sub-connection information in step 102 above includes: for each sub-connection information, creating the sub-connection corresponding to the sub-connection information.
[0046] In some application scenarios, the parent connection can create one sub-connection or multiple sub-connections. For example, if the resources allocated by the parent connection to a sub-connection are insufficient to process the current network event, multiple sub-connections can be created to process the network event through the resources corresponding to the multiple sub-connections, so as to improve the processing efficiency and success rate of the network event.
[0047] In some alternative implementation manners, creating the sub-connection corresponding to the sub-connection information may include the following sub-steps:
[0048] Sub-step 1021, creating a structure of the sub-connection;
[0049] In some application scenarios, the parent connection can create the structure of the sub-connection. For example, the parent connection can apply for a memory pool, and can apply for memory for the sub-connection in the memory pool, and can create a structure according to the applied memory and related setting information.
[0050] In some alternative implementation manners, the processing function and configuration information for processing the network event can be set through the parent connection; and the structure of the sub-connection is created according to the processing function and the configuration information.
[0051] The parent connection can set a processing function for handling network events.
[0052] The parent connection can set the configuration information for handling network events. The above configuration information can include, for example, the duration parameter information determined to be a timeout, the file specification parameter information for transmission, and the like.
[0053] After the parent connection has set the processing function and the configuration information, it can create the structure of the sub - connection according to the set processing function and configuration information, so as to more conveniently monitor and manage the sub - connection through the structure of the sub - connection. And since the sub - connection is created relying on the parent connection, when the parent connection sets the configuration information, it can use the already set configuration information, so that the sub - connection can inherit and apply the relevant configuration.
[0054] Sub - step 1022: Create a listening event for the sub - connection;
[0055] In some application scenarios, the parent connection can create a listening event for the sub - connection. The above listening event can include, for example, listening for whether the network event is processed with a timeout, listening for whether the sub - connection has an exception, and the like.
[0056] In some alternative implementation manners, the interface information provided by the system kernel can be obtained, and the listening event can be created through the interface information.
[0057] In some application scenarios, Nginx can obtain the interface information provided by the system kernel. The above system can include, for example, the Linux system. The above interface information can include the interface number. Then, the parent connection can listen for events such as whether the sub - connection has an exception through the interface provided by the Linux kernel.
[0058] Sub - step 1023: If the structure and the listening event are successfully created, determine that the sub - connection is created successfully.
[0059] After the parent connection successfully creates the structure of the sub - connection and the listening event, it can be regarded that the sub - connection is created successfully.
[0060] In this implementation manner, the parent connection can implement the creation of the sub - connection by creating the structure of the sub - connection and the listening event, which is beneficial for Nginx to manage the connection.
[0061] In some alternative implementation manners, the handling of the network event through the sub - connection in step 103 above can include the following steps:
[0062] First, filter the data packet corresponding to the network event by using the preset filtering function of the sub - connection;
[0063] In some application scenarios, when a sub-connection processes a network event, it can determine how to handle the network event through a filtering function. The above filtering function can be the default filtering function provided by Nginx; it can also be a custom function. For a custom function, Nginx can insert it into the filtering function linked list provided by Nginx through the tail-insertion method to achieve the purpose of filtering the data packets of network events through the custom function.
[0064] Then, if the data packet passes the filtering process, it is forwarded; if the data packet fails to pass the filtering process, it is blocked.
[0065] That is to say, if the sub-connection filters out the data packet of the network event through the filtering function, it can forward it to the upstream server. If the sub-connection does not filter out the data packet of the network event through the filtering function, it can block the data packet of the network event and not forward it to the upstream server.
[0066] For example, if the default filtering function ngx_stream_sub_write_filter of Nginx is used to filter the data packet of the network event, if the filtering result is "NGX_ERROR", it can be regarded as the data packet failing to pass the filtering process, and then the data packet can be blocked; if the filtering result is "ngx_stream_sub_top_next_filter(ss,in,from_upstream)", the next filtering function can be used to continue processing the data packet of the network event. When the "NGX_OK" filtering result is obtained when detecting that the last filtering function is completed, it can be regarded as the data packet passing the filtering process and the data packet being forwarded to the upstream server, and then it can be regarded as the current network event having been processed.
[0067] In this implementation method, it is possible to determine whether to forward the data packet through the filtering process of the data packet of the network event by the filtering function, so as to achieve the purpose of quickly and accurately processing the network event.
[0068] Furthermore, when a sub-connection processes a network event, it needs to receive or send data. Therefore, the sub-connection can inherit the chain-buf form that conforms to the Nginx standard. Among them, the chain-buf form can play the role of a chain, which can string together the data to be sent. buf is a structure for managing buffer blocks, which can record the starting position, ending position, cursor of the data that has been sent, and some flag bit information, etc.
[0069] In some application scenarios, when a sub - connection receives data sent by a downstream client, its processing procedure (where ss represents the sub - connection storing the data received from the downstream) may include, for example: caching the received data through ss->downstream_buf, and then adding the cached data to the ss->downstream_out linked list by calling the ss->sub_apf_proxy_filter function. Then, by calling the ngx_stream_sub_top_filter function, cache the data in the ss->downstream_out linked list, and the data in ctx->from_downstream can be sent by calling the send_chain function. After sending the data, the residual data after calling the send_chain function can be saved through ss->downstream_busy, and free chain - buf containers can be saved through ss->free, etc.
[0070] In some other application scenarios, the form in which Nginx sends data to the upstream server through sub - connections can be the same as or similar to the form in which it receives data from the downstream client, which will not be elaborated here.
[0071] Please refer to Figure 3 , which shows a structural block diagram of a network event processing device provided by an embodiment of the present application. This network event processing device can be a module, a program segment, or code on an electronic device. It should be understood that this device corresponds to the above - mentioned Figure 1 method embodiment and can execute Figure 1 each step involved in the method embodiment. The specific functions of this device can be seen in the above description. To avoid repetition, the detailed description is appropriately omitted here.
[0072] Optionally, the above - mentioned network event processing device is applied to an Nginx proxy server, and it may include a parent - connection creation module 301, a sub - connection creation module 302, and a processing module 303. Among them, the parent - connection creation module 301 is used to create a parent connection for processing the network event in response to detecting a network event; the sub - connection creation module 302 is used to create a sub - connection corresponding to the sub - connection information through the parent connection when the parent connection obtains the sub - connection information from the event information corresponding to the network event; the processing module 303 is used to process the network event through the sub - connection.
[0073] Optionally, the event information includes multiple sub - connection information, and the sub - connection creation module 302 is further used to: for each sub - connection information, create a sub - connection corresponding to the sub - connection information.
[0074] Optionally, the sub - connection creation module 302 is further configured to: create a structure of the sub - connection; create a listening event for the sub - connection; and determine that the sub - connection is created successfully if the structure and the listening event are created successfully.
[0075] Optionally, the sub - connection creation module 302 is further configured to: set a processing function and configuration information for processing the network event through the parent connection; and create a structure of the sub - connection according to the processing function and the configuration information.
[0076] Optionally, the sub - connection creation module 302 is further configured to: obtain interface information provided by the system kernel, and create the listening event through the interface information.
[0077] Optionally, the processing module 303 is further configured to: filter a data packet corresponding to the network event by using a preset filtering function of the sub - connection; forward the data packet if the data packet passes the filtering process; and block the data packet if the data packet does not pass the filtering process.
[0078] Optionally, the network event processing device further includes an obtaining module, and the obtaining module is configured to obtain event information corresponding to the network event from the application layer through the parent connection before obtaining sub - connection information corresponding to the network event from the event information corresponding to the network event through the parent connection and creating a sub - connection corresponding to the sub - connection information.
[0079] It should be noted that those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the above - described devices can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0080] Please refer to Figure 4 , Figure 4 FIG. is a schematic structural diagram of an electronic device for executing a network event processing method provided by an embodiment of the present application. The electronic device may include: at least one processor 401, such as a CPU, at least one communication interface 402, at least one memory 403, and at least one communication bus 404. Among them, the communication bus 404 is used to implement direct connection communication between these components. Among them, the communication interface 402 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 403 may be a high - speed RAM memory, or a non - volatile memory, such as at least one disk memory. Optionally, the memory 403 may further be at least one storage device located far from the foregoing processor. The memory 403 stores computer - readable instructions. When the computer - readable instructions are executed by the processor 401, the electronic device may execute the above - mentioned Figure 1 shown method process.
[0081] It can be understood that Figure 4 the structure shown is only illustrative, and the electronic device may further include more or fewer components than those shown in Figure 4 or have a configuration different from that shown in Figure 4 . Figure 4 Each component shown in can be implemented by hardware, software, or a combination thereof.
[0082] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it can execute the method process executed by the electronic device in the method embodiment as shown in Figure 1 .
[0083] An embodiment of the present application provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the methods provided in the above method embodiments. For example, the method may include: creating a parent connection for processing the network event in response to detecting a network event; obtaining sub-connection information from the event information corresponding to the network event through the parent connection, and creating a sub-connection corresponding to the sub-connection information; and processing the network event through the sub-connection.
[0084] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces. The indirect coupling or communication connection of the devices or units can be in an electrical, mechanical, or other form.
[0085] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0086] Furthermore, in each embodiment of the present application, the functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.
[0087] In this document, relational terms such as first and second are used solely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0088] The above description is only for the embodiments of this application and is not intended to limit the protection scope of this application. For those skilled in the art, various modifications and variations can be made to this application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this application shall be included within the protection scope of this application.
Claims
1. A network event processing method, characterized in that, Applied to an Nginx proxy server, the method includes: In response to detecting a network event, create a parent connection for handling the network event; Obtain sub-connection information from the event information corresponding to the network event through the parent connection, and create a sub-connection corresponding to the sub-connection information; Handle the network event through the sub-connection; The creating of the sub-connection corresponding to the sub-connection information includes: Create a structure of the sub-connection; Create a listening event for the sub-connection; If the structure and the listening event are successfully created, determine that the sub-connection is created successfully; The creating of the structure of the sub-connection includes: Set a processing function and configuration information for handling the network event through the parent connection; Create the structure of the sub-connection according to the processing function and the configuration information.
2. The method according to claim 1, characterized in that, The event information includes multiple sub-connection information, and The creating of the sub-connection corresponding to the sub-connection information includes: For each sub-connection information, create a sub-connection corresponding to the sub-connection information.
3. The method according to claim 1, characterized in that, The creating of the listening event for the sub-connection includes: Obtain interface information provided by the system kernel, and create the listening event through the interface information.
4. The method according to any one of claims 1 to 3, characterized in that, The handling of the network event through the sub-connection includes: Filter the data packet corresponding to the network event by using a preset filtering function of the sub-connection; If the data packet passes the filtering process, forward it; If the data packet does not pass the filtering process, block it.
5. The method according to any one of claims 1 to 3, characterized in that Before obtaining the sub-connection information from the event information corresponding to the network event through the parent connection and creating the sub-connection corresponding to the sub-connection information, the method further includes: Obtain the event information corresponding to the network event from the application layer through the parent connection.
6. A network event processing device, characterized in that Applied to an Nginx proxy server, the device includes: A parent connection creation module, configured to create a parent connection for handling the network event in response to detecting a network event; A sub-connection creation module, configured to create a sub-connection corresponding to the sub-connection information through the parent connection when the parent connection obtains the sub-connection information from the event information corresponding to the network event; the creating of the sub-connection corresponding to the sub-connection information includes: creating a structure of the sub-connection; creating a listening event for the sub-connection; if the structure and the listening event are successfully created, determine that the sub-connection is created successfully; the creating of the structure of the sub-connection includes: setting a processing function and configuration information for handling the network event through the parent connection; creating the structure of the sub-connection according to the processing function and the configuration information; A processing module, configured to handle the network event through the sub-connection.
7. An electronic device, characterized in that, It includes a processor and a memory, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the method according to any one of claims 1-5 is run.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1-5 is run.