Skip to content

Commit f593704

Browse files
committed
php#53: A more proper error handling has been added. If an exception occurs, php_network_accept_incoming outputs its message as a warning.
1 parent 558a213 commit f593704

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

main/network.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,17 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
808808
*error_code = error;
809809
}
810810
if (error_string) {
811-
*error_string = php_socket_error_str(error);
811+
if(EG(exception)) {
812+
zval rv;
813+
const zval *message =
814+
zend_read_property_ex(EG(exception)->ce, EG(exception), zend_known_strings[ZEND_STR_MESSAGE], 0, &rv);
815+
816+
if (message != NULL && Z_TYPE_P(message) == IS_STRING) {
817+
*error_string = Z_STR_P(message);
818+
}
819+
} else {
820+
*error_string = php_socket_error_str(error);
821+
}
812822
}
813823

814824
return clisock;

0 commit comments

Comments
 (0)