]> granicus.if.org Git - php/commitdiff
- Allow resetting the module global last_error too.
authorMarkus Fischer <mfischer@php.net>
Tue, 30 Apr 2002 22:01:06 +0000 (22:01 +0000)
committerMarkus Fischer <mfischer@php.net>
Tue, 30 Apr 2002 22:01:06 +0000 (22:01 +0000)
ext/sockets/sockets.c

index b1008f1bae62ef735c09e6495f4cb4b7d4f97b81..37caf6026a73901ff6262d51ba11ebbd9165d763 100644 (file)
@@ -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;
 }