You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cli_set_process_title('uqudu-coroutine-master');
\swoole\coroutine::set(self::COROUTINE_CONF);
$http = new \swoole\http\server('127.0.0.1',9501,SWOOLE_PROCESS,SWOOLE_SOCK_TCP);
$http->on('request',function (\swoole\http\request $request,\swoole\http\response $response){
$a1 = go(function () {
file_put_contents('/tmp/a.txt',22222);
});
$redis = new \Swoole\Coroutine\Redis();
$redis->connect('redis.service', 6401);
$authRes = true;
$data = '';
if ($redis->connected && $authRes) {
$val = $redis->set('key',2222);
$data = $redis->get('key');
}
$response->end($data);
$this->log('msg get '.$data.'[is_connect]'.$redis->connected . '[auth]'.(string)$authRes);
});
phpredis扩展,操作结果如下:
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
应该是没有处理好redis的错误,造成崩溃。
What did you expect to see?
期望的结果是什么?
简单的redis操作,可以正常的写入到Redis中
What did you see instead?
实际运行的结果是什么?
swoole被卡住很久,然后发生coredump
coredump 如下:
#0 0x00007f250c9d9518 in sdslen (s=0x2064657473657571 <Address 0x2064657473657571 out of bounds>)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/sds.h:87 #1 0x00007f250c9da492 in sdscatlen (s=0x2064657473657571 <Address 0x2064657473657571 out of bounds>, t=0x1ad1c23, len=22)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/sds.c:380 #2 0x00007f250c9d652d in __redisAppendCommand (c=0x1acd4e0, cmd=0x1ad1c23 "*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n", len=22)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:900 #3 0x00007f250c9d6788 in redisAppendCommandArgv (c=0x1acd4e0, argc=2, argv=0x7f250a5f0ea0, argvlen=0x7f250a5f0e90)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:961 #4 0x00007f250c9d6922 in redisCommandArgv (c=0x1acd4e0, argc=2, argv=0x7f250a5f0ea0, argvlen=0x7f250a5f0e90)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:1007 #5 0x00007f250c9871f5 in redis_request (redis=redis@entry=0x7f250ef1a850, argc=argc@entry=2, argv=argv@entry=0x7f250a5f0ea0,
argvlen=argvlen@entry=0x7f250a5f0e90, return_value=return_value@entry=0x7f2509800200) at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:926 #6 0x00007f250c9896c9 in sw_redis_command_key (cmd_len=3, cmd=0x7f250c9f70e2 "GET", return_value=0x7f2509800200, execute_data=0x7f25098002b0)
at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:1047 #7 zim_swoole_redis_coro_get (execute_data=0x7f25098002b0, return_value=0x7f2509800200) at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:1997
What version of Swoole are you using (php --ri swoole)?
你的版本? 贴出 php --ri swoole 所打印的内容
swoole
swoole support => enabled
Version => 4.2.8
Author => Swoole Group[email: [email protected]]
coroutine => enabled
debug => enabled
trace_log => enabled
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
http2 => 1.26.0
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
mysqlnd => enabled
async_redis => enabled
Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
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
What is your machine environment used (including the version of kernel & php & gcc)?
coredump 如下:
#0 0x00007f250c9d9518 in sdslen (s=0x2064657473657571 <Address 0x2064657473657571 out of bounds>)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/sds.h:87
#1 0x00007f250c9da492 in sdscatlen (s=0x2064657473657571 <Address 0x2064657473657571 out of bounds>, t=0x1ad1c23, len=22)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/sds.c:380
#2 0x00007f250c9d652d in __redisAppendCommand (c=0x1acd4e0, cmd=0x1ad1c23 "*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n", len=22)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:900
#3 0x00007f250c9d6788 in redisAppendCommandArgv (c=0x1acd4e0, argc=2, argv=0x7f250a5f0ea0, argvlen=0x7f250a5f0e90)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:961
#4 0x00007f250c9d6922 in redisCommandArgv (c=0x1acd4e0, argc=2, argv=0x7f250a5f0ea0, argvlen=0x7f250a5f0e90)
at /home/package/swoole-src-4.2.8/thirdparty/hiredis/hiredis.c:1007
#5 0x00007f250c9871f5 in redis_request (redis=redis@entry=0x7f250ef1a850, argc=argc@entry=2, argv=argv@entry=0x7f250a5f0ea0,
argvlen=argvlen@entry=0x7f250a5f0e90, return_value=return_value@entry=0x7f2509800200) at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:926
#6 0x00007f250c9896c9 in sw_redis_command_key (cmd_len=3, cmd=0x7f250c9f70e2 "GET", return_value=0x7f2509800200, execute_data=0x7f25098002b0)
at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:1047
#7 zim_swoole_redis_coro_get (execute_data=0x7f25098002b0, return_value=0x7f2509800200) at /home/package/swoole-src-4.2.8/swoole_redis_coro.cc:1997
php --ri swoole
)?swoole
Linux php7.2 3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
PHP 7.2.10 (cli) (built: Sep 29 2018 22:29:42) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC)
The text was updated successfully, but these errors were encountered: