Skip to content

Commit

Permalink
uwsgi_opt_set_int: use strtol() and warn on non-numeric data
Browse files Browse the repository at this point in the history
This should not change the existing behavior of using 0 when
a non-numeric value is provided, but loudly logs:

    $ uwsgi test.ini --processes 2x
    [uWSGI] getting INI configuration from test.ini
    [WARNING] non-numeric value "2x" for option "processes" - using 2 !
    [WARNING] non-numeric value "true" for option "http-keepalive" - using 0 !
    *** Starting uWSGI 2.1-dev-ade7d170 (64bit) on [Sun Jun 23 18:36:29 2019] ***
    compiled with version: 8.3.0 on 23 June 2019 16:22:05
    ...

It might be saner to not even start with invalid options. However,
hypothetical setups with http-keepalive=off or http-keepalive=false may
then fail to start at all and people might get unahppy.
  • Loading branch information
awelzel authored and Arne Welzel committed Jun 26, 2019
1 parent 3bfe1dd commit fcaeb88
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/uwsgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -4138,7 +4138,11 @@ void uwsgi_opt_safe_fd(char *opt, char *value, void *foobar) {
void uwsgi_opt_set_int(char *opt, char *value, void *key) {
int *ptr = (int *) key;
if (value) {
*ptr = atoi((char *) value);
char *endptr;
*ptr = (int)strtol(value, &endptr, 10);
if (*endptr) {
uwsgi_log("[WARNING] non-numeric value \"%s\" for option \"%s\" - using %d !\n", value, opt, *ptr);
}
}
else {
*ptr = 1;
Expand Down

0 comments on commit fcaeb88

Please sign in to comment.