New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write to pipe log using vmsplice() (Trac #3) #3
Comments
Trac update at 20100726T17:59:53: charlie_brown commented:
|
Trac update at 20110227T00:07:34:
|
Trac update at 20110906T19:05:21:
|
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>
Linux kernel provides a syscall named vmsplice() which allows to write an
iov struct with zero copy to a pipe, we must use vmsplice() instead of
writev() for that procedure.
Migrated from http://bugs.monkey-project.com/ticket/3
The text was updated successfully, but these errors were encountered: