Browse Source

Catch a timeout and add user-level interface for connection handling

experimetnal/RETURN_REF_PATCH
Rasmus Lerdorf 27 years ago
parent
commit
d3439023d3
  1. 57
      ext/standard/basic_functions.c
  2. 5
      ext/standard/basic_functions.h
  3. 1
      main/main.c

57
ext/standard/basic_functions.c

@ -335,6 +335,11 @@ function_entry basic_functions[] = {
PHP_FE(array_keys, NULL)
PHP_FE(array_values, NULL)
PHP_FE(connection_aborted, NULL)
PHP_FE(connection_timeout, NULL)
PHP_FE(connection_status, NULL)
PHP_FE(ignore_user_abort, NULL)
{NULL, NULL, NULL}
};
@ -2337,6 +2342,58 @@ PHP_FUNCTION(defined)
}
}
/* {{{ proto int connection_aborted(void)
Returns true if client disconnected */
PHP_FUNCTION(connection_aborted)
{
RETURN_LONG(PG(connection_status)&PHP_CONNECTION_ABORTED);
}
/* }}} */
/* {{{ proto int connection_timeout(void)
Returns true if script timed out */
PHP_FUNCTION(connection_timeout)
{
RETURN_LONG(PG(connection_status)&PHP_CONNECTION_TIMEOUT);
}
/* }}} */
/* {{{ proto int connection_status(void)
Returns the connection status bitfield */
PHP_FUNCTION(connection_status)
{
RETURN_LONG(PG(connection_status));
}
/* }}} */
/* {{{ proto int ignore_user_abort(boolean value)
Set whether we want to ignore a user abort event or not */
PHP_FUNCTION(ignore_user_abort)
{
pval *arg;
int old_setting;
old_setting = PG(ignore_user_abort);
switch (ARG_COUNT(ht)) {
case 0:
break;
case 1:
if (getParameters(ht,1,&arg) == FAILURE) {
RETURN_FALSE;
}
convert_to_long(arg);
PG(ignore_user_abort)=arg->value.lval;
break;
default:
WRONG_PARAM_COUNT;
break;
}
RETURN_LONG(old_setting);
}
/* }}} */
/* {{{ proto bool function_exists(string function_name)
Checks if a given function has been defined */
PHP_FUNCTION(function_exists)

5
ext/standard/basic_functions.h

@ -123,6 +123,11 @@ PHP_FUNCTION(print_r);
PHP_FUNCTION(define);
PHP_FUNCTION(defined);
PHP_FUNCTION(connection_aborted);
PHP_FUNCTION(connection_timeout);
PHP_FUNCTION(connection_status);
PHP_FUNCTION(ignore_user_abort);
PHP_FUNCTION(function_exists);
PHP_FUNCTION(in_array);
PHP_FUNCTION(extract);

1
main/main.c

@ -474,6 +474,7 @@ static void php3_timeout(int dummy)
php_error(E_ERROR, "Maximum execution time of %d second%s exceeded",
php_timeout_seconds, php_timeout_seconds == 1 ? "" : "s");
PG(connection_status) |= PHP_CONNECTION_TIMEOUT;
}
#endif

Loading…
Cancel
Save