-
Notifications
You must be signed in to change notification settings - Fork 166
Block remote config signals during ftp functions #2957
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| #include "handlers_api.h" | ||
| #include "remote_config.h" | ||
| #include <signal.h> | ||
| #include <php.h> | ||
|
|
||
| /* We need to do signal blocking for the remote config signaling to not interfere with some PHP functions. | ||
| * See e.g. https://github.com/php/php-src/issues/16800 | ||
| * I don't know the full problem space, so I expect there might be functions missing here, and we need to eventually expand this list. | ||
| */ | ||
| static void dd_handle_signal(zif_handler original_function, INTERNAL_FUNCTION_PARAMETERS) { | ||
| sigset_t x; | ||
| sigemptyset(&x); | ||
| sigaddset(&x, SIGVTALRM); | ||
| sigprocmask(SIG_BLOCK, &x, NULL); | ||
|
|
||
| original_function(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
|
|
||
| sigprocmask(SIG_UNBLOCK, &x, NULL); | ||
| #ifndef __linux__ | ||
| // At least on linux unblocking causes immediate signal delivery. | ||
| ddtrace_check_for_new_config_now(); | ||
| #endif | ||
| } | ||
|
|
||
| #define BLOCKSIGFN(function) \ | ||
| static zif_handler dd_handle_signal_zif_##function;\ | ||
| static ZEND_FUNCTION(dd_handle_signal_##function) { \ | ||
| dd_handle_signal(dd_handle_signal_zif_##function, INTERNAL_FUNCTION_PARAM_PASSTHRU); \ | ||
| } | ||
|
|
||
| #define BLOCK(x) \ | ||
| x(ftp_alloc) \ | ||
| x(ftp_append) \ | ||
| x(ftp_cdup) \ | ||
| x(ftp_chdir) \ | ||
| x(ftp_chmod) \ | ||
| x(ftp_close) \ | ||
| x(ftp_connect) \ | ||
| x(ftp_delete) \ | ||
| x(ftp_exec) \ | ||
| x(ftp_fget) \ | ||
| x(ftp_fput) \ | ||
| x(ftp_get) \ | ||
| x(ftp_get_option) \ | ||
| x(ftp_login) \ | ||
| x(ftp_mdtm) \ | ||
| x(ftp_mkdir) \ | ||
| x(ftp_mlsd) \ | ||
| x(ftp_nb_continue) \ | ||
| x(ftp_nb_fget) \ | ||
| x(ftp_nb_fput) \ | ||
| x(ftp_nb_get) \ | ||
| x(ftp_nb_put) \ | ||
| x(ftp_nlist) \ | ||
| x(ftp_pasv) \ | ||
| x(ftp_put) \ | ||
| x(ftp_pwd) \ | ||
| x(ftp_quit) \ | ||
| x(ftp_raw) \ | ||
| x(ftp_rawlist) \ | ||
| x(ftp_rename) \ | ||
| x(ftp_rmdir) \ | ||
| x(ftp_site) \ | ||
| x(ftp_size) \ | ||
| x(ftp_ssl_connect) \ | ||
| x(ftp_systype) \ | ||
|
|
||
| BLOCK(BLOCKSIGFN) | ||
|
|
||
| void ddtrace_signal_block_handlers_startup() { | ||
| #define BLOCKFNENTRY(function) { ZEND_STRL(#function), &dd_handle_signal_zif_##function, ZEND_FN(dd_handle_signal_##function) }, | ||
| datadog_php_zif_handler handlers[] = { BLOCK(BLOCKFNENTRY) }; | ||
|
|
||
| size_t handlers_len = sizeof handlers / sizeof handlers[0]; | ||
| for (size_t i = 0; i < handlers_len; ++i) { | ||
| datadog_php_install_handler(handlers[i]); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Submodule libdatadog
updated
27 files
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 my understanding is correct, this will re-emit at least one queued signal, meaning that you may not need to call
ddtrace_check_for_new_config_now.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.
Interesting, that's really nice. Manpages for non-Linux (e.g. macos) say no such thing, so I'll
#ifndef __linux__this.