{"action":"opened","issue":{"url":"https://api.github.com/repos/swoole/swoole-src/issues/875","repository_url":"https://api.github.com/repos/swoole/swoole-src","labels_url":"https://api.github.com/repos/swoole/swoole-src/issues/875/labels{/name}","comments_url":"https://api.github.com/repos/swoole/swoole-src/issues/875/comments","events_url":"https://api.github.com/repos/swoole/swoole-src/issues/875/events","html_url":"https://github.com/swoole/swoole-src/issues/875","id":182165414,"number":875,"title":"swoole多端口混合协议 监听存在内存泄漏问题","user":{"login":"badxpgy","id":11013665,"avatar_url":"https://avatars.githubusercontent.com/u/11013665?v=3","gravatar_id":"","url":"https://api.github.com/users/badxpgy","html_url":"https://github.com/badxpgy","followers_url":"https://api.github.com/users/badxpgy/followers","following_url":"https://api.github.com/users/badxpgy/following{/other_user}","gists_url":"https://api.github.com/users/badxpgy/gists{/gist_id}","starred_url":"https://api.github.com/users/badxpgy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/badxpgy/subscriptions","organizations_url":"https://api.github.com/users/badxpgy/orgs","repos_url":"https://api.github.com/users/badxpgy/repos","events_url":"https://api.github.com/users/badxpgy/events{/privacy}","received_events_url":"https://api.github.com/users/badxpgy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-11T03:32:13Z","updated_at":"2016-10-11T03:32:13Z","closed_at":null,"body":"版本：swoole_1.8.12/php7\r\n服务端代码：\r\n<?php\r\nerror_reporting(E_ALL);\r\n$server = new swoole_server(\"0.0.0.0\", 9501, SWOOLE_PROCESS, SWOOLE_SOCK_TCP);\r\n$server->set([\r\n\t'worker_num' => 3,\r\n\t'dispatch_mode' => 2,\r\n\t'open_length_check' => true,\r\n\t'package_length_type' => 'n',\r\n\t'package_length_offset' => 0,\r\n\t'package_body_offset' => 2\r\n]);\r\n$server->on('connect', function ($serv, $fd) {});\r\n$server->on('receive', function ($serv, $fd, $from_id, $data) {\r\n\t$serv->send($fd, $data);\r\n});\r\n$server->on('close', function ($serv, $fd) {});\r\n$nwport = $server->listen(\"0.0.0.0\", 9502, SWOOLE_SOCK_TCP);\r\n$nwport->set([\r\n\t'open_length_check' => true,\r\n\t'package_length_type' => 'N',\r\n\t'package_length_offset' => 0,\r\n\t'package_body_offset' => 4\r\n]);\r\n$nwport->on('receive', function ($serv, $fd, $from_id, $data) {\r\n\t$serv->send($fd, $data);\r\n});\r\n$server->start();\r\n\r\n测试重现代码：\r\n<?php\r\n$serv = new swoole_server(\"0.0.0.0\", 9503, SWOOLE_BASE, SWOOLE_SOCK_TCP);\r\n$serv->set(array('worker_num' => 200));\r\n$serv->on('receive', function ($serv, $fd, $from_id, $data) {});\r\n$serv->on('close', function ($serv, $fd) {});\r\n$serv->on('connect', function ($serv, $fd) {});\r\n$serv->on('WorkerStart', function ($serv, $worker_id) {\r\n\t$serv->tick(500, function() {\r\n\t\t$send_buff=  pack('n',500).  str_repeat('a', 500);\t\r\n\t\tdoTest(\"127.0.0.1\", 9501,$send_buff);\r\n\t\t$send_buff=  pack('N',500).  str_repeat('a', 500);\t\r\n\t\tdoTest(\"127.0.0.1\", 9502,$send_buff);\r\n\t});\r\n});\r\n$serv->start();\r\n\r\nfunction doTest($ip, $port,$send_buff) {\r\n\t$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);\r\n\tsocket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);\r\n\t@socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, array(\"sec\" => 1, \"usec\" => 0));\r\n\t@socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array(\"sec\" => 1, \"usec\" => 0));\r\n\t@socket_connect($socket, $ip, $port);\r\n\t@socket_write($socket, $send_buff, strlen($send_buff));\t\r\n\t$bufferLen = @socket_recv($socket, $buffer, 1024, MSG_WAITALL);\r\n\tif ($buffer != $send_buff) {\r\n\t\techo \"error2:\" . strlen($send_buff) . '-' . $bufferLen . ',' . strlen($buffer) . PHP_EOL;\r\n\t}\r\n\t@socket_close($socket);\r\n}\r\n"}}
{"actor":{"display_login":"badxpgy"}}