Skip to content

Commit

Permalink
small improvements (#957)
Browse files Browse the repository at this point in the history
* added s/m/h/d prefix for --time-limit option and updated docs

* removed the 2 GB upper limit for the --hard-memory-limit option
  • Loading branch information
troy4eg authored Jan 16, 2024
1 parent 8f335c7 commit d57f9fe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion common/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ int convert_bytes_num_to_string(long long bytes, char *res, int res_size) {
}

int parse_time_limit(const char *s) {
int x;
int x = 0;
char c = 0;
if (sscanf(s, "%d%c", &x, &c) < 1) {
kprintf ("Parsing time limit for option fail: %s\n", s);
Expand Down
2 changes: 1 addition & 1 deletion docs/kphp-server/execution-options/server-cmd-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ A unique name for the KPHP server, required if several KPHP servers are launched

<aside>--time-limit {limit} / -t {limit}</aside>

A time limit in seconds for script processing, default **30** for server mode and **infinity** for CLI mode. To override, pass a whole number. The maximum is 7 minutes (if passed a greater value, it would be ceiled).
A time limit in seconds for script processing, default **30s** for server mode and **infinity** for CLI mode. To override, pass a whole number. (You can use the s/m/h/d prefix to set the limit in seconds/minutes/hours/days)

<aside>--worker-queries-to-reload {n}</aside>

Expand Down
8 changes: 6 additions & 2 deletions server/php-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,11 @@ int main_args_handler(int i, const char *long_option) {
}
case 'm': {
max_memory = parse_memory_limit_default(optarg, 'm');
assert((1 << 20) <= max_memory && max_memory <= (2047LL << 20));
const long long min_size = 1 << 20;
if (max_memory <= min_size) {
kprintf("--%s option: cannot be less than 1 megabyte\n", long_option);
return -1;
}
return 0;
}
case 'f': {
Expand Down Expand Up @@ -1873,7 +1877,7 @@ int main_args_handler(int i, const char *long_option) {
return vk::singleton<ServerConfig>::get().init_from_config(optarg);
}
case 't': {
script_timeout = static_cast<int>(normalize_script_timeout(atoi(optarg)));
script_timeout = static_cast<int>(normalize_script_timeout(parse_time_limit(optarg)));
return 0;
}
case 'o': {
Expand Down

0 comments on commit d57f9fe

Please sign in to comment.