From: Markus Fischer Date: Tue, 30 Apr 2002 22:01:06 +0000 (+0000) Subject: - Allow resetting the module global last_error too. X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~330 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1c1ee9f6e7329f5d52237726fb39e79d047d2e7;p=php - Allow resetting the module global last_error too. --- diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c index b1008f1bae..37caf6026a 100644 --- a/ext/sockets/sockets.c +++ b/ext/sockets/sockets.c @@ -1939,18 +1939,21 @@ PHP_FUNCTION(socket_last_error) /* }}} */ /* {{{ proto void socket_clear_error(resource socket) - Clears the error on the socket */ + Clears the error on the socket or the last error code. */ PHP_FUNCTION(socket_clear_error) { - zval *arg1; + zval *arg1 = NULL; php_socket *php_sock; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &arg1) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &arg1) == FAILURE) return; - ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, le_socket); - - php_sock->error = 0; + if (arg1) { + ZEND_FETCH_RESOURCE(php_sock, php_socket*, &arg1, -1, le_socket_name, le_socket); + php_sock->error = 0; + } else { + SOCKETS_G(last_error) = 0; + } return; }