Skip to content

Commit f4ef694

Browse files
committed
poll: fix failed addition
1 parent 68958b5 commit f4ef694

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

ext/standard/poll.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -532,14 +532,13 @@ PHP_METHOD(PollContext, add)
532532

533533
/* Add to poll context */
534534
if (php_poll_add(intern->ctx, (int) fd, (uint32_t) events, watcher) != SUCCESS) {
535-
/* Clean up the partially initialized watcher */
536-
OBJ_RELEASE(&handle->std);
537-
zval_ptr_dtor(&watcher->data);
538-
zval_ptr_dtor(return_value);
539-
ZVAL_NULL(return_value);
540-
541-
zend_throw_exception(
542-
php_poll_exception_class_entry, "Failed to add handle to polling context", 0);
535+
if (php_poll_get_error(intern->ctx) == PHP_POLL_ERR_EXISTS) {
536+
zend_throw_exception(
537+
php_poll_exception_class_entry, "Handle already added", 0);
538+
} else {
539+
zend_throw_exception(
540+
php_poll_exception_class_entry, "Failed to add handle", 0);
541+
}
543542
RETURN_THROWS();
544543
}
545544

ext/standard/tests/poll/poll_stream_add_error_duplicate.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ try {
1616
}
1717
?>
1818
--EXPECT--
19-
ERROR: Stream already added
19+
ERROR: Handle already added

0 commit comments

Comments
 (0)