Skip to content

Commit

Permalink
Merge pull request #4046 from sysown/v2.x-4001
Browse files Browse the repository at this point in the history
Fix crash on RESTAPI script invocation - Closes #4001
  • Loading branch information
renecannao authored Dec 12, 2022
2 parents 8fff0f3 + be9088b commit 4ff11f4
Show file tree
Hide file tree
Showing 31 changed files with 1,455 additions and 452 deletions.
1 change: 1 addition & 0 deletions include/proxysql_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ enum debug_module {
PROXY_DEBUG_IPC,
PROXY_DEBUG_QUERY_CACHE,
PROXY_DEBUG_QUERY_STATISTICS,
PROXY_DEBUG_RESTAPI,
PROXY_DEBUG_UNKNOWN // this module doesn't exist. It is used only to define the last possible module
};

Expand Down
19 changes: 9 additions & 10 deletions include/proxysql_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,27 @@ cfmt_t cstr_format(char (&out_buf)[N], const char* fmt, ...) {
/**
* @brief Simple struct that holds the 'timeout options' for 'wexecvp'.
*/
struct to_opts {
struct to_opts_t {
/**
* @brief Timeout for the script execution to be completed, in case of being
* exceeded, the script will be terminated.
*/
unsigned int timeout_us;
/**
* @brief Timeout used for 'select()' non blocking calls.
* @brief Timeout used for 'poll()' non blocking calls.
*/
suseconds_t select_to_us;
suseconds_t poll_to_us;
/**
* @brief The duration of the sleeps between the checks being performed
* on the child process waiting it to exit after being signaled to terminate,
* before issuing 'SIGKILL'.
*/
unsigned int it_delay_us;
unsigned int waitpid_delay_us;
/**
* @brief The timeout to be waited on the child process after being signaled
* with 'SIGTERM' before being forcely terminated by 'SIGKILL'.
*/
unsigned int sigkill_timeout_us;
unsigned int sigkill_to_us;
};

/**
Expand All @@ -165,17 +165,16 @@ struct to_opts {
* @return 0 In case of success or one of the following error codes:
* - '-1' in case any 'pipe()' creation failed.
* - '-2' in case 'fork()' call failed.
* - '-3' in case 'fcntl()' call failed .
* - '-4' in case of resource exhaustion, file descriptors being used exceeds 'FD_SETSIZE'.
* - '-5' in case 'select()' call failed.
* - '-6' in case 'read()' from pipes failed with a non-expected error.
* - '-3' in case 'fcntl()' call failed.
* - '-4' in case 'poll()' call failed.
* - '-5' in case 'read()' from pipes failed with a non-expected error.
* - 'ETIME' in case the executable has exceeded the timeout supplied in 'opts.timeout_us'.
* In all this cases 'errno' is set to the error reported by the failing 'system call'.
*/
int wexecvp(
const std::string& file,
const std::vector<const char*>& argv,
const to_opts* opts,
const to_opts_t& opts,
std::string& s_stdout,
std::string& s_stderr
);
Expand Down
Loading

0 comments on commit 4ff11f4

Please sign in to comment.