com php-src: Fix posix_setrlimit() to use int as values instead of strings. Add constant for unlimited (POSIX_RLIMIT_INFINITY).: ext/posix/p osix.c

From: Date: Wed, 08 Jul 2015 22:04:13 +0000
Subject: com php-src: Fix posix_setrlimit() to use int as values instead of strings. Add constant for unlimited (POSIX_RLIMIT_INFINITY).: ext/posix/p osix.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-87856@lists.php.net to get a copy of this message
Commit: a55ca9a8d14d16708c0627c05e117b26d2aaef86 Author: Magnus Määttä <magnus@php.net> Thu, 9 Jul 2015 00:04:13 +0200 Parents: 963d906aff71325f0e3d3620318601c0fb5962c1 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a55ca9a8d14d16708c0627c05e117b26d2aaef86 Log: Fix posix_setrlimit() to use int as values instead of strings. Add constant for unlimited (POSIX_RLIMIT_INFINITY). Changed paths: M ext/posix/posix.c Diff: diff --git a/ext/posix/posix.c b/ext/posix/posix.c index ec28121..6d34da7 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -403,6 +403,9 @@ static PHP_MINIT_FUNCTION(posix) #ifdef RLIMIT_STACK REGISTER_LONG_CONSTANT("POSIX_RLIMIT_STACK", RLIMIT_STACK, CONST_CS | CONST_PERSISTENT); #endif +#ifdef HAVE_SETRLIMIT + REGISTER_LONG_CONSTANT("POSIX_RLIMIT_INFINITY", RLIM_INFINITY, CONST_CS | CONST_PERSISTENT); +#endif return SUCCESS; } /* }}} */ @@ -1381,30 +1384,20 @@ PHP_FUNCTION(posix_getrlimit) #endif /* HAVE_GETRLIMIT */ #ifdef HAVE_SETRLIMIT -/* {{{ proto bool posix_setrlimit(int resource, string softlimit, string hardlimit) +/* {{{ proto bool posix_setrlimit(int resource, int softlimit, int hardlimit) Set system resource consumption limits (POSIX.1-2001) */ PHP_FUNCTION(posix_setrlimit) { struct rlimit rl; - char *cur, *max; - size_t cur_len, max_len; + zend_long cur, max; int res; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lss", &res, &cur, &cur_len, &max, &max_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &res, &cur, &max) == FAILURE) { RETURN_FALSE; } - if (!strcasecmp(cur, "unlimited")) { - rl.rlim_cur = RLIM_INFINITY; - } else { - rl.rlim_cur = zend_atol(cur, cur_len); - } - - if (!strcasecmp(max, "unlimited")) { - rl.rlim_max = RLIM_INFINITY; - } else { - rl.rlim_max = zend_atol(max, max_len); - } + rl.rlim_cur = cur; + rl.rlim_max = max; if (setrlimit(res, &rl) == -1) { POSIX_G(last_error) = errno;

« previous php.cvs (#87856) next »