{"action":"created","issue":{"url":"https://api.github.com/repos/swoole/framework/issues/110","repository_url":"https://api.github.com/repos/swoole/framework","labels_url":"https://api.github.com/repos/swoole/framework/issues/110/labels{/name}","comments_url":"https://api.github.com/repos/swoole/framework/issues/110/comments","events_url":"https://api.github.com/repos/swoole/framework/issues/110/events","html_url":"https://github.com/swoole/framework/issues/110","id":130615376,"number":110,"title":"redis重连auth错误","user":{"login":"kinkk","id":7188412,"avatar_url":"https://avatars.githubusercontent.com/u/7188412?v=3","gravatar_id":"","url":"https://api.github.com/users/kinkk","html_url":"https://github.com/kinkk","followers_url":"https://api.github.com/users/kinkk/followers","following_url":"https://api.github.com/users/kinkk/following{/other_user}","gists_url":"https://api.github.com/users/kinkk/gists{/gist_id}","starred_url":"https://api.github.com/users/kinkk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kinkk/subscriptions","organizations_url":"https://api.github.com/users/kinkk/orgs","repos_url":"https://api.github.com/users/kinkk/repos","events_url":"https://api.github.com/users/kinkk/events{/privacy}","received_events_url":"https://api.github.com/users/kinkk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-02-02T08:46:40Z","updated_at":"2016-12-13T09:32:00Z","closed_at":"2016-12-01T09:46:22Z","body":"初始化redis是先connect后auth，但重连时只是connect，并没有auth验证。\n\n```\n    function connect()\n    {\n        try\n        {\n            if ($this->_redis)\n            {\n                unset($this->_redis);\n            }\n            $this->_redis = new \\Redis();\n            if ($this->config['pconnect'])\n            {\n                return $this->_redis->pconnect($this->config['host'], $this->config['port'], $this->config['timeout']);\n            }\n            else\n            {\n                return $this->_redis->connect($this->config['host'], $this->config['port'], $this->config['timeout']);\n            }\n        }\n        catch (\\RedisException $e)\n        {\n            \\Swoole::$php->log->error(__CLASS__ . \" Swoole Redis Exception\" . var_export($e, 1));\n            return false;\n        }\n    }\n    function __call($method, $args = array())\n    {\n        $reConnect = false;\n        while (1)\n        {\n            try\n            {\n                $result = call_user_func_array(array($this->_redis, $method), $args);\n            }\n            catch (\\RedisException $e)\n            {\n                //已重连过，仍然报错\n                if ($reConnect)\n                {\n                    throw $e;\n                }\n                \\Swoole::$php->log->error(__CLASS__ . \" [\" . posix_getpid() . \"] Swoole Redis[{$this->config['host']}:{$this->config['port']}]\n                 Exception(Msg=\" . $e->getMessage() . \", Code=\" . $e->getCode() . \"), Redis->{$method}, Params=\" . var_export($args, 1));\n                $this->_redis->close();\n                // 重连只是connect，如需验证就会出现错误\n                $this->connect();\n                // ---------------------------\n                $reConnect = true;\n                continue;\n            }\n            return $result;\n        }\n        //不可能到这里\n        return false;\n    }\n```\n"},"comment":{"url":"https://api.github.com/repos/swoole/framework/issues/comments/266689744","html_url":"https://github.com/swoole/framework/issues/110#issuecomment-266689744","issue_url":"https://api.github.com/repos/swoole/framework/issues/110","id":266689744,"user":{"login":"pandabajie","id":8722511,"avatar_url":"https://avatars.githubusercontent.com/u/8722511?v=3","gravatar_id":"","url":"https://api.github.com/users/pandabajie","html_url":"https://github.com/pandabajie","followers_url":"https://api.github.com/users/pandabajie/followers","following_url":"https://api.github.com/users/pandabajie/following{/other_user}","gists_url":"https://api.github.com/users/pandabajie/gists{/gist_id}","starred_url":"https://api.github.com/users/pandabajie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pandabajie/subscriptions","organizations_url":"https://api.github.com/users/pandabajie/orgs","repos_url":"https://api.github.com/users/pandabajie/repos","events_url":"https://api.github.com/users/pandabajie/events{/privacy}","received_events_url":"https://api.github.com/users/pandabajie/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T09:32:00Z","updated_at":"2016-12-13T09:32:00Z","body":"在哪里可以看到改了哪个文件？"}}
{"actor":{"display_login":"pandabajie"}}