{"action":"closed","number":401,"pull_request":{"url":"https://api.github.com/repos/swoole/swoole-src/pulls/401","id":51438743,"html_url":"https://github.com/swoole/swoole-src/pull/401","diff_url":"https://github.com/swoole/swoole-src/pull/401.diff","patch_url":"https://github.com/swoole/swoole-src/pull/401.patch","issue_url":"https://api.github.com/repos/swoole/swoole-src/issues/401","number":401,"state":"closed","locked":false,"title":"swoole_client异步模式connect无超时时间问题的处理","user":{"login":"coooold","id":6245836,"avatar_url":"https://avatars.githubusercontent.com/u/6245836?v=3","gravatar_id":"","url":"https://api.github.com/users/coooold","html_url":"https://github.com/coooold","followers_url":"https://api.github.com/users/coooold/followers","following_url":"https://api.github.com/users/coooold/following{/other_user}","gists_url":"https://api.github.com/users/coooold/gists{/gist_id}","starred_url":"https://api.github.com/users/coooold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coooold/subscriptions","organizations_url":"https://api.github.com/users/coooold/orgs","repos_url":"https://api.github.com/users/coooold/repos","events_url":"https://api.github.com/users/coooold/events{/privacy}","received_events_url":"https://api.github.com/users/coooold/received_events","type":"User","site_admin":false},"body":"由于asyc模式的connect没有超时模式，需要使用timer来释放cli，此时active=0，导致内存泄露，因此此处不检测active，只检测socket。特别要注意的是，timer释放cli的时候，务必不能使用引用模式！\"\r\n[master 98ce399] 由于asyc模式的connect没有超时模式，需要使用timer来释放cli，此时active=0，导致内存泄露，因此此处不检测active，只检测socket。特别要注意的是，timer释放cli的时候，不可使用引用模式，否则会导致段错误。\r\n\r\n示例代码：\r\n\r\n\r\n```php\r\n$cli = new \\swoole_client ( SWOOLE_TCP, SWOOLE_SOCK_ASYNC );\r\n\r\n//on ...\r\n\r\n$cli->on ( \"error\", function ($cli) use(&$promise) {\r\n\tTimer::del($cli->sock);\r\n} );\r\n\r\n$ret = $cli->connect ( '192.112.121.122',80 );\r\nif(!$cli->errCode){\r\n\tTimer::add($cli->sock, $this->timeout, function()use($cli, &$promise){\r\n\t\tTimer::del($cli->sock);\r\n\t\t$cli->close();          //这个地方需要使用打过补丁的swoole，这样才能释放掉内存\r\n\t});\r\n}\r\n```","created_at":"2015-11-21T10:37:37Z","updated_at":"2015-11-22T09:07:15Z","closed_at":"2015-11-22T09:07:15Z","merged_at":null,"merge_commit_sha":"1e7df46ef05231f5d827dabba061abcbfa2cd223","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/swoole/swoole-src/pulls/401/commits","review_comments_url":"https://api.github.com/repos/swoole/swoole-src/pulls/401/comments","review_comment_url":"https://api.github.com/repos/swoole/swoole-src/pulls/comments{/number}","comments_url":"https://api.github.com/repos/swoole/swoole-src/issues/401/comments","statuses_url":"https://api.github.com/repos/swoole/swoole-src/statuses/4042aaf8b54ba77066b9a1c015c39529290e11f1","head":{"label":"coooold:master","ref":"master","sha":"4042aaf8b54ba77066b9a1c015c39529290e11f1","user":{"login":"coooold","id":6245836,"avatar_url":"https://avatars.githubusercontent.com/u/6245836?v=3","gravatar_id":"","url":"https://api.github.com/users/coooold","html_url":"https://github.com/coooold","followers_url":"https://api.github.com/users/coooold/followers","following_url":"https://api.github.com/users/coooold/following{/other_user}","gists_url":"https://api.github.com/users/coooold/gists{/gist_id}","starred_url":"https://api.github.com/users/coooold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coooold/subscriptions","organizations_url":"https://api.github.com/users/coooold/orgs","repos_url":"https://api.github.com/users/coooold/repos","events_url":"https://api.github.com/users/coooold/events{/privacy}","received_events_url":"https://api.github.com/users/coooold/received_events","type":"User","site_admin":false},"repo":{"id":46323276,"name":"swoole-src","full_name":"coooold/swoole-src","owner":{"login":"coooold","id":6245836,"avatar_url":"https://avatars.githubusercontent.com/u/6245836?v=3","gravatar_id":"","url":"https://api.github.com/users/coooold","html_url":"https://github.com/coooold","followers_url":"https://api.github.com/users/coooold/followers","following_url":"https://api.github.com/users/coooold/following{/other_user}","gists_url":"https://api.github.com/users/coooold/gists{/gist_id}","starred_url":"https://api.github.com/users/coooold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coooold/subscriptions","organizations_url":"https://api.github.com/users/coooold/orgs","repos_url":"https://api.github.com/users/coooold/repos","events_url":"https://api.github.com/users/coooold/events{/privacy}","received_events_url":"https://api.github.com/users/coooold/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/coooold/swoole-src","description":"Asynchronous & concurrent & distributed networking framework for PHP.","fork":true,"url":"https://api.github.com/repos/coooold/swoole-src","forks_url":"https://api.github.com/repos/coooold/swoole-src/forks","keys_url":"https://api.github.com/repos/coooold/swoole-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/coooold/swoole-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/coooold/swoole-src/teams","hooks_url":"https://api.github.com/repos/coooold/swoole-src/hooks","issue_events_url":"https://api.github.com/repos/coooold/swoole-src/issues/events{/number}","events_url":"https://api.github.com/repos/coooold/swoole-src/events","assignees_url":"https://api.github.com/repos/coooold/swoole-src/assignees{/user}","branches_url":"https://api.github.com/repos/coooold/swoole-src/branches{/branch}","tags_url":"https://api.github.com/repos/coooold/swoole-src/tags","blobs_url":"https://api.github.com/repos/coooold/swoole-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/coooold/swoole-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/coooold/swoole-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/coooold/swoole-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/coooold/swoole-src/statuses/{sha}","languages_url":"https://api.github.com/repos/coooold/swoole-src/languages","stargazers_url":"https://api.github.com/repos/coooold/swoole-src/stargazers","contributors_url":"https://api.github.com/repos/coooold/swoole-src/contributors","subscribers_url":"https://api.github.com/repos/coooold/swoole-src/subscribers","subscription_url":"https://api.github.com/repos/coooold/swoole-src/subscription","commits_url":"https://api.github.com/repos/coooold/swoole-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/coooold/swoole-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/coooold/swoole-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/coooold/swoole-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/coooold/swoole-src/contents/{+path}","compare_url":"https://api.github.com/repos/coooold/swoole-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/coooold/swoole-src/merges","archive_url":"https://api.github.com/repos/coooold/swoole-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/coooold/swoole-src/downloads","issues_url":"https://api.github.com/repos/coooold/swoole-src/issues{/number}","pulls_url":"https://api.github.com/repos/coooold/swoole-src/pulls{/number}","milestones_url":"https://api.github.com/repos/coooold/swoole-src/milestones{/number}","notifications_url":"https://api.github.com/repos/coooold/swoole-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/coooold/swoole-src/labels{/name}","releases_url":"https://api.github.com/repos/coooold/swoole-src/releases{/id}","created_at":"2015-11-17T04:31:43Z","updated_at":"2015-11-17T04:31:49Z","pushed_at":"2015-11-22T09:04:56Z","git_url":"git://github.com/coooold/swoole-src.git","ssh_url":"git@github.com:coooold/swoole-src.git","clone_url":"https://github.com/coooold/swoole-src.git","svn_url":"https://github.com/coooold/swoole-src","homepage":"www.swoole.com","size":10262,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"swoole:master","ref":"master","sha":"3e829316f2975779e9652079ff477e3ba7b2d762","user":{"login":"swoole","id":8121270,"avatar_url":"https://avatars.githubusercontent.com/u/8121270?v=3","gravatar_id":"","url":"https://api.github.com/users/swoole","html_url":"https://github.com/swoole","followers_url":"https://api.github.com/users/swoole/followers","following_url":"https://api.github.com/users/swoole/following{/other_user}","gists_url":"https://api.github.com/users/swoole/gists{/gist_id}","starred_url":"https://api.github.com/users/swoole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swoole/subscriptions","organizations_url":"https://api.github.com/users/swoole/orgs","repos_url":"https://api.github.com/users/swoole/repos","events_url":"https://api.github.com/users/swoole/events{/privacy}","received_events_url":"https://api.github.com/users/swoole/received_events","type":"Organization","site_admin":false},"repo":{"id":5133949,"name":"swoole-src","full_name":"swoole/swoole-src","owner":{"login":"swoole","id":8121270,"avatar_url":"https://avatars.githubusercontent.com/u/8121270?v=3","gravatar_id":"","url":"https://api.github.com/users/swoole","html_url":"https://github.com/swoole","followers_url":"https://api.github.com/users/swoole/followers","following_url":"https://api.github.com/users/swoole/following{/other_user}","gists_url":"https://api.github.com/users/swoole/gists{/gist_id}","starred_url":"https://api.github.com/users/swoole/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swoole/subscriptions","organizations_url":"https://api.github.com/users/swoole/orgs","repos_url":"https://api.github.com/users/swoole/repos","events_url":"https://api.github.com/users/swoole/events{/privacy}","received_events_url":"https://api.github.com/users/swoole/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/swoole/swoole-src","description":"Asynchronous & concurrent & distributed networking framework for PHP.","fork":false,"url":"https://api.github.com/repos/swoole/swoole-src","forks_url":"https://api.github.com/repos/swoole/swoole-src/forks","keys_url":"https://api.github.com/repos/swoole/swoole-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/swoole/swoole-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/swoole/swoole-src/teams","hooks_url":"https://api.github.com/repos/swoole/swoole-src/hooks","issue_events_url":"https://api.github.com/repos/swoole/swoole-src/issues/events{/number}","events_url":"https://api.github.com/repos/swoole/swoole-src/events","assignees_url":"https://api.github.com/repos/swoole/swoole-src/assignees{/user}","branches_url":"https://api.github.com/repos/swoole/swoole-src/branches{/branch}","tags_url":"https://api.github.com/repos/swoole/swoole-src/tags","blobs_url":"https://api.github.com/repos/swoole/swoole-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/swoole/swoole-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/swoole/swoole-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/swoole/swoole-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/swoole/swoole-src/statuses/{sha}","languages_url":"https://api.github.com/repos/swoole/swoole-src/languages","stargazers_url":"https://api.github.com/repos/swoole/swoole-src/stargazers","contributors_url":"https://api.github.com/repos/swoole/swoole-src/contributors","subscribers_url":"https://api.github.com/repos/swoole/swoole-src/subscribers","subscription_url":"https://api.github.com/repos/swoole/swoole-src/subscription","commits_url":"https://api.github.com/repos/swoole/swoole-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/swoole/swoole-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/swoole/swoole-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/swoole/swoole-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/swoole/swoole-src/contents/{+path}","compare_url":"https://api.github.com/repos/swoole/swoole-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/swoole/swoole-src/merges","archive_url":"https://api.github.com/repos/swoole/swoole-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/swoole/swoole-src/downloads","issues_url":"https://api.github.com/repos/swoole/swoole-src/issues{/number}","pulls_url":"https://api.github.com/repos/swoole/swoole-src/pulls{/number}","milestones_url":"https://api.github.com/repos/swoole/swoole-src/milestones{/number}","notifications_url":"https://api.github.com/repos/swoole/swoole-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/swoole/swoole-src/labels{/name}","releases_url":"https://api.github.com/repos/swoole/swoole-src/releases{/id}","created_at":"2012-07-21T13:49:59Z","updated_at":"2015-11-21T00:38:03Z","pushed_at":"2015-11-22T09:04:58Z","git_url":"git://github.com/swoole/swoole-src.git","ssh_url":"git@github.com:swoole/swoole-src.git","clone_url":"https://github.com/swoole/swoole-src.git","svn_url":"https://github.com/swoole/swoole-src","homepage":"www.swoole.com","size":11263,"stargazers_count":2614,"watchers_count":2614,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":883,"mirror_url":null,"open_issues_count":56,"forks":883,"open_issues":56,"watchers":2614,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/swoole/swoole-src/pulls/401"},"html":{"href":"https://github.com/swoole/swoole-src/pull/401"},"issue":{"href":"https://api.github.com/repos/swoole/swoole-src/issues/401"},"comments":{"href":"https://api.github.com/repos/swoole/swoole-src/issues/401/comments"},"review_comments":{"href":"https://api.github.com/repos/swoole/swoole-src/pulls/401/comments"},"review_comment":{"href":"https://api.github.com/repos/swoole/swoole-src/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/swoole/swoole-src/pulls/401/commits"},"statuses":{"href":"https://api.github.com/repos/swoole/swoole-src/statuses/4042aaf8b54ba77066b9a1c015c39529290e11f1"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":2,"deletions":1,"changed_files":1}}