-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feature: introduced the 'lua_sa_restart' directive, which sets the SA_RESTART flag on nginx workers signal dispositions. #1296
Conversation
358763e
to
9f2d3b3
Compare
9f2d3b3
to
aba20d0
Compare
src/ngx_http_lua_worker.c
Outdated
struct sigaction act; | ||
|
||
if (ngx_process != NGX_PROCESS_WORKER | ||
&& ngx_process != NGX_PROCESS_SINGLE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to take into account the privileged agent helper process here.
@thibaultcha I think it's better to simply enable |
@agentzh Does this list sound good for the set of signals the |
I must admit that for the sake of backwards-compatibility (in the event of an unforeseen issue), I was under the impression that we would not enable this flag on any signal by default - especially considering it is enabled by default in resty-cli (as per openresty/resty-cli#41), where it matters the most. But I am fine enabling it by default in this module's init context, no problem (if the suggested list of signals is good to go). |
@thibaultcha That list looks good to me. This is also important for non-resty-cli contexts. I don't like enabling by hand, which is too easy to miss for average users. And it does not look like there is any unwanted side effects so there's no backward compatibility that we need to preserve here? |
@thibaultcha I think at least we should include the signals found in http://lxr.nginx.org/source/src/os/unix/ngx_process.c#0039. The last two are not needed since they are ignored already. |
aba20d0
to
fd3b236
Compare
@agentzh @dndx I have reworked the PR and other related ones. So far, this PR sets the SA_RESTART flag upon worker initialization, and exposes an FFI API that openresty/lua-resty-core#183 can consume. openresty/resty-cli#41 now simply adds regression tests for the EINTR error on file handle reads (still needs docs & tests if we are exposing the Lua-land API). I do wonder if maintaining a patch adding the SA_RESTART flag in ngx_init_signals would be easier? But the FFI API is a nice-to-have anyway I think. |
9714bb0
to
2598710
Compare
5a7e66b
to
f928849
Compare
Patch updated:
I did like the granularity offered by the FFI API (being able to set/unset this flag as desired on a per-signal basis), but I removed it to show what a minimal patch would look like. I can add the FFI back any time if desired. |
src/ngx_http_lua_util.c
Outdated
@@ -70,6 +70,25 @@ | |||
#endif | |||
|
|||
|
|||
#if !(NGX_WIN32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we do feature test instead of excluding just win32 here for better portability.
f928849
to
92f4e62
Compare
@agentzh Updated with a feature test. Mind having another look? If ready, I will port this PR to the meta-lua module as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should add some docs. Otherwise it looks good to me.
92f4e62
to
e6be59f
Compare
Pushed some documentation. |
d6d6673
to
67e118b
Compare
src/ngx_http_lua_util.c
Outdated
"setting SA_RESTART for signal %d", *signo); | ||
|
||
if (sigaction(*signo, NULL, &act) != 0) { | ||
ngx_log_error(NGX_LOG_WARN, log, 0, "failed to get sigaction for " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use the errno
arg directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agentzh Updated
… SA_RESTART flag on nginx workers signal dispositions.
67e118b
to
fbf47fa
Compare
This is one of 4 PRs to properly handle
EINTR
errors in resty-cli (and/or OpenResty if desired by the user).SA_RESTART
on signal handlerssig_restart()
APISA_RESTART
flag on interrupting signalsIf all PRs are merged:
io.popen()
popen crashes in resty but not in luajit resty-cli#35