This repository has been archived by the owner on Sep 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Segmentation fault when run in distinct coroutine context #55
Comments
Hi, may I have a feedback? I have created a pull request that fix the bug. I think that run this extension in distinct coroutine contexts can be useful in unit testing and other things! |
@sergiotabanelli hi! I think you shouldn't use Coroutine objects in this manner. Coroutine::run - creates one global app event loop, application may have only one event loop at once. Your app arch should be like: php main.php
// main.php content
<?php
// create event loop
\Co\run(function() {
// you're inside event loop now
$db = new \Swoole\Coroutine\PostgreSQL();
$db->connect("host=127.0.0.1 port=5432 dbname=wireskel user=wireskel password=xxxxxx");
\Swoole\Coroutine::create(function () use ($db) {
$res = $db->query('SELECT * from _cred_user');
});
// Wait here for some events: e.g. coroutine exit or termination signal
// disconnect from Postgres while you're in event loop
unset($db);
});
exit(0); |
@codercms thanks for Your answer, but I have to disagree.
|
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The following code produce a segmentation fault. The problem is that the registration of coroutine callbacks were done only in the connect method. I have a fork that fix this bug. I can do a pull request if needed.
The text was updated successfully, but these errors were encountered: