Skip to content

Commit 6c000f9

Browse files
committed
#32: + Fix behavior handle_exception_and_errno
1 parent 063ca0c commit 6c000f9

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

main/network_async.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,20 @@ static zend_always_inline void handle_exception_and_errno(void)
265265
zend_class_entry *default_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_DEFAULT);
266266
zend_class_entry *cancellation_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION);
267267
zend_class_entry *timeout_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_TIMEOUT);
268+
zend_class_entry *io_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_INPUT_OUTPUT);
268269

269270
if (instanceof_function(error->ce, cancellation_ce)) {
270271
errno = ECANCELED;
271272
} else if (error->ce == timeout_ce) {
272273
errno = ETIMEDOUT;
273274
should_throw = false;
274-
} else if (instanceof_function(error->ce, default_ce)) {
275-
errno = EINTR;
275+
} else if (instanceof_function(error->ce, default_ce)
276+
|| instanceof_function(error->ce, io_ce)) {
277+
errno = EBADF;
276278
should_throw = false;
277279
as_warning = true;
278280
} else {
279-
errno = EINTR;
281+
errno = EBADF;
280282
}
281283

282284
if (false == should_throw) {
@@ -285,13 +287,13 @@ static zend_always_inline void handle_exception_and_errno(void)
285287

286288
if (as_warning) {
287289
zend_exception_error(error, E_WARNING);
290+
} else {
291+
OBJ_RELEASE(error);
288292
}
289-
290-
OBJ_RELEASE(error);
291293
}
292294

293295
} else {
294-
errno = EINTR;
296+
errno = EBADF;
295297
}
296298
}
297299

@@ -665,21 +667,23 @@ static zend_always_inline void dns_handle_exception_and_errno(void)
665667
zend_class_entry *cancellation_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_CANCELLATION);
666668
zend_class_entry *timeout_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_TIMEOUT);
667669
zend_class_entry *dns_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_DNS);
670+
zend_class_entry *io_ce = ZEND_ASYNC_GET_EXCEPTION_CE(ZEND_ASYNC_EXCEPTION_INPUT_OUTPUT);
668671

669672
if (instanceof_function(error->ce, cancellation_ce)) {
670673
errno = ECANCELED;
671674
} else if (error->ce == timeout_ce) {
672675
errno = ETIMEDOUT;
673676
should_throw = false;
674677
} else if (error->ce == dns_ce) {
675-
errno = EINTR;
678+
errno = EBADF;
676679
should_throw = false;
677-
} else if (instanceof_function(error->ce, default_ce)) {
678-
errno = EINTR;
680+
} else if (instanceof_function(error->ce, default_ce)
681+
|| instanceof_function(error->ce, io_ce)) {
682+
errno = EBADF;
679683
should_throw = false;
680684
as_warning = true;
681685
} else {
682-
errno = EINTR;
686+
errno = EBADF;
683687
}
684688

685689
if (false == should_throw) {
@@ -694,7 +698,7 @@ static zend_always_inline void dns_handle_exception_and_errno(void)
694698
}
695699

696700
} else {
697-
errno = EINTR;
701+
errno = EBADF;
698702
}
699703
}
700704

0 commit comments

Comments
 (0)