Skip to content

Conversation

@enumag
Copy link
Contributor

@enumag enumag commented Sep 17, 2021

Closes #59

You removed the call to eio_init() here, however this completely breaks the EioDriver. When I try to use it, the script will hang until I press enter and then continues. Calling eio_init() fixes the problem.

What's more you claim that it was deprecated in eio v2 and removed in eio v3. However I can confirm that it still exists in eio 3.0.0RC2 and even this version breaks when it isn't called.

In my opinion we should still call it but perhaps wrap it with function exists. Hopefully if eio does remove it in the future the bug should be fixed.

@enumag
Copy link
Contributor Author

enumag commented Sep 17, 2021

If you wanna try it yourself you can easily reproduce the issue like this.

Create Dockerfile with this content:

ARG PHP_VERSION=7.4

FROM php:${PHP_VERSION}

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

WORKDIR /usr/app

RUN apt-get update && \
    apt-get install -qq git unzip ${PHPIZE_DEPS} && \
    pecl install eio && \
    docker-php-ext-enable eio && \
    git clone https://github.com/amphp/file.git . && \
    composer install --ignore-platform-reqs

RUN echo '<?php\n\
use Amp\File\Driver\EioDriver;\n\
use Amp\Loop;\n\
require __DIR__ . "/vendor/autoload.php";\n\
Loop::run(\n\
    function (): Generator {\n\
        $driver = new EioDriver(Loop::get());\n\
        $list = yield $driver->listFiles(__DIR__);\n\
        echo count($list);\n\
    }\n\
);\n\
' >> ./test.php

Then run:

docker build . --tag eio-bug
docker run -it eio-bug sh -c "php test.php"

The script will hang unless you add the eio_init() call but it will continue if you press enter.

Running it like this instead also fixes it (even without eio_init()):

docker run -it eio-bug sh -c "echo '\n' | php test.php"

@trowski
Copy link
Member

trowski commented Sep 20, 2021

eio_init is in fact removed in the PHP 8 version of the extension. The function is deprecated, but still remains in the PHP 7 version. The function_exist guard seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

EioDriver not working

2 participants