-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mk_server: scheduler: new interface to enqueue defer events object free
This patch implements a new scheduler interface that allows the plugins to defer the release of some object, the context and requirement of implementation is based on the following behavior: 1. A connection is being handled by a plugin (e.g: CGI), the CGI plugin also registered it own 'event' into the Event Loop to read incoming data from the child process. 2. Before to receive the response, the client for some reason closes the TCP connection. 3. The Scheduler will trap the 'close event' on the connection and start notifying the protocol handler and the plugin associated about this. 4. The plugin will catch the notification on it stage30_hangup() callback so it will release it resources (CGI context, child process, close file desriptors, etc). 5. At this point in the same Event Loop round, it may contain many events notified in the array, e.g: [0] TCP connection closed [N] others... [16] Read data from CGI child So when we reach the the 'TCP connection closed'[0], we perform a release procedure as stated on #3 and #4, but then we reach 'Read data from CGI child'[16] but our event context was already released due to 'TCP connection closed'[0]. For hence we face a memory corruption. In order to avoid this kind of situations, the Scheduler and the plugins interface now provides a new interface to request the Server to perform a 'memory release' of a linked list of 'struct mk_event' after processing all the events in the round returned by mk_event_wait(). A plugin only requires to be aware of the broken connection stage30_hangup() and register it event object mk_api->sched_event_free(struct mk_event *x). Signed-off-by: Eduardo Silva <eduardo@monkey.io>
- Loading branch information
Showing
5 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters