Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websocket下用定时器发送断错误 #280

Closed
merlinyang521 opened this issue Jun 8, 2015 · 5 comments
Closed

websocket下用定时器发送断错误 #280

merlinyang521 opened this issue Jun 8, 2015 · 5 comments

Comments

@merlinyang521
Copy link

websocket下用定时器发送断错误

(gdb) bt
#0 zif_swoole_server_addtimer (ht=1, return_value=0x7fd3c1c76f08, return_value_ptr=, this_ptr=0x7fd3c1a9e698, return_value_used=0) at /root/swoole-src-swoole-1.7.17-stable/swoole_server.c:2291
#1 0x0000000000897065 in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.9/Zend/zend_vm_execute.h:560
#2 0x0000000000886bc0 in execute_ex (execute_data=0x7fd3c1c3aa68) at /root/php-5.6.9/Zend/zend_vm_execute.h:363
#3 0x0000000000818949 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /root/php-5.6.9/Zend/zend.c:1341
#4 0x00000000007b844a in php_execute_script (primary_file=0x7ffff3d62d50) at /root/php-5.6.9/main/main.c:2597
#5 0x00000000008be78c in do_cli (argc=2, argv=0x13fab10) at /root/php-5.6.9/sapi/cli/php_cli.c:994
#6 0x00000000008bef28 in main (argc=2, argv=0x13fab10) at /root/php-5.6.9/sapi/cli/php_cli.c:1378

(gdb)

(gdb) f 1
#1 0x0000000000897065 in zend_do_fcall_common_helper_SPEC (execute_data=) at /root/php-5.6.9/Zend/zend_vm_execute.h:560

560 zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC);
(gdb)

(gdb) f 0
#0 zif_swoole_server_addtimer (ht=1, return_value=0x7fd3c1c76f08, return_value_ptr=, this_ptr=0x7fd3c1a9e698, return_value_used=0) at /root/swoole-src-swoole-1.7.17-stable/swoole_server.c:2291

2291 /root/swoole-src-swoole-1.7.17-stable/swoole_server.c: 没有那个文件或目录.
in /root/swoole-src-swoole-1.7.17-stable/swoole_server.c
(gdb)

@matyhtf
Copy link
Member

matyhtf commented Jun 8, 2015

贴一下你的代码

@merlinyang521
Copy link
Author

代码片段:
$this->server->addtimer(1000);
$this->server->on('Timer', function ($server, $interval) {
file_put_contents('/var/www/gg.log', date('Y-m-d H:i:s') . "\n", FILE_APPEND);
});
加上这两断代码就会发生断错误,不加就没事。

@matyhtf
Copy link
Member

matyhtf commented Jun 8, 2015

你用法有错误,必须在 回调函数中调用 addtimer

@matyhtf matyhtf closed this as completed Jun 8, 2015
@merlinyang521
Copy link
Author

1.7.5之后onStart回调中不再支持定时器
建议使用tick定时器,addtimer定时器未来或将移除

看文档有这个描述,我的代码有onStart的回调:
$this->server->on('WorkerStart', function ($server, $worker_id) {
$this->redis = R();
});
是不是这个原因啊?

@merlinyang521
Copy link
Author

好,我知道了,谢谢。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants