mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
Move timeout code to Zend, allow Win32 timeouts
@- Implemented max_execution_time under Win32 (Zeev)
This commit is contained in:
parent
e3ae196da8
commit
f29eae1302
6 changed files with 21 additions and 62 deletions
|
@ -241,6 +241,7 @@ PHP_INI_BEGIN()
|
||||||
STD_PHP_INI_ENTRY("mysql.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysql_globals, mysql_globals)
|
STD_PHP_INI_ENTRY("mysql.default_user", NULL, PHP_INI_ALL, OnUpdateString, default_user, zend_mysql_globals, mysql_globals)
|
||||||
STD_PHP_INI_ENTRY("mysql.default_password", NULL, PHP_INI_ALL, OnUpdateString, default_password, zend_mysql_globals, mysql_globals)
|
STD_PHP_INI_ENTRY("mysql.default_password", NULL, PHP_INI_ALL, OnUpdateString, default_password, zend_mysql_globals, mysql_globals)
|
||||||
PHP_INI_ENTRY("mysql.default_port", NULL, PHP_INI_ALL, OnMySQLPort)
|
PHP_INI_ENTRY("mysql.default_port", NULL, PHP_INI_ALL, OnMySQLPort)
|
||||||
|
STD_PHP_INI_ENTRY("mysql.default_socket", NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_socket, zend_mysql_globals, mysql_globals)
|
||||||
PHP_INI_END()
|
PHP_INI_END()
|
||||||
|
|
||||||
|
|
||||||
|
@ -311,7 +312,7 @@ PHP_MINFO_FUNCTION(mysql)
|
||||||
|
|
||||||
static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||||
{
|
{
|
||||||
char *user,*passwd,*host,*socket=NULL,*tmp;
|
char *user,*passwd,*host,*socket,*tmp;
|
||||||
char *hashed_details;
|
char *hashed_details;
|
||||||
int hashed_details_length,port = MYSQL_PORT;
|
int hashed_details_length,port = MYSQL_PORT;
|
||||||
MYSQL *mysql;
|
MYSQL *mysql;
|
||||||
|
@ -319,6 +320,8 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent)
|
||||||
MySLS_FETCH();
|
MySLS_FETCH();
|
||||||
PLS_FETCH();
|
PLS_FETCH();
|
||||||
|
|
||||||
|
socket = MySG(default_socket);
|
||||||
|
|
||||||
if (PG(sql_safe_mode)) {
|
if (PG(sql_safe_mode)) {
|
||||||
if (ZEND_NUM_ARGS()>0) {
|
if (ZEND_NUM_ARGS()>0) {
|
||||||
php_error(E_NOTICE,"SQL safe mode in effect - ignoring host/user/password information");
|
php_error(E_NOTICE,"SQL safe mode in effect - ignoring host/user/password information");
|
||||||
|
|
|
@ -82,6 +82,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mysql)
|
||||||
long allow_persistent;
|
long allow_persistent;
|
||||||
long default_port;
|
long default_port;
|
||||||
char *default_host, *default_user, *default_password;
|
char *default_host, *default_user, *default_password;
|
||||||
|
char *default_socket;
|
||||||
ZEND_END_MODULE_GLOBALS(mysql);
|
ZEND_END_MODULE_GLOBALS(mysql);
|
||||||
|
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
|
|
59
main/main.c
59
main/main.c
|
@ -96,8 +96,6 @@ static MUTEX_T global_lock;
|
||||||
|
|
||||||
|
|
||||||
static void php_build_argv(char *s, zval *track_vars_array ELS_DC PLS_DC);
|
static void php_build_argv(char *s, zval *track_vars_array ELS_DC PLS_DC);
|
||||||
static void php_timeout(int dummy);
|
|
||||||
static void php_set_timeout(long seconds);
|
|
||||||
|
|
||||||
void *gLock; /*mutex variable */
|
void *gLock; /*mutex variable */
|
||||||
|
|
||||||
|
@ -441,55 +439,6 @@ static void php_error_cb(int type, const char *error_filename, const uint error_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static long php_timeout_seconds;
|
|
||||||
|
|
||||||
#ifdef HAVE_SETITIMER
|
|
||||||
static void php_timeout(int dummy)
|
|
||||||
{
|
|
||||||
PLS_FETCH();
|
|
||||||
|
|
||||||
PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
|
|
||||||
php_error(E_ERROR, "Maximum execution time of %d second%s exceeded",
|
|
||||||
php_timeout_seconds, php_timeout_seconds == 1 ? "" : "s");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* This one doesn't exists on QNX */
|
|
||||||
#ifndef SIGPROF
|
|
||||||
#define SIGPROF 27
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void php_set_timeout(long seconds)
|
|
||||||
{
|
|
||||||
#ifdef PHP_WIN32
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_SETITIMER
|
|
||||||
struct itimerval t_r; /* timeout requested */
|
|
||||||
|
|
||||||
t_r.it_value.tv_sec = seconds;
|
|
||||||
t_r.it_value.tv_usec = t_r.it_interval.tv_sec = t_r.it_interval.tv_usec = 0;
|
|
||||||
|
|
||||||
php_timeout_seconds = seconds;
|
|
||||||
setitimer(ITIMER_PROF, &t_r, NULL);
|
|
||||||
signal(SIGPROF, php_timeout);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void php_unset_timeout(void)
|
|
||||||
{
|
|
||||||
#ifdef PHP_WIN32
|
|
||||||
#else
|
|
||||||
# ifdef HAVE_SETITIMER
|
|
||||||
struct itimerval no_timeout;
|
|
||||||
|
|
||||||
no_timeout.it_value.tv_sec = no_timeout.it_value.tv_usec = no_timeout.it_interval.tv_sec = no_timeout.it_interval.tv_usec = 0;
|
|
||||||
|
|
||||||
setitimer(ITIMER_PROF, &no_timeout, NULL);
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* {{{ proto void set_time_limit(int seconds)
|
/* {{{ proto void set_time_limit(int seconds)
|
||||||
Sets the maximum time a script can run */
|
Sets the maximum time a script can run */
|
||||||
|
@ -518,8 +467,8 @@ PHP_FUNCTION(set_time_limit)
|
||||||
should work fine. Is this FIXME a WIN32 problem? Is
|
should work fine. Is this FIXME a WIN32 problem? Is
|
||||||
there no way to do per-thread timers on WIN32?
|
there no way to do per-thread timers on WIN32?
|
||||||
*/
|
*/
|
||||||
php_unset_timeout();
|
zend_unset_timeout();
|
||||||
php_set_timeout(Z_LVAL_PP(new_timeout));
|
zend_set_timeout(Z_LVAL_PP(new_timeout));
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
|
@ -654,7 +603,7 @@ int php_request_startup(CLS_D ELS_DC PLS_DC SLS_DC)
|
||||||
virtual_cwd_activate(SG(request_info).path_translated);
|
virtual_cwd_activate(SG(request_info).path_translated);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
php_set_timeout(PG(max_execution_time));
|
zend_set_timeout(PG(max_execution_time));
|
||||||
|
|
||||||
if (PG(expose_php)) {
|
if (PG(expose_php)) {
|
||||||
sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
|
sapi_add_header(SAPI_PHP_VERSION_HEADER, sizeof(SAPI_PHP_VERSION_HEADER)-1, 1);
|
||||||
|
@ -703,7 +652,7 @@ void php_request_shutdown(void *dummy)
|
||||||
sapi_deactivate(SLS_C);
|
sapi_deactivate(SLS_C);
|
||||||
|
|
||||||
shutdown_memory_manager(CG(unclean_shutdown), 0);
|
shutdown_memory_manager(CG(unclean_shutdown), 0);
|
||||||
php_unset_timeout();
|
zend_unset_timeout();
|
||||||
|
|
||||||
global_unlock();
|
global_unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -300,6 +300,8 @@ mysql.default_port = ; default port number for mysql_connect(). If unset,
|
||||||
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
||||||
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
||||||
; (in that order). Win32 will only look at MYSQL_PORT.
|
; (in that order). Win32 will only look at MYSQL_PORT.
|
||||||
|
mysql.default_socket = ; default socket name for local MySQL connects. If empty, uses the built-in
|
||||||
|
; MySQL defaults
|
||||||
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
||||||
|
|
|
@ -288,6 +288,8 @@ mysql.default_port = ; default port number for mysql_connect(). If unset,
|
||||||
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
||||||
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
||||||
; (in that order). Win32 will only look at MYSQL_PORT.
|
; (in that order). Win32 will only look at MYSQL_PORT.
|
||||||
|
mysql.default_socket = ; default socket name for local MySQL connects. If empty, uses the built-in
|
||||||
|
; MySQL defaults
|
||||||
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
||||||
|
|
|
@ -288,6 +288,8 @@ mysql.default_port = ; default port number for mysql_connect(). If unset,
|
||||||
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
; mysql_connect() will use the $MYSQL_TCP_PORT, or the mysql-tcp
|
||||||
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
; entry in /etc/services, or the compile-time defined MYSQL_PORT
|
||||||
; (in that order). Win32 will only look at MYSQL_PORT.
|
; (in that order). Win32 will only look at MYSQL_PORT.
|
||||||
|
mysql.default_socket = ; default socket name for local MySQL connects. If empty, uses the built-in
|
||||||
|
; MySQL defaults
|
||||||
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_host = ; default host for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_user = ; default user for mysql_connect() (doesn't apply in safe mode)
|
||||||
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
mysql.default_password = ; default password for mysql_connect() (doesn't apply in safe mode)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue