{"action":"created","issue":{"url":"https://api.github.com/repos/krakjoe/pthreads/issues/472","labels_url":"https://api.github.com/repos/krakjoe/pthreads/issues/472/labels{/name}","comments_url":"https://api.github.com/repos/krakjoe/pthreads/issues/472/comments","events_url":"https://api.github.com/repos/krakjoe/pthreads/issues/472/events","html_url":"https://github.com/krakjoe/pthreads/issues/472","id":101091459,"number":472,"title":"core dump while \"stack\" a conection in a worker","user":{"login":"CriztianiX","id":1068190,"avatar_url":"https://avatars.githubusercontent.com/u/1068190?v=3","gravatar_id":"","url":"https://api.github.com/users/CriztianiX","html_url":"https://github.com/CriztianiX","followers_url":"https://api.github.com/users/CriztianiX/followers","following_url":"https://api.github.com/users/CriztianiX/following{/other_user}","gists_url":"https://api.github.com/users/CriztianiX/gists{/gist_id}","starred_url":"https://api.github.com/users/CriztianiX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CriztianiX/subscriptions","organizations_url":"https://api.github.com/users/CriztianiX/orgs","repos_url":"https://api.github.com/users/CriztianiX/repos","events_url":"https://api.github.com/users/CriztianiX/events{/privacy}","received_events_url":"https://api.github.com/users/CriztianiX/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-14T19:57:13Z","updated_at":"2015-08-16T16:11:53Z","closed_at":null,"body":"Trying to create a conection in the worker and use it in the thread i get:\r\nmundo@mundo-laptop:~/workspace/rds$ php Main.php \r\nstring(26) \"instance created in worker\"\r\nstring(26) \"instance created in worker\"\r\nstring(26) \"instance created in worker\"\r\nstring(26) \"instance created in worker\"\r\nViolación de segmento (`core' generado)\r\n\r\nThe worker:\r\n```php\r\n<?php\r\nnamespace Rds {\r\n    class Worker extends \\Worker {\r\n        protected $loader;\r\n        protected $couchbase;\r\n\r\n        public function __construct($loader, $couchbase)\r\n        {\r\n            $this->loader = $loader;\r\n            $this->couchbase = $couchbase->connection();\r\n        }\r\n        public function run()\r\n        {\r\n          require_once($this->loader);\r\n        }\r\n\r\n        public function start()\r\n        {\r\n          return parent::start(PTHREADS_INHERIT_NONE);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe thread part using the conection created in the worker\r\n```php\r\nnamespace Rds {\r\n  class Task extends \\Collectable {\r\n    public $page;\r\n\r\n    public function __construct($page) {\r\n      $this->page = $page;\r\n    }\r\n    public function run()\r\n    {\r\n      $boot = Bootstrap::getInstace();\r\n      $rows = $boot->getPage($this->page);\r\n\r\n      $bucket = $this->worker->couchbase;\r\n      ....\r\n}\r\n```\r\n\r\nThe stackable conection\r\n```php\r\nnamespace Rds {\r\n    class CouchbaseConnectionStack extends \\Stackable  {\r\n        public function connection()\r\n        {\r\n          var_dump(\"instance created in worker\");\r\n          $connectionString = \"http://127.0.0.1\";\r\n          $bucket = \"default\";\r\n          $cluster = new \\CouchbaseCluster($connectionString);\r\n          return $cluster->openBucket($bucket);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nThe main app:\r\n```php\r\n      $stacks = [ \"Vendor/autoload.php\", new \\Rds\\CouchbaseConnectionStack ];\r\n        $pool = new \\Pool((int)$numWorkers, \\Rds\\Worker::class, $stacks);\r\n        for ($page=1; $page <= $totalPages ; $page++) {\r\n          $task = new \\Rds\\Task($page);\r\n          $pool->submit($task);\r\n        }\r\n        $pool->shutdown();\r\n        $pool->collect(function($work){\r\n          return $work->isGarbage();\r\n        });\r\n```"},"comment":{"url":"https://api.github.com/repos/krakjoe/pthreads/issues/comments/131577591","html_url":"https://github.com/krakjoe/pthreads/issues/472#issuecomment-131577591","issue_url":"https://api.github.com/repos/krakjoe/pthreads/issues/472","id":131577591,"user":{"login":"CriztianiX","id":1068190,"avatar_url":"https://avatars.githubusercontent.com/u/1068190?v=3","gravatar_id":"","url":"https://api.github.com/users/CriztianiX","html_url":"https://github.com/CriztianiX","followers_url":"https://api.github.com/users/CriztianiX/followers","following_url":"https://api.github.com/users/CriztianiX/following{/other_user}","gists_url":"https://api.github.com/users/CriztianiX/gists{/gist_id}","starred_url":"https://api.github.com/users/CriztianiX/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CriztianiX/subscriptions","organizations_url":"https://api.github.com/users/CriztianiX/orgs","repos_url":"https://api.github.com/users/CriztianiX/repos","events_url":"https://api.github.com/users/CriztianiX/events{/privacy}","received_events_url":"https://api.github.com/users/CriztianiX/received_events","type":"User","site_admin":false},"created_at":"2015-08-16T16:11:53Z","updated_at":"2015-08-16T16:11:53Z","body":"@cottton Following the example, i still get \"core dumped\"\r\n\r\nI've pushed the full implmenetation in this branch\r\nhttps://github.com/CriztianiX/couchbase-etl/tree/reuse_couchbase_connection\r\n\r\nThe files are in https://github.com/CriztianiX/couchbase-etl/tree/reuse_couchbase_connection/Vendor/criztianix/rds/lib\r\nis it an error in the implementation?\r\nThanks!"}}