swoole / swoole-src

🚀 Coroutine-based concurrency library for PHP
https://www.swoole.com
Apache License 2.0
18.44k stars 3.16k forks source link

协程Redis客户端调用失败时,会影响后面的返回值 #2029

Closed limingxinleo closed 6 years ago

limingxinleo commented 6 years ago

Please answer these questions before submitting your issue. Thanks!

  1. What did you do? If possible, provide a simple script for reproducing the error.

        go(function () {
            $key = 'test:string';
            $redis = new \Swoole\Coroutine\Redis(['timeout' => 3]);
            $result = $redis->connect('127.0.0.1', '6379', 0);
            $res = $redis->set($key, 'val');
            var_dump($res);
            $res = $redis->hIncrBy($key, 'a', 1);
            $res = $redis->set($key . '1', 'val2');
            var_dump($res);
        });
  2. What did you expect to see?

    bool(true)
    bool(true)
  3. What did you see instead?

    
    bool(true)
    PHP Notice:  Undefined variable: res in /Users/limx/Applications/php/swoft/swoft-component/src/redis/test/Cases/PoolTest.php on line 115

Notice: Undefined variable: res in /Users/limx/Applications/php/swoft/swoft-component/src/redis/test/Cases/PoolTest.php on line 115 NULL



4. What version of Swoole are you using (show your `php --ri swoole`)?

swoole

swoole support => enabled
Version => 4.0.4
Author => Swoole Group[email: team@swoole.com]
coroutine => enabled
kqueue => enabled
rwlock => enabled
async redis client => enabled
async http/websocket client => enabled
openssl => enabled
http2 => enabled
pcre => enabled
zlib => enabled
mysqlnd => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => On => On
swoole.use_shortname => On => On
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

5. What is your machine environment used (including version of kernel & php & gcc) ?
twose commented 6 years ago

已修复, 由于上次错误值未清除进入了错误的逻辑分支.

limingxinleo commented 6 years ago

这个bug是在最新的版本里 修改了么??

twose commented 6 years ago

是的,master分支

limingxinleo commented 6 years ago

@twose 最新版本的swoole如果不开启协程runtime,和4.0.4版本差别大么?

limingxinleo commented 6 years ago

新版本什么时候可以发布?

twose commented 6 years ago

runtime只是替换了PHP原先的IO函数, 没有使用的话没有任何影响, 无特殊原因最好使用最新版

limingxinleo commented 6 years ago

@twose 那下个版本估计什么时候可以发布呢