From c1c1ee9f6e7329f5d52237726fb39e79d047d2e7 Mon Sep 17 00:00:00 2001 From: Markus Fischer Date: Tue, 30 Apr 2002 22:01:06 +0000 Subject: [PATCH] - Allow resetting the module global last_error too. --- ext/sockets/sockets.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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; } -- 2.50.1