cloudwu / skynet

A lightweight online game framework
MIT License
13.33k stars 4.2k forks source link

clusterd 接受一个连接,启动clusteragent时,forward失败,导致clusteragent服务创建失败,这时fd无法正常关闭 #1958

Closed mengtianci closed 3 months ago

mengtianci commented 3 months ago
lua call [1b3 to :12 : 2 msgsz = 10] error : ^[[31m./skynet/lualib/skynet.lua:861: ./skynet/lualib/skynet.lua:330: ./skynet/service/gate.lua:75: assertion failed!
stack traceback:
        [C]: in function 'assert'
        ./skynet/service/gate.lua:75: in function <./skynet/service/gate.lua:74>
        (...tail calls...)
        ./skynet/lualib/snax/gateserver.lua:148: in upvalue 'f'
        ./skynet/lualib/skynet.lua:280: in function <./skynet/lualib/skynet.lua:252>
stack traceback:
        [C]: in function 'assert'
        ./skynet/lualib/skynet.lua:861: in function 'skynet.dispatch_message'^[[0m
[:000001b3][DEBUG][04:54:34.79][service0]init service failed: ./skynet/lualib/skynet.lua:593: call failed
stack traceback:
        [C]: in function 'error'
        ./skynet/lualib/skynet.lua:593: in upvalue 'yield_call'
        ./skynet/lualib/skynet.lua:610: in function 'skynet.call'
        ./skynet/service/clusteragent.lua:134: in upvalue 'start'
        ./skynet/lualib/skynet.lua:942: in function <./skynet/lualib/skynet.lua:940>
        [C]: in function 'xpcall'
        ./skynet/lualib/skynet.lua:944: in function 'skynet.init_service'
        ./skynet/lualib/skynet.lua:957: in upvalue 'f'
        ./skynet/lualib/skynet.lua:253: in function <./skynet/lualib/skynet.lua:252>
[:000001b3][DEBUG][04:54:34.79][service0]KILL self
[:0000000d][DEBUG][04:54:34.79][service0]lua call [3 to :d : 197 msgsz = 0] error : ^[[31m./skynet/lualib/skynet.lua:861: ./skynet/lualib/skynet.lua:330: ./skynet/lualib/skynet.lua:593: call failed
stack traceback:
        [C]: in function 'error'
        ./skynet/lualib/skynet.lua:593: in upvalue 'yield_call'
        ./skynet/lualib/skynet.lua:610: in function 'skynet.call'
        (...tail calls...)
        ./skynet/service/clusterd.lua:216: in local 'f'
        ./skynet/service/clusterd.lua:243: in upvalue 'f'
        ./skynet/lualib/skynet.lua:280: in function <./skynet/lualib/skynet.lua:252>
stack traceback:
        [C]: in function 'assert'
        ./skynet/lualib/skynet.lua:861: in function 'skynet.dispatch_message'^[[0m
cloudwu commented 3 months ago

所有文本信息,均不要以截图形式发出来。

cloudwu commented 3 months ago

如何重现?

@hongling0 是否和最近修改有关?

mengtianci commented 3 months ago

猜想,应该是创建clusteragent服务的过程中,对方关闭连接,gate里的connection表里的fd项被置空,forward的时候,调用assert(connection[fd])断言失败。这个是线上偶发的情况。

cloudwu commented 3 months ago

是有这种可能性。我明天改一下,gate 的 forward 感觉用错误返回值更好;但为了保持兼容性,这里加上 pcall 应该就可以了。