Skip to content

Commit cc224f7

Browse files
committed
#32: * fix error code issue in network
1 parent e671b51 commit cc224f7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

main/network.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
407407
while (true) {
408408
n = php_pollfd_for(sockfd, events, timeout ? &working_timeout : NULL);
409409
if (n < 0) {
410+
#ifdef PHP_ASYNC_API
411+
// We need to update the error information because we called some functions before this.
412+
error = errno;
413+
#endif
410414
if (errno == EINTR) {
411415
#ifdef HAVE_GETTIMEOFDAY
412416
if (timeout) {
@@ -440,7 +444,6 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
440444

441445
ok:
442446
if (!asynchronous) {
443-
error = errno;
444447
/* back to blocking mode */
445448
RESTORE_SOCKET_BLOCKING_MODE(sockfd, orig_flags);
446449
}

0 commit comments

Comments
 (0)