CN114356446B - Processing method, device, equipment and storage medium for inter-process event - Google Patents

Processing method, device, equipment and storage medium for inter-process event Download PDF

Info

Publication number
CN114356446B
CN114356446B CN202111619272.6A CN202111619272A CN114356446B CN 114356446 B CN114356446 B CN 114356446B CN 202111619272 A CN202111619272 A CN 202111619272A CN 114356446 B CN114356446 B CN 114356446B
Authority
CN
China
Prior art keywords
kernel
event
target
read
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111619272.6A
Other languages
Chinese (zh)
Other versions
CN114356446A (en
Inventor
董叶豪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Hubei Topsec Network Security Technology Co Ltd
Original Assignee
Beijing Topsec Technology Co Ltd
Beijing Topsec Network Security Technology Co Ltd
Beijing Topsec Software Co Ltd
Hubei Topsec Network Security Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Topsec Technology Co Ltd, Beijing Topsec Network Security Technology Co Ltd, Beijing Topsec Software Co Ltd, Hubei Topsec Network Security Technology Co Ltd filed Critical Beijing Topsec Technology Co Ltd
Priority to CN202111619272.6A priority Critical patent/CN114356446B/en
Publication of CN114356446A publication Critical patent/CN114356446A/en
Application granted granted Critical
Publication of CN114356446B publication Critical patent/CN114356446B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a processing method, a device, equipment and a storage medium of an inter-process event, wherein the processing method comprises the following steps: and when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier. The mode of locking the work queue is not adopted, so that the time consumption of the CPU is saved.

Description

Processing method, device, equipment and storage medium for inter-process event
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for processing an inter-process event.
Background
In the prior art, a parent process is responsible for monitoring, establishing connection and packaging an http request object, adding the packaged http request object into a shared work queue, and a child process is responsible for taking out the http request object from the work queue, analyzing http request data and constructing an http response.
The parent process and the child process share a work queue, the parent process adds an http request object to the work queue, and the child process takes the http request object out of the work queue, so that the work queue is locked, and the consumption of CPU time is increased.
Disclosure of Invention
Based on the above, a method, a device, equipment and a storage medium for processing an inter-process event are provided.
In a first aspect, a method for processing an inter-process event is provided, including:
when the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to a parent process, wherein the monitoring data comprises data of a client request for establishing connection, and the parent process registers the first reading ready event on the monitoring socket into an epoll kernel event table corresponding to the parent process in advance;
when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process;
when the kernel detects that data exists in a pipeline socket in a target sub-process, the kernel returns a second read-ready event to the target sub-process, and the target sub-process registers the second read-ready event in an epoll kernel event table corresponding to the target sub-process in advance;
and when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier.
When the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to the parent process, wherein the monitoring data comprises data of a client side requesting to establish connection; then, when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process; and when the kernel detects that the data exists in the pipeline socket in the target subprocess, the kernel returns a second read-ready event to the target subprocess; and finally, when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier. Therefore, the method for processing the inter-process event does not adopt a mode of locking a work queue, so that the time consumption of a CPU is saved, in the prior art, each subprocess can only process one http request at the same time, if the number of http requests is excessive and the number of subprocesses is small, more http requests in the work queue cannot be processed timely, and therefore the response speed to a client is reduced.
In one embodiment, after said establishing a connection between said target sub-process and said client according to said establishing a connection identification, further comprising: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; and when receiving a third read ready event returned by the kernel, the target subprocess reads an http request from the connection socket, constructs an http response corresponding to the http request, writes the http response into the connection socket, and sends the http response to the client.
According to the embodiment, the subprocess is responsible for processing the http requests, and due to the adoption of the IO multiplexing technology of epoll, the subprocess can process a plurality of http requests at the same time, and http responses corresponding to the http requests are constructed, so that the response speed to the client is improved to a certain extent.
In one embodiment, after said establishing a connection between said target sub-process and said client according to said establishing a connection identification, further comprising: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; when a third read ready event returned by the kernel is received by the target subprocess, reading an http request from the connection socket, constructing an http response corresponding to the http request, and registering a write ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess; returning a write ready event to the target sub-process when the kernel detects the write ready event; and when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
In the above embodiment, the buffer area of the socket may be already full, and then the write ready event is registered in the epoll kernel event table corresponding to the target sub-process, and further, when the buffer area of the socket is not full yet, the http response is written, so that the read-write error is prevented to a certain extent.
In one embodiment, the method for processing an inter-process event further includes: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the read-write error occurs, and closing the connection socket.
In the above embodiment, since a read-write error occurs, the descriptor of the connection socket is deleted from the epoll kernel event table corresponding to the target sub-process, and the connection socket is closed, so as to prevent more read-write errors from occurring, and release resources.
In one embodiment, the method for processing an inter-process event further includes: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the client closes the connection, and closing the connection socket.
In the above embodiment, since the client closes the connection, the descriptor of the connection socket is deleted from the epoll kernel event table corresponding to the target sub-process, and the connection socket is closed, so as to prevent a read-write error from occurring, and release the resource.
In one embodiment, before the kernel returns the first read ready event to the parent process when the kernel detects that there is snoop data in the snoop socket, the method further comprises: creating a process pool comprising a plurality of sub-processes, wherein the target sub-process is included in the plurality of sub-processes; a pipe is established between the parent process and each child process in the process pool.
In the above embodiment, the process pool is created in advance, and the communication pipe between the parent process and the child process is established so that the subsequent parent process and child process communicate.
In one embodiment, the method for processing an inter-process event further includes: if the parent process is detected to be exited, all sockets of the parent process, all sockets of the child process, an epoll kernel event table corresponding to the parent process and an epoll kernel event table corresponding to the child process are closed.
In the above embodiment, when the parent process exits, all the sockets and epoll kernel event tables are closed, so that the resources are released.
In a second aspect, there is provided an apparatus for processing an inter-process event, including:
the data monitoring module is used for returning a first read ready event to the father process when the kernel detects that the monitoring socket has monitoring data, wherein the monitoring data comprises data of a client request for establishing connection, and the father process registers the first read ready event on the monitoring socket in an epoll kernel event table corresponding to the father process in advance;
The first return module is used for determining a target sub-process when the parent process receives a first read ready event returned by the kernel, and writing a connection establishment identifier into a pipeline between the parent process and the target sub-process;
the second return module is used for returning a second read-ready event to the target subprocess when the kernel detects that the pipeline socket in the target subprocess has data, and the target subprocess registers the second read-ready event in an epoll kernel event table corresponding to the target subprocess in advance;
and the connection establishment module is used for reading the connection establishment identifier from the pipeline socket when the target subprocess receives a second read event returned by the kernel, and establishing connection between the target subprocess and the client according to the connection establishment identifier.
In one embodiment, the processing apparatus for an inter-process event further includes: a third return module for: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; and when receiving a third read ready event returned by the kernel, the target subprocess reads an http request from the connection socket, constructs an http response corresponding to the http request, writes the http response into the connection socket, and sends the http response to the client.
In one embodiment, the processing apparatus for an inter-process event further includes: a write module for: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; when a third read ready event returned by the kernel is received by the target subprocess, reading an http request from the connection socket, constructing an http response corresponding to the http request, and registering a write ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess; returning a write ready event to the target sub-process when the kernel detects the write ready event; and when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
In one embodiment, the processing apparatus for an inter-process event further includes: a read-write error module for: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the read-write error occurs, and closing the connection socket.
In one embodiment, the processing apparatus for an inter-process event further includes: a closing module for: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the client closes the connection, and closing the connection socket.
In one embodiment, the processing apparatus for an inter-process event further includes: a creation module for: creating a process pool comprising a plurality of sub-processes, wherein the target sub-process is included in the plurality of sub-processes; a pipe is established between the parent process and each child process in the process pool.
In one embodiment, the processing apparatus for an inter-process event further includes: an exit module for: if the parent process is detected to be exited, all sockets of the parent process, all sockets of the child process, an epoll kernel event table corresponding to the parent process and an epoll kernel event table corresponding to the child process are closed.
In a third aspect, a computer device is provided comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method of processing an inter-process event as described above when the computer program is executed.
In a fourth aspect, a computer readable storage medium is provided, having stored therein computer program instructions which, when read and executed by a processor, perform the steps of a method of processing an inter-process event as described above.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and should not be considered as limiting the scope, and other related drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow chart of an implementation of a method for processing an inter-process event according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a composition structure of a device for processing an inter-process event according to an embodiment of the present application;
fig. 3 is a block diagram showing an internal structure of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In one embodiment, a method of processing an inter-process event is provided. The execution main body of the processing method of the inter-process event according to the embodiment of the present invention is a computer device capable of implementing the processing method of the inter-process event according to the embodiment of the present invention, and the computer device may include, but is not limited to, a terminal and a server. The terminal comprises a desktop terminal and a mobile terminal, wherein the desktop terminal comprises, but is not limited to, a desktop computer and a vehicle-mounted computer; mobile terminals include, but are not limited to, cell phones, tablets, notebook computers, and smart watches. The server includes a high-performance computer and a high-performance computer cluster.
In one embodiment, as shown in fig. 1, there is provided a method for processing an inter-process event, including:
step 100, when the kernel detects that there is monitor data in the monitor socket, the kernel returns a first read ready event to the parent process, where the monitor data includes data that the client requests to establish a connection, and the parent process has registered the first read ready event on the monitor socket in advance in an epoll kernel event table corresponding to the parent process.
The first read ready event is that, in order to detect an event that there is monitor data in the monitor socket, the first read ready event on the monitor socket is registered in advance in an epoll kernel event table corresponding to the parent process, so that the kernel can monitor whether there is monitor data on the monitor socket, and when monitor that there is monitor data in the monitor socket, the first read ready event is returned to the parent process, where the monitor data includes data that a client requests to establish a connection, for example, the monitor data is a message that the client requests to establish a connection.
Step 200, when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identification into a pipeline between the parent process and the target child process.
And establishing a connection identifier, wherein the connection identifier is used for indicating the target subprocess to establish connection between the target subprocess and the client. When the parent process receives a first read ready event returned by the kernel, it is determined that monitoring data is readable in a monitoring socket, then a target child process is determined, and a connection establishment identification is written into a pipeline between the parent process and the target child process, so that the target child process processes data of a client request for connection establishment, namely, the target child process establishes connection between the target child process and the client, wherein the target child process is one of a plurality of child processes contained in a process pool, for example, the target child process is one child process with the minimum load selected from the plurality of child processes contained in the process pool according to a load balancing algorithm.
And 300, when the kernel detects that the pipeline socket in the target subprocess has data, the kernel returns a second read-ready event to the target subprocess, and the target subprocess registers the second read-ready event in an epoll kernel event table corresponding to the target subprocess in advance.
And the second read-ready event is an event with data readable in the pipeline socket, and the second read-ready event is registered in an epoll kernel event table corresponding to the target subprocess in advance, so that when the kernel detects that the data readable in the pipeline socket in the target subprocess exists, the kernel returns the second read-ready event to the target subprocess, so that the target subprocess can read the data in the pipeline socket.
And 400, when receiving a second read-ready event returned by the kernel, the target subprocess reads the connection establishment identifier from the pipeline socket, and establishes connection between the target subprocess and the client according to the connection establishment identifier.
Upon receipt of a second read-ready event returned by the kernel, the target sub-process determines that there is data readable in the pipe socket, then reads the connection establishment identifier from the pipe socket, and establishes a connection between the target sub-process and the client according to the connection establishment identifier, e.g., the target sub-process invokes an accept function to establish a connection between the target sub-process and the client so that after the connection is established, the target sub-process communicates with the client, and the client sends an http request to the target sub-process.
When the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to the parent process, wherein the monitoring data comprises data of a client side requesting to establish connection; then, when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process; and when the kernel detects that the data exists in the pipeline socket in the target subprocess, the kernel returns a second read-ready event to the target subprocess; and finally, when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier. Therefore, the method for processing the inter-process event does not adopt a mode of locking a work queue, so that the time consumption of a CPU is saved, in the prior art, each subprocess can only process one http request at the same time, if the number of http requests is excessive and the number of subprocesses is small, more http requests in the work queue cannot be processed timely, and therefore the response speed to a client is reduced.
In one embodiment, after the connection between the target sub-process and the client is established according to the connection establishment identifier in step 400, the method further includes:
and 500, when the kernel detects that the data exists in the connection socket in the target subprocess, the kernel returns a third read ready event to the target subprocess, and the target subprocess registers the third read ready event on the connection socket in the epoll kernel event table corresponding to the target subprocess in advance.
And the third read ready event is an event for detecting that the data is readable in the connection socket, and the target subprocess registers the third read ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess, so that when the kernel detects that the data is in the connection socket in the target subprocess, the kernel returns the third read ready event to the target subprocess to inform the target subprocess to read the data in the connection socket.
And 600, when receiving a third read ready event returned by the kernel, the target subprocess reads an http request from the connection socket, constructs an http response corresponding to the http request, writes the http response into the connection socket, and sends the http response to the client.
Because the target subprocess has established the connection with the client, the client can send an http request to the target subprocess, so that the target subprocess can read the http request from the connection socket when receiving a third read ready event returned by the kernel, and then the target subprocess processes the http request to construct an http response corresponding to the http request, and writes the http response into the connection socket after constructing the http response corresponding to the http request, so that the http response is sent to the client.
According to the embodiment, the subprocess is responsible for processing the http requests, and due to the adoption of the IO multiplexing technology of epoll, the subprocess can process a plurality of http requests at the same time, and http responses corresponding to the http requests are constructed, so that the response speed to the client is improved to a certain extent.
In one embodiment, after the connection between the target sub-process and the client is established according to the connection establishment identifier in step 400, the method further includes:
in step 700, when the kernel detects that there is data in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process.
Step 700 is identical to step 500 and will not be described in detail herein.
Step 800, when receiving a third read ready event returned by the kernel, the target sub-process reads an http request from the connection socket, constructs an http response corresponding to the http request, and registers the write ready event on the connection socket to an epoll kernel event table corresponding to the target sub-process.
The "reading the http request from the connection socket when the target sub-process receives the third read ready event returned by the kernel" in step 800, and constructing an http response corresponding to the http request "is the same as the" reading the http request from the connection socket when the target sub-process in step 600 receives the third read ready event returned by the kernel, and constructing an http response corresponding to the http request "which is not described in detail herein.
The write ready event is a writable event of a buffer area of the connection socket detected by the kernel, and it can be understood that the write ready event will not be generated when the buffer area of the connection socket is full, if the buffer area of the connection socket is full, data is still written into the buffer area of the connection socket, and a read-write error may occur, so that the target sub-process registers the write ready event into an epoll kernel event table corresponding to the target sub-process, and thus, when the kernel detects that the buffer area of the connection socket is writable, the kernel detects the write ready event and returns the write ready event to the target sub-process to write data (particularly, write an http request) into the connection socket through the target sub-process.
Step 900, when the kernel detects a write ready event, returning the write ready event to the target sub-process.
Since the write ready event is registered in the epoll kernel event table corresponding to the target sub-process in step 800, the write ready event is returned to the target sub-process when the kernel detects the write ready event.
And step 1000, when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
And when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket, so that the http response is sent to the client, and the response to the http request is completed.
In the above embodiment, the buffer area of the socket may be already full, and then the write ready event is registered in the epoll kernel event table corresponding to the target sub-process, and further, when the buffer area of the socket is not full yet, the http response is written, so that the read-write error is prevented to a certain extent.
In one embodiment, the method for processing an inter-process event further includes: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the read-write error occurs, and closing the connection socket.
The target sub-process can call a read function provided by the kernel in the running process, if the value returned by the read function to the target sub-process is-1, the target sub-process can detect that a read-write error occurs, then the target sub-process calls a close function provided by the kernel, closes a connection socket, and the target sub-process calls an epoll_ctl function provided by the kernel, and deletes a descriptor of the connection socket from an epoll kernel event table corresponding to the target sub-process.
In the above embodiment, since a read-write error occurs, the descriptor of the connection socket is deleted from the epoll kernel event table corresponding to the target sub-process, and the connection socket is closed, so as to prevent more read-write errors from occurring, and release resources.
In one embodiment, the method for processing an inter-process event further includes: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the client closes the connection, and closing the connection socket.
The target sub-process can call a read function provided by the kernel in the running process, if the value returned by the read function to the target sub-process is 0, the target sub-process can detect that the client closes the connection between the client and the target sub-process, then the target sub-process calls a close function provided by the kernel to close a connection socket, and the target sub-process calls an epoll_ctl function provided by the kernel to delete a descriptor of the connection socket from an epoll kernel event table corresponding to the target sub-process.
In the above embodiment, since the client closes the connection, the descriptor of the connection socket is deleted from the epoll kernel event table corresponding to the target sub-process, and the connection socket is closed, so as to prevent a read-write error from occurring, and release the resource.
In one embodiment, before the kernel returns the first ready-to-read event to the parent process when the kernel detects that there is snoop data in the snoop socket in step 100, the method further includes: creating a process pool comprising a plurality of sub-processes, wherein the target sub-process is included in the plurality of sub-processes; a pipe is established between the parent process and each child process in the process pool.
A process pool containing a plurality of subprocesses is created in advance, the plurality of subprocesses comprise target subprocesses, and then http requests initiated by the client can be processed through the plurality of subprocesses. A pipe is a communication technique used between a parent process and a child process, and after creating a child process, a pipe between the parent process and each child process in a process pool is established for subsequent parent process and each child process to communicate.
In the above embodiment, the process pool is created in advance, and the communication pipe between the parent process and the child process is established so that the subsequent parent process and child process communicate.
In one embodiment, the method for processing an inter-process event further includes: if the parent process is detected to be exited, all sockets of the parent process, all sockets of the child process, an epoll kernel event table corresponding to the parent process and an epoll kernel event table corresponding to the child process are closed.
For example, if the user closes the parent process, it may detect that the parent process exits, so all the sockets and epoll kernel event tables need to be closed, specifically, the parent process calls a close function provided by the kernel to close all the sockets of the parent process, including monitoring the sockets, the parent process continues to call the close function provided by the kernel to close the epoll kernel event table corresponding to the parent process, the child process calls the close function provided by the kernel to close all the sockets of the child process, including connecting the sockets and the pipeline sockets, and the child process continues to call the close function provided by the kernel to close the epoll kernel event table corresponding to the child process.
In the above embodiment, when the parent process exits, all the sockets and epoll kernel event tables are closed, so that the resources are released.
In one embodiment, as shown in fig. 2, there is provided an apparatus 200 for processing an inter-process event, including:
The data monitoring module 201 is configured to, when the kernel detects that there is monitoring data in the monitoring socket, return a first read ready event to the parent process, where the monitoring data includes data that the client requests to establish a connection, and the parent process has registered in advance the first read ready event on the monitoring socket into an epoll kernel event table corresponding to the parent process;
a first return module 202, configured to determine a target child process when the parent process receives a first read ready event returned by the kernel, and write a connection establishment identifier into a pipeline between the parent process and the target child process;
the second return module 203 is configured to, when the kernel detects that there is data in a pipe socket in a target sub-process, return a second read ready event to the target sub-process, where the target sub-process has registered the second read ready event in advance in an epoll kernel event table corresponding to the target sub-process;
and the connection establishing module 204 is configured to, when receiving a second read event returned by the kernel, read the connection establishment identifier from the pipe socket, and establish a connection between the target sub-process and the client according to the connection establishment identifier.
In one embodiment, the processing apparatus 200 for an inter-process event further includes: a third return module for: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; and when receiving a third read ready event returned by the kernel, the target subprocess reads an http request from the connection socket, constructs an http response corresponding to the http request, writes the http response into the connection socket, and sends the http response to the client.
In one embodiment, the processing apparatus 200 for an inter-process event further includes: a write module for: when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process; when a third read ready event returned by the kernel is received by the target subprocess, reading an http request from the connection socket, constructing an http response corresponding to the http request, and registering a write ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess; returning a write ready event to the target sub-process when the kernel detects the write ready event; and when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
In one embodiment, the processing apparatus 200 for an inter-process event further includes: a read-write error module for: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the read-write error occurs, and closing the connection socket.
In one embodiment, the processing apparatus 200 for an inter-process event further includes: a closing module for: and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the client closes the connection, and closing the connection socket.
In one embodiment, the processing apparatus for an inter-process event further includes: a creation module for: creating a process pool comprising a plurality of sub-processes, wherein the target sub-process is included in the plurality of sub-processes; a pipe is established between the parent process and each child process in the process pool.
In one embodiment, the processing apparatus 200 for an inter-process event further includes: an exit module for: if the parent process is detected to be exited, all sockets of the parent process, all sockets of the child process, an epoll kernel event table corresponding to the parent process and an epoll kernel event table corresponding to the child process are closed.
In one embodiment, as shown in fig. 3, a computer device is provided, which may be a terminal or a server in particular. The computer device comprises a processor, a memory and a network interface which are connected through a system bus, wherein the memory comprises a nonvolatile storage medium and an internal memory, the nonvolatile storage medium of the computer device stores an operating system and can also store a computer program, and the computer program can enable the processor to realize a processing method of an inter-process event when being executed by the processor. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others. The internal memory may also have stored therein a computer program which, when executed by the processor, causes the processor to perform a method of processing an inter-process event. It will be appreciated by those skilled in the art that the structure shown in FIG. 3 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
The method for processing an inter-process event provided by the application can be implemented in the form of a computer program, and the computer program can be run on a computer device as shown in fig. 3. The memory of the computer device may store therein various program templates that constitute the processing means for the inter-process events. Such as a data listening module 201, a first return module 202 and a second return module 203.
A computer device comprising a memory and a processor, the memory storing a computer program which, when executed by the processor, causes the processor to perform the steps of:
when the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to a parent process, wherein the monitoring data comprises data of a client request for establishing connection, and the parent process registers the first reading ready event on the monitoring socket into an epoll kernel event table corresponding to the parent process in advance;
when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process;
when the kernel detects that data exists in a pipeline socket in a target sub-process, the kernel returns a second read-ready event to the target sub-process, and the target sub-process registers the second read-ready event in an epoll kernel event table corresponding to the target sub-process in advance;
And when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier.
In one embodiment, a computer readable storage medium is provided, storing a computer program which, when executed by a processor, causes the processor to perform the steps of:
when the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to a parent process, wherein the monitoring data comprises data of a client request for establishing connection, and the parent process registers the first reading ready event on the monitoring socket into an epoll kernel event table corresponding to the parent process in advance;
when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process;
when the kernel detects that data exists in a pipeline socket in a target sub-process, the kernel returns a second read-ready event to the target sub-process, and the target sub-process registers the second read-ready event in an epoll kernel event table corresponding to the target sub-process in advance;
And when the target subprocess receives a second read-ready event returned by the kernel, reading the connection establishment identifier from the pipeline socket, and establishing connection between the target subprocess and the client according to the connection establishment identifier.
It should be noted that, the above-mentioned method for processing an inter-process event, apparatus for processing an inter-process event, computer device, and computer readable storage medium belong to a general inventive concept, and the content in the embodiments of the method for processing an inter-process event, apparatus for processing an inter-process event, computer device, and computer readable storage medium may be mutually applicable.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
Further, the units described as separate units may or may not be physically separate, and units displayed as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
Furthermore, functional modules in various embodiments of the present application may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion.
In this document, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and variations will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (8)

1. A method for processing an inter-process event, comprising:
when the kernel detects that the monitoring socket has monitoring data, the kernel returns a first reading ready event to a parent process, wherein the monitoring data comprises data of a client request for establishing connection, and the parent process registers the first reading ready event on the monitoring socket into an epoll kernel event table corresponding to the parent process in advance;
when the parent process receives a first read ready event returned by the kernel, determining a target child process, and writing a connection establishment identifier into a pipeline between the parent process and the target child process;
when the kernel detects that data exists in a pipeline socket in a target sub-process, the kernel returns a second read-ready event to the target sub-process, and the target sub-process registers the second read-ready event in an epoll kernel event table corresponding to the target sub-process in advance;
when receiving a second read-ready event returned by the kernel, the target subprocess reads the connection establishment identifier from the pipeline socket, and establishes connection between the target subprocess and the client according to the connection establishment identifier;
after the connection between the target sub-process and the client is established according to the connection establishment identifier, the method further comprises the following steps:
When the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process;
when a third read ready event returned by the kernel is received by the target subprocess, reading an http request from the connection socket, constructing an http response corresponding to the http request, and registering a write ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess;
returning a write ready event to the target sub-process when the kernel detects the write ready event;
and when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
2. The method of processing according to claim 1, further comprising:
and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the read-write error occurs, and closing the connection socket.
3. The method of processing according to claim 1, further comprising:
and deleting the descriptor of the connection socket from the epoll kernel event table corresponding to the target subprocess when the target subprocess detects that the client closes the connection, and closing the connection socket.
4. The processing method of claim 1, wherein before the kernel returns the first read ready event to the parent process when the kernel detects snoop data in a snoop socket, further comprising:
creating a process pool comprising a plurality of sub-processes, wherein the target sub-process is included in the plurality of sub-processes;
a pipe is established between the parent process and each child process in the process pool.
5. The method of processing according to claim 4, further comprising:
if the parent process is detected to be exited, all sockets of the parent process, all sockets of the child process, an epoll kernel event table corresponding to the parent process and an epoll kernel event table corresponding to the child process are closed.
6. An apparatus for processing an inter-process event, comprising:
the data monitoring module is used for returning a first read ready event to the father process when the kernel detects that the monitoring socket has monitoring data, wherein the monitoring data comprises data of a client request for establishing connection, and the father process registers the first read ready event on the monitoring socket in an epoll kernel event table corresponding to the father process in advance;
The first return module is used for determining a target sub-process when the parent process receives a first read ready event returned by the kernel, and writing a connection establishment identifier into a pipeline between the parent process and the target sub-process;
the second return module is used for returning a second read-ready event to the target subprocess when the kernel detects that the pipeline socket in the target subprocess has data, and the target subprocess registers the second read-ready event in an epoll kernel event table corresponding to the target subprocess in advance;
the connection establishment module is used for reading the connection establishment identifier from the pipeline socket when the target subprocess receives a second read event returned by the kernel, and establishing connection between the target subprocess and the client according to the connection establishment identifier; after the connection between the target sub-process and the client is established according to the connection establishment identifier, the method further comprises the following steps:
when the kernel detects that the data exists in the connection socket in the target sub-process, the kernel returns a third read ready event to the target sub-process, and the target sub-process registers the third read ready event on the connection socket in advance in an epoll kernel event table corresponding to the target sub-process;
When a third read ready event returned by the kernel is received by the target subprocess, reading an http request from the connection socket, constructing an http response corresponding to the http request, and registering a write ready event on the connection socket into an epoll kernel event table corresponding to the target subprocess;
returning a write ready event to the target sub-process when the kernel detects the write ready event;
and when receiving a write ready event returned by the kernel, the target subprocess writes the http response into the connection socket so as to send the http response to the client.
7. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the method of processing an inter-process event as claimed in any one of claims 1 to 5 when the computer program is executed.
8. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein computer program instructions which, when read and executed by a processor, perform the steps of the method of processing an inter-process event according to any of claims 1 to 5.
CN202111619272.6A 2021-12-27 2021-12-27 Processing method, device, equipment and storage medium for inter-process event Active CN114356446B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111619272.6A CN114356446B (en) 2021-12-27 2021-12-27 Processing method, device, equipment and storage medium for inter-process event

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111619272.6A CN114356446B (en) 2021-12-27 2021-12-27 Processing method, device, equipment and storage medium for inter-process event

Publications (2)

Publication Number Publication Date
CN114356446A CN114356446A (en) 2022-04-15
CN114356446B true CN114356446B (en) 2023-08-22

Family

ID=81103340

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111619272.6A Active CN114356446B (en) 2021-12-27 2021-12-27 Processing method, device, equipment and storage medium for inter-process event

Country Status (1)

Country Link
CN (1) CN114356446B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114756180B (en) * 2022-06-15 2022-12-09 广东睿江云计算股份有限公司 Method and device for distributing coverage writing data blocks, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103384274A (en) * 2013-07-15 2013-11-06 浙江大学 Hyper text transport protocol (http)-based communication method for connection of public network with intranet computer
CN103746977A (en) * 2013-12-27 2014-04-23 东软熙康健康科技有限公司 Connection method and device for Linux server
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
CN111061474A (en) * 2018-10-16 2020-04-24 深圳市茁壮网络股份有限公司 Lamda programming model and data processing method thereof
CN111309458A (en) * 2019-07-12 2020-06-19 北京关键科技股份有限公司 Asynchronous cooperative processing method for multi-node tasks
CN111625326A (en) * 2020-05-13 2020-09-04 北京字节跳动网络技术有限公司 Task pipeline execution method and device and electronic equipment

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8161544B2 (en) * 2006-07-19 2012-04-17 Microsoft Corporation Trusted communications with child processes

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103384274A (en) * 2013-07-15 2013-11-06 浙江大学 Hyper text transport protocol (http)-based communication method for connection of public network with intranet computer
CN103746977A (en) * 2013-12-27 2014-04-23 东软熙康健康科技有限公司 Connection method and device for Linux server
CN111061474A (en) * 2018-10-16 2020-04-24 深圳市茁壮网络股份有限公司 Lamda programming model and data processing method thereof
CN110413386A (en) * 2019-06-27 2019-11-05 深圳市富途网络科技有限公司 Multiprocessing method, apparatus, terminal device and computer readable storage medium
CN111309458A (en) * 2019-07-12 2020-06-19 北京关键科技股份有限公司 Asynchronous cooperative processing method for multi-node tasks
CN111625326A (en) * 2020-05-13 2020-09-04 北京字节跳动网络技术有限公司 Task pipeline execution method and device and electronic equipment

Also Published As

Publication number Publication date
CN114356446A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
CN108038039B (en) Method for recording log and micro-service system
US20230030856A1 (en) Distributed table storage processing method, device and system
CN114356446B (en) Processing method, device, equipment and storage medium for inter-process event
CN113535425A (en) Data sending method and device, electronic equipment and storage medium
CN114760233B (en) Service processing method, device, electronic equipment and storage medium
CN111966653A (en) Data processing method, device, server and storage medium for micro-service call link
CN111522706A (en) Method and device for monitoring page abnormity of front-end application
CN111414263A (en) Information processing method, device, server and storage medium
CN114637611A (en) Information processing method and device based on message queue and computer equipment
CN111159298B (en) Service request processing method and device, electronic equipment and storage medium
CN108241616B (en) Message pushing method and device
CN107291628B (en) Method and apparatus for accessing data storage device
CN115170152A (en) Data distribution method, device, equipment and storage medium
CN110764995B (en) Method, device, medium and electronic equipment for detecting file access abnormality
CN108959405B (en) Strong consistency reading method of data and terminal equipment
CN111459819A (en) Software testing method and device, electronic equipment and computer readable medium
CN112231290A (en) Method, device and equipment for processing local log and storage medium
CN114050991B (en) Method, device, equipment and storage medium for testing proxy
US9600508B1 (en) Data layer service availability
CN115037783B (en) Data transmission method and device
CN110874238A (en) Online service updating method and device
CN114691318A (en) Data queuing processing method, device, terminal and storage medium
CN116955287A (en) Data processing method, device, equipment and storage medium
CN115756952A (en) Micro service gateway management method, system, computer device and storage medium
CN116028160A (en) System, service request method and client for enterprise and bank

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant