Request processing method, electronic equipment and computer storage medium
By associating a unique message uplink for each epoll event node and determining the target node under the monitoring instructions in the user-state protocol stack VPP, the message loss problem when multi-threaded access to the message queue is solved, and efficient request processing and accurate implementation is achieved messaging.
Patent Information
- Application Number
- CN202411229365.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-20
AI Technical Summary
In the VCL of the user-state protocol stack VPP, multiple threads may cause message loss when accessing the message queue at the same time.
By associating a unique message uplink for each epoll event node, and determining the first target epoll event node under the monitoring instructions for monitoring and response, avoiding lock competition and ensuring that messages are not lost.
It effectively avoids the epoll event node incorrectly dealing with input and output IO events of other threads, preventing messages from being lost, and improving the accuracy and efficiency of request processing.
Smart Images

Figure CN119172440A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of network communication technology, and in particular to a request processing method, an electronic device and a computer storage medium. Background Art
[0002] I / O multiplexing is a synchronous I / O model that allows a single process / thread to handle multiple I / O requests simultaneously. This model is implemented by monitoring multiple file handles. Once a file handle is ready, the application can be notified to perform the corresponding read and write operations. If no file handle is ready, the application will be blocked, thus handing over the CPU. This idea is similar to the CPU running multiple processes concurrently, so it is also called time division multiplexing. In traditional kernels, there is complete scenario support for I / O multiplexing, but it cannot meet the scenario requirements in network scenarios with high data concurrency.
[0003] At present, in order to achieve high concurrent processing capabilities, IO multiplexing technology is supported through the user-mode protocol stack (VPP, Vector Packet Processing). The communication library (VCL, VPP Communication Library) of the user-mode protocol stack VPP simplifies the integration of applications and the user-mode protocol stack VPP by providing an application programming interface (API, Application Programming Interface) similar to but not compatible with the portable operating system interface (POSIX, Portable Operating System Interface).
[0004] However, in the VCL of the user-mode protocol stack VPP, although thread safety is ensured by locking in multi-threaded mode to ensure that only one application accesses it at a time, a single worker working mode is used within the process to interact with the protocol stack. All interactive messages are sent and received through a message queue. When multiple threads access the message queue at the same time, lock competition is involved, and the current thread may process messages from other threads, resulting in message loss. Summary of the invention
[0005] In view of this, the present application provides a request processing method, an electronic device and a computer storage medium to solve the problem of message loss that may exist when multiple threads simultaneously access a message queue in a traditional solution.
[0006] In a first aspect, the present application provides a request processing method, which is applied to a communication library VCL corresponding to a user-mode protocol stack VPP, wherein the communication library VCL includes multiple epoll event nodes, each of which is associated one-to-one with a message upstream queue. The request processing method includes: determining a first target epoll event node from the multiple epoll event nodes according to a monitoring instruction, and monitoring the first target epoll event node; when the message upstream queue associated with the first target epoll event node receives an input / output IO request sent by the protocol stack, responding to the input / output IO request through the first target epoll event node, writing the input / output IO event included in the input / output IO request into the first target epoll event node, and generating a first target epoll event message; and sending the first target epoll event message to the user-mode protocol stack VPP through the message downstream queue.
[0007] Optionally, the request processing process may also include: establishing a mapping between a file descriptor and the epoll event node, so that when the protocol stack sends the input / output IO request, a second target epoll event node is determined based on the file descriptor included in the input / output IO request, and the input / output IO request is sent to a message upstream queue corresponding to the second target epoll event node.
[0008] Optionally, the request processing process may also include: when creating each of the epoll event nodes, executing: creating the epoll event node and allocating one of the message upstream queues to the epoll event node; sending the address of the message upstream queue to the epoll event node through the message downstream queue.
[0009] Optionally, a plurality of the message uplink queues share a memory.
[0010] Optionally, the process of sending the address of the message upstream queue to the epoll event node through the message downstream queue may also include: allocating an address for the message upstream queue from a shared memory; and sending the address of the message upstream queue to the epoll event node through the message downstream queue.
[0011] A second aspect of the present application provides a request processing method, which is applied to a user-mode protocol stack VPP, comprising: when an input / output IO event needs to be sent to a communication library VCL corresponding to the user-mode protocol stack VPP, generating an input / output IO request including the input / output IO event, wherein the communication library VCL includes multiple epoll event nodes, and each of the epoll event nodes is associated one-to-one with a message upstream queue; sending the input / output IO request to the message upstream queue, so that a first target epoll event node associated one-to-one with the message upstream queue responds to the input / output IO request, and writes the input / output IO event included in the input / output IO request into the first target epoll event node; receiving a first target epoll event message sent by the first target epoll event node to the message downstream queue, wherein the first target epoll event message is generated after the first target epoll event node writes the input / output IO event included in the input / output IO request.
[0012] Optionally, the process of sending the input / output IO request to the message upstream queue may also include: obtaining the file descriptor of the input / output IO event; determining the second target epoll event node corresponding to the file descriptor of the input / output IO event based on the mapping of the file descriptor and the epoll event node; and sending the input / output IO request to the message upstream queue corresponding to the second target epoll event node.
[0013] According to a third aspect of an embodiment of the present application, there is provided an electronic device comprising: a processor, a communication interface, a memory and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method described in the first aspect or the second aspect of the embodiment.
[0014] According to a fourth aspect of an embodiment of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect or the second aspect of the embodiment is implemented.
[0015] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, including computer instructions, wherein the computer instructions instruct a computing device to perform operations corresponding to the method described in the first aspect or the second aspect of the embodiment.
[0016] The present application associates a message upstream queue one-to-one with multiple epoll event nodes included in the communication library VCL, and only responds to and processes the input and output IO requests sent to the first target epoll event node being monitored. When the protocol stack sends messages to the VCL user side, the epoll event node is prevented from misprocessing the input and output IO events of other threads, thereby avoiding the occurrence of message loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0018] Figure 1 is a flowchart of the steps of a request processing method according to an embodiment of the present application;
[0019] Figure 2 It is an exemplary scenario applicable to the embodiments of the present application;
[0020] Figure 3 is a flowchart of the steps of a request processing method according to another embodiment of the present application;
[0021] Figure 4 is a flowchart of the steps of a request sending method according to an embodiment of the present application;
[0022] Figure 5 It is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0023] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0024] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0025] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0026] The technical solutions in the embodiments of the present application are clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application. In the absence of conflict, the following embodiments and their technical features can be combined with each other.
[0027] IO multiplexing is a synchronous IO model that allows a single process / thread to handle multiple IO requests at the same time. This model is implemented by monitoring multiple file handles. Once a file handle is ready, it can notify the application to perform the corresponding read and write operations. If no file handle is ready, the application will be blocked, thus handing over the CPU. The main mechanisms of IO multiplexing include select, poll, epoll, etc., all of which need to be responsible for reading and writing after the read and write events are ready, that is, blocking the reading and writing process. Compared with asynchronous IO, asynchronous IO will notify the program to process after the IO operation is completed, and there is no blocked data reading and writing process. However, asynchronous IO is not very commonly used, and many high-performance concurrent service programs use the architecture of IO multiplexing + multi-threaded task processing to basically meet the needs. This is mainly because the operating system's support for asynchronous IO is not particularly perfect, and IO multiplexing is more often used to simulate asynchronous IO.
[0028] Specifically, the implementation methods of IO multiplexing include:
[0029] select: You can monitor multiple file descriptors, including those in readable, writable, or abnormal states. When a file descriptor is ready, the select function returns and the application can process the corresponding IO event.
[0030] poll: Similar to select, but there is no limit to the number of file descriptors that can be monitored (1024 on Linux), and there is no need to copy the fd set from user state to kernel state every time it is called like select.
[0031] epoll: It is a Linux-specific I / O multiplexing mechanism. Compared with select and poll, epoll has higher efficiency and scalability when handling a large number of concurrent connections.
[0032] The advantage of I / O multiplexing is that it can improve the concurrent processing capability of applications and reduce the waste of system resources. By monitoring the state changes of multiple file descriptors, applications can wait for IO events to occur without blocking, thereby achieving efficient processing of multiple IO requests.
[0033] I / O multiplexing is applicable to many scenarios, such as: High-concurrency servers: such as Web servers, mail servers, database servers, etc. These servers need to handle a large number of client connection requests. Through I / O multiplexing, the server can handle multiple connection requests simultaneously in one thread, thereby improving efficiency. Real-time communication applications: such as instant messaging, VoIP, video conferencing and other applications. These applications need to handle multiple connections at the same time and need to process the data of each connection in a timely manner. I / O multiplexing enables applications to process data from multiple connections at the same time, thereby meeting the needs of real-time processing. Network proxy or load balancer: such as reverse proxy server, load balancer, etc. These applications need to forward data between the client and the server and handle a large number of concurrent connections at the same time. I / O multiplexing enables these applications to efficiently handle concurrent connections and improve the efficiency of data forwarding. Online game servers: such as MORPG and other large-scale multiplayer online games. These servers need to handle a large number of concurrent connections from players and process the data of each player at the same time. I / O multiplexing enables game servers to efficiently handle concurrent connections and ensure the real-time and smoothness of the game.
[0034] At present, the VCL library of the user-mode protocol stack VPP simplifies the integration of applications and VPP by providing an API similar to but not compatible with POSIX. Under the existing VCL library design, there is support for IO multiplexing select, poll and epoll. However, under the existing framework, although thread safety is guaranteed by locking in multi-threaded mode to ensure that only one application accesses it at a time, a single worker working mode is used within the process to interact with the protocol stack. All interactive messages are sent and received through a message queue. When multiple threads access the message queue at the same time, lock competition is involved, and the current thread may process messages from other threads, resulting in message loss. Therefore, the present application proposes a request processing method, an electronic device and a computer storage medium to solve the above problems.
[0035] Figure 11 is a flowchart of the steps of a request processing method according to an embodiment of the present application. The request processing method 100 is applied to a communication library VCL corresponding to a user-mode protocol stack VPP. The communication library VCL includes a plurality of epoll event nodes. Each epoll event node is associated with a message upstream queue one-to-one, such as Figure 1 The request processing method 100 includes the following steps:
[0036] Step 101: determine a first target epoll event node from a plurality of epoll event nodes according to a monitoring instruction, and monitor the first target epoll event node.
[0037] Step 102: When the message upstream queue associated with the first target epoll event node receives an input / output IO request sent by the protocol stack, the first target epoll event node responds to the input / output IO request, writes the input / output IO event included in the input / output IO request into the first target epoll event node, and generates a first target epoll event message.
[0038] Step 103: Send the first target epoll event message to the user mode protocol stack VPP through the message downlink queue.
[0039] The communication library VCL includes multiple epoll event nodes. In order to avoid the lock contention that causes the thread with the lock to obtain the request that should be sent to other threads during the multi-threaded request processing, a unique message upstream queue is associated with each epoll event node, and a first target epoll event node is determined from multiple epoll event nodes and monitored through monitoring instructions. For example, the monitoring instruction can be an epoll_wait function, and the first target epoll event node is monitored through the epoll_wait function, waiting for the generation of related events by the monitored first target epoll event node. Specifically, multiple message upstream queues share memory.
[0040] In the process of monitoring the first target epoll event node, the epoll_wait function monitors whether there is an input / output IO request in the message upstream queue associated with the first target epoll event node. When it is found that the message upstream queue associated with the first target epoll event node receives the input / output IO request sent by the protocol stack, the first target epoll event node responds to the input / output IO request, writes the input / output IO event included in the input / output IO request to the first target epoll event node, and generates the first target epoll event message. Finally, the first target epoll event message is sent to the user mode protocol stack VPP through the message downstream queue. Among them, the message downstream queue is a message queue shared by all epoll event nodes.
[0041] The operation scenario of the request processing method 100 can be as follows: Figure 2 As shown, for example, the first target epoll event node monitored by the epoll_wait function is epoll event node 1. At this time, the protocol stack sends IO request 1 and IO request 2. The epoll_wait function monitors that there is IO request 1 in queue1, and then receives and responds to IO request 1 through epoll event node 1, writes the input and output IO event 1 included in IO request 1 into epoll event node 1, generates the first target epoll event message, and sends it to the protocol stack through ctl_queue. During the process, IO request 2 will not be responded to by epoll event node 2, but will be blocked in queue2, thereby preventing queue1 from receiving IO request 2.
[0042] In an embodiment of the present application, by one-to-one associating a message upstream queue for multiple epoll event nodes included in the communication library VCL, and only responding to and processing the input and output IO requests sent to the first target epoll event node being monitored, when the protocol stack sends a message to the VCL user side, the epoll event node is prevented from misprocessing the input and output IO events of other threads, thereby avoiding the occurrence of message loss.
[0043] In one possible implementation, the request processing method also includes: establishing a mapping between a file descriptor and an epoll event node, so that when the protocol stack sends an input / output IO request, the second target epoll event node is determined based on the file descriptor included in the input / output IO request, and the input / output IO request is sent to the message upstream queue corresponding to the second target epoll event node.
[0044] When creating an epoll event node, a mapping between a file descriptor and an epoll event node is established in advance. For example, the file descriptor fd can be registered to the epoll event node through the epoll_ctl function, and the mapping relationship is associated with the file descriptor fd, indicating that the input / output IO request to which the associated file descriptor fd belongs is processed by the epoll event node indicated by the mapping relationship. At this time, when the protocol stack sends an input / output IO request, the second target epoll event node for processing is determined according to the file descriptor included in the input / output IO request, and the input / output IO request is sent to the message upstream queue corresponding to the second target epoll event node.
[0045] In the embodiment of the present application, by establishing a mapping between a file descriptor and an epoll event node, an input / output IO request can be sent to a second target epoll event node for processing the input / output IO request, thereby improving the efficiency of request processing.
[0046] In a possible implementation, the request processing method further includes: when creating each epoll event node, executing: creating an epoll event node and allocating a message upstream queue for the epoll event node; sending the address of the message upstream queue to the epoll event node through the message downstream queue.
[0047] When the communication library VCL creates each epoll event node, a message upstream queue is allocated to the created epoll event node. In order to associate the epoll event node with the message upstream queue, the address of the message upstream queue is sent to the epoll event node through the message downstream queue.
[0048] In an embodiment of the present application, the message downstream queue sends the address of the message upstream queue to the epoll event node, which can associate the epoll event node with the message upstream queue, thereby avoiding the loss of sent data when processing input and output IO requests.
[0049] In a possible implementation, the process of sending the address of the message upstream queue to the epoll event node through the message downstream queue may also include:
[0050] Assign an address to the message upstream queue from the shared memory, and send the address of the message upstream queue to the epoll event node through the message downstream queue.
[0051] Since multiple message upstream queues share memory, addresses are allocated to the message upstream queues in the shared memory. After an address is allocated to each message upstream queue, the address of the message upstream queue is sent to the epoll event node through the message downstream queue.
[0052] In an embodiment of the present application, the address of the message upstream queue is sent to the epoll event node through the message downstream queue, so that the message upstream queue only sends input and output IO requests, which can further ensure the integrity of the data sent by the input and output IO requests.
[0053] Figure 3 is a flowchart of the steps of a request processing method according to another embodiment of the present application. Figure 3 As shown, the request processing method 200 applied to the user mode protocol stack VPP includes the following steps:
[0054] Step 201: When an input / output (IO) event needs to be sent to a communication library (VCL) corresponding to a user-mode protocol stack (VPP), an input / output (IO) request including the input / output (IO) event is generated.
[0055] Step 202: Send the input / output IO request to the message uplink queue.
[0056] Step 203: Receive the first target epoll event message sent by the first target epoll event node to the message downlink queue.
[0057] The communication library VCL includes multiple epoll event nodes, each of which is associated with a message upstream queue one-to-one. The communication library VCL determines the first target epoll event node from the multiple epoll event nodes and monitors it through a monitoring instruction. For example, the monitoring instruction can be an epoll_wait function, and the first target epoll event node is monitored through the epoll_wait function, waiting for the generation of a related event by the monitored first target epoll event node. When the input-output IO event needs to be sent to the communication library VCL corresponding to the user-mode protocol stack VPP, the user-mode protocol stack generates an input-output IO request including the input-output IO event, and sends the input-output IO request to the message upstream queue, so that the first target epoll event node associated with the message upstream queue one-to-one responds to the input-output IO request, writes the input-output IO event included in the input-output IO request into the first target epoll event node, and the first target epoll event node generates the first target epoll event message after writing the input-output IO event included in the input-output IO request. Afterwards, the user state protocol stack receives the first target epoll event message sent by the first target epoll event node to the message downlink queue.
[0058] In an embodiment of the present application, by one-to-one associating a message upstream queue for multiple epoll event nodes included in the communication library VCL, and only responding to and processing the input and output IO requests sent to the first target epoll event node being monitored, when the protocol stack sends a message to the VCL user side, the epoll event node is prevented from misprocessing the input and output IO events of other threads, thereby avoiding the occurrence of message loss.
[0059] Figure 4 is a flowchart of the steps of a request sending method according to an embodiment of the present application. Figure 4 As shown, the request sending method 300 includes the following steps:
[0060] Step 301: Get the file descriptor of the input / output (IO) event.
[0061] Step 302: According to the mapping between the file descriptor and the epoll event node, determine the second target epoll event node corresponding to the file descriptor of the input / output IO event.
[0062] Step 303: Send the input / output IO request to the message uplink queue corresponding to the second target epoll event node.
[0063] When sending an input / output IO request, the user-state protocol stack VPP first obtains the file descriptor of the input / output IO event. Since the file descriptor is pre-associated with the epoll event node, the second target epoll event node of the file descriptor for processing the input / output IO event can be determined based on the mapping between the file descriptor and the epoll event node. At this time, the user-state protocol stack VPP directly sends the input / output IO request to the message upstream queue corresponding to the second target epoll event node, so that the communication library VCL responds to the input / output IO request through the second target epoll event node, and writes the input / output IO event included in the input / output IO request into the second target epoll event node.
[0064] In the embodiment of the present application, a mapping between a file descriptor and an epoll event node is established, so that an input / output IO request can be sent to a second target epoll event node for processing the input / output IO request, thereby improving the efficiency of request processing.
[0065] In this embodiment, an electronic device 400 is provided, such as Figure 5 As shown, the electronic device 400 may include: a processor 401, a communications interface 402, a memory 403, and a communication bus 404. Among them:
[0066] The processor 401 , the communication interface 402 , and the memory 403 communicate with each other via the communication bus 404 .
[0067] The communication interface 402 is used to communicate with other electronic devices or servers.
[0068] The processor 401 is used to execute the program 405, and specifically can execute the relevant steps in the aforementioned method embodiment.
[0069] Specifically, the program 405 may include program codes, which include computer operation instructions.
[0070] The processor 401 may be a CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or may be configured as one or more integrated circuits. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs, or processors of different types, such as one or more CPUs and one or more ASICs.
[0071] The memory 403 is used to store the program 405. The memory 403 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0072] The program 404 may be specifically used to enable the processor 401 to execute the method in the aforementioned embodiment.
[0073] The specific implementation of each step in program 404 can refer to the corresponding description of the corresponding steps and units in the aforementioned method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the aforementioned method embodiment, which will not be repeated here.
[0074] The electronic device 400 of the embodiment of the present application associates a message upstream queue one-to-one with multiple epoll event nodes included in the communication library VCL, and only responds to and processes input and output IO requests sent to the first target epoll event node being monitored. When the protocol stack sends messages to the VCL user side, the epoll event node is prevented from mishandling input and output IO events of other threads, thereby avoiding the occurrence of message loss.
[0075] In this embodiment, a computer-readable storage medium is provided, which stores instructions for causing a machine to execute the method in the above method embodiment. Specifically, a system or device equipped with a storage medium can be provided, on which a software program code that implements the functions of any of the above embodiments is stored, and a computer (or CPU or MPU) of the system or device reads and executes the program code stored in the storage medium.
[0076] In this case, the program code read from the storage medium itself can implement the functions in the above method embodiments, so the program code and the storage medium storing the program code constitute part of the present application.
[0077] The storage medium embodiments for providing the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), a magnetic tape, a non-volatile memory card, and a ROM. Alternatively, the program code can be downloaded from a server computer by a communication network.
[0078] In this embodiment, a computer program product is provided, including computer instructions, which instruct a computing device to perform operations corresponding to the above method embodiments.
[0079] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.
[0080] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (for example, RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here. Although the present application has been shown and described with respect to one or more implementations, those skilled in the art will think of equivalent deformations and modifications based on the reading and understanding of this specification and the accompanying drawings. The present application includes all such modifications and variations, and is limited only by the scope of the appended claims. In particular, with respect to the various functions performed by the above-described components, the terms used to describe such components are intended to correspond to any component that performs the specified function of the component (e.g., which is functionally equivalent) (unless otherwise indicated), even if not structurally equivalent to the disclosed structure that performs the function in the exemplary implementation of the present specification shown herein.
[0081] That is, the above description is only an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, such as the mutual combination of technical features between the embodiments, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.
[0082] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0083] In order to enable any technician in the field to implement and use the application, the application provides the above description. In the above description, various details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art can recognize that the application can also be implemented without using these specific details. In other embodiments, the well-known process will not be elaborated in detail to avoid unnecessary details that make the description of the application obscure. Therefore, the application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the application.
[0084] It should be noted that, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in this application can be arbitrarily combined with each other, and the technical solution obtained after the combination should also fall within the protection scope of this application.
[0085] It should be understood that the specific examples in the embodiments of the present application are only to help those skilled in the art to better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. Those skilled in the art can make various improvements and modifications based on the above embodiments, and these improvements or modifications all fall within the scope of protection of the present application.
[0086] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A request processing method, applied to a communication library VCL corresponding to a user-mode protocol stack VPP, characterized in that: The communication library VCL includes a plurality of epoll event nodes, each of which is associated one-to-one with a message upstream queue. The request processing method includes: Determine a first target epoll event node from the multiple epoll event nodes according to the monitoring instruction, and monitor the first target epoll event node; When the message upstream queue associated with the first target epoll event node receives an input / output IO request sent by the protocol stack, the first target epoll event node responds to the input / output IO request, writes the input / output IO event included in the input / output IO request into the first target epoll event node, and generates a first target epoll event message; The first target epoll event message is sent to the user mode protocol stack VPP through a message downlink queue.
2. The method according to claim 1, characterized in that: The method further comprises: A mapping between a file descriptor and the epoll event node is established so that when the protocol stack sends the input / output IO request, a second target epoll event node is determined according to the file descriptor included in the input / output IO request, and the input / output IO request is sent to a message upstream queue corresponding to the second target epoll event node.
3. The method according to claim 1, characterized in that The method further comprises: When creating each of the epoll event nodes, execute: Create the epoll event node and allocate one of the message uplink queues to the epoll event node; The address of the message upstream queue is sent to the epoll event node through the message downstream queue.
4. The method according to claim 3, characterized in that The multiple message uplink queues share memory.
5. The method according to claim 4, characterized in that The sending the address of the message upstream queue to the epoll event node through the message downstream queue includes: Allocating an address for the message uplink queue from the shared memory; The address of the message upstream queue is sent to the epoll event node through the message downstream queue.
6. A request processing method, applied to a user-mode protocol stack VPP, characterized in that: include: When an input / output IO event needs to be sent to the communication library VCL corresponding to the user mode protocol stack VPP, an input / output IO request including the input / output IO event is generated, wherein the communication library VCL includes a plurality of epoll event nodes, and each of the epoll event nodes is associated one-to-one with a message upstream queue; Send the input / output IO request to the message upstream queue, so that the first target epoll event node associated with the message upstream queue one-to-one responds to the input / output IO request, and writes the input / output IO event included in the input / output IO request into the first target epoll event node; A first target epoll event message sent by the first target epoll event node to a message downlink queue is received, wherein the first target epoll event message is generated after the first target epoll event node writes the input / output IO event included in the input / output IO request.
7. The method according to claim 6, characterized in that The step of sending the input / output IO request to an upstream message queue includes: Get the file descriptor of the input and output IO event; Determine, according to the mapping between the file descriptor and the epoll event node, a second target epoll event node corresponding to the file descriptor of the input / output IO event; The input / output IO request is sent to the message upstream queue corresponding to the second target epoll event node.
8. An electronic device, characterized in that: include: A processor, a communication interface, a memory and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute an operation corresponding to the method described in any one of claims 1-5 or 6-7.
9. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 5 or 6 to 7 is implemented.
10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions instruct a computing device to execute operations corresponding to the method as claimed in any one of claims 1-5 or 6-7.
