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
Issue #1384: Refactor some common code in the Timer API for legibilit… #1428
base: master
Are you sure you want to change the base?
Conversation
time_t now; | ||
if (alarms_blocked == TRUE) { | ||
alarms_pending++; | ||
return; |
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.
If alarms are blocked, we shouldn't enter the while
loop at all. Previously, we'd enter the while
loop, set nalarms = 0
, and then check whether alarms were blocked. If they were, then perhaps the SIGALRM
signal which triggered this function call might not be properly handled, and in fact may have been "forgotten" due to the nalarms = 0
setting. Perhaps that might be the cause of some of the symptoms/behaviors reported in this issue?
Note to self: It is possible to handle a SIGALRM
signal while alarms are blocked; due to the ordering of signal handling in the ProFTPD code, pr_alarms_blocked()
could be called after the SIGALRM
signal is received, and before it is processed.
1f6188e
to
05e9213
Compare
@@ -152,7 +152,7 @@ static void chk_on_blk_list(union block_hdr *blok, union block_hdr *free_blk, | |||
#endif /* PR_USE_DEVEL */ | |||
} | |||
|
|||
/* Free a chain of blocks -- _must_ call with alarms blocked. */ | |||
/* Free a chain of blocks -- _must_ call with signals blocked. */ |
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.
Turns out that attempting to use pr_trace_msg()
in the pr_alarms_block()
function leads to a stack overflow, since the trace logging code calls into the Pools API, which blocks alarms, which calls the trace logging code, etc.
To avoid this -- and to honor what the Pools API really needs here -- we block signals, rather than alarms. And this is more desirable, as pr_alarms_block()
does not block SIGARLM
signals, it only blocks the processing of the timer callbacks. In these Pool routines, we don't want interruptions at all via signals, thus pr_signals_block()
is better here anyway.
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.
The follow-on, then, is that we cannot call pr_trace_msg()
within the pr_signals_block()
functions, either, lest we trigger the same stack overflow!
05e9213
to
a43c64a
Compare
a43c64a
to
3075371
Compare
3075371
to
176bcbb
Compare
176bcbb
to
d3ba6b9
Compare
…y/tracing, and add trace logging of alarm blocking.
d3ba6b9
to
017bc17
Compare
…y/tracing, and add trace logging of alarm blocking.