Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to destruct the socket #142

Closed
joelwurtz opened this issue Oct 15, 2017 · 3 comments
Closed

Error when trying to destruct the socket #142

joelwurtz opened this issue Oct 15, 2017 · 3 comments
Assignees
Labels

Comments

@joelwurtz
Copy link

It was happening randomly and i made this error "consistent" when it tries to end the script with last response resolved in the "same time":

PHP Fatal error:  Uncaught Error: Unknown socket: 0 in /home/brouznouf/Workspace/asynit/vendor/amphp/socket/lib/BasicSocketPool.php:116
Stack trace:
#0 /home/brouznouf/Workspace/asynit/vendor/amphp/artax/lib/HttpSocketPool.php(104): Amp\Socket\BasicSocketPool->clear(Object(Amp\Socket\ClientSocket))
#1 /home/brouznouf/Workspace/asynit/vendor/amphp/artax/lib/DefaultClient.php(706): Amp\Artax\HttpSocketPool->clear(Object(Amp\Socket\ClientSocket))
#2 [internal function]: class@anonymous->__destruct()
#3 {main}
  thrown in /home/brouznouf/Workspace/asynit/vendor/amphp/socket/lib/BasicSocketPool.php on line 116
PHP Stack trace:
PHP   1. {main}() /home/brouznouf/Workspace/asynit/bin/asynit:0
PHP   2. Asynit\Application->run() /home/brouznouf/Workspace/asynit/bin/asynit:14

To reproduce it you can checkout the "feature/amp" branch of this lib https://github.com/jolicode/asynit
do the composer install and then launch the test with this command : php bin/asynit example

@kelunik kelunik self-assigned this Oct 15, 2017
@kelunik kelunik added the bug label Oct 15, 2017
@bwoebi
Copy link
Member

bwoebi commented Oct 15, 2017

I think we should just have checked against the socket id being 0 within amphp/socket @kelunik Catching \Error looks like quite an unclean solution. A resource id will always be positive. If it is 0 the resource will have been destroyed.

@kelunik
Copy link
Member

kelunik commented Oct 16, 2017

@bwoebi The socket should never be destroyed at that point unless it's the final GC round cleaning up everything. See the amphp/byte-stream issue I posted.

@bwoebi
Copy link
Member

bwoebi commented Oct 17, 2017

Okay, you're right. But still, the fix here is not the proper one. It's now fixed in byte-stream.

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

No branches or pull requests

3 participants