lua-nginx-module
lua-nginx-module copied to clipboard
ngx.thread.kill - give all threads the permissions to kill each other
Removed the restriction that only a parent of a thread can kill it, making the ngx.thread.kill API a bit more like the UNIX-style interface. In my code, I have a case in which a thread should kill another (non child) thread.
@aviramc Care must be take in the case when, for example, the parent is currently waiting on the thread being killed by a 3rd party. Will you add some test cases for such corner cases? I usually dare not merge anything that does not come with tests. Thanks!
@agentzh I will tests, but this may take some time. If you can review the changes beforehand, that would be great. This applies to all my open pull requests (there'll be more really soon)
@aviramc Yeah, sure. Thank you :)
@aviramc When you kill a thread being waited by its parent, I think you should notify the sleeping parent somehow.
@agentzh when you say a sleeping parent, do you mean a parent that is waiting on the thread?
@aviramc Yes, via ngx.thread.wait().
@agentzh , please review commit 4ca58fe. In order to notify the parent thread that it the child thread has been killed, I've used posted ngx_http_lua_post_thread(). In order to be able to pass parameters to the posted thread, I've added the nrets attribute to the posted thread object. If you approve this fix, I'll starting writing some test cases for the feature.
@aviramc Sorry for the long delay on my side! I've made some more comments. Will you please look into them? Thanks a lot!
This pull request is now in conflict :(