Coder Social home page Coder Social logo

Comments (21)

liangmanlin avatar liangmanlin commented on June 6, 2024

没有使用taskpool,直接在poller里面进行了一次nbiotcp.Write,按道理不会卡死?

from nbio.

lesismal avatar lesismal commented on June 6, 2024

用Shutdown试试。

from nbio.

lesismal avatar lesismal commented on June 6, 2024

提供下可复现的代码

from nbio.

lesismal avatar lesismal commented on June 6, 2024

我最近有点忙,闲了看

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

复现代码可能要等下周,目前已知就是在nbhttp.Parser.Read里面触发了Parser.Close,导致了死锁,nbhttp默认是用taskpool工作,可能平时不会发生,我是直接在poller里面执行函数

复现过程就是,大量新建wss连接,然后突然关闭客户端

from nbio.

lesismal avatar lesismal commented on June 6, 2024

我想想要不要给bio.Conn多加个mutex给Execute队列单独使用,否则这种io协程上不跨协程直接执行逻辑队列onclose确实不好弄。但poller协程上直接进行逻辑处理要注意避免阻塞比如请求下游http或者rpc或者数据库等其他阻塞操作

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

目前看只有onclose会这样,我认为可以把onclose放入taskpool运行,一般来说不会有问题,这样改的比较少

from nbio.

lesismal avatar lesismal commented on June 6, 2024

Onclose也要保证顺序,所以是用nbio.Conn.Execute放到Conn队列里去执行,这里默认就是用的taskpool但你定制后没有走协程池了

from nbio.

lesismal avatar lesismal commented on June 6, 2024

直接在engine调用onclose的地方go去执行倒是可以解决onclose本身,但可能还会有其他死锁

from nbio.

lesismal avatar lesismal commented on June 6, 2024

可以测下试试

from nbio.

lesismal avatar lesismal commented on June 6, 2024

你本地在这里加个go试试:
https://github.com/lesismal/nbio/blob/master/poller_epoll.go#L103

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

好,我试试

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

跑了几天,问题依旧,可能还有别的地方触发

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

在websocket.Conn.handleProtocolMessage也会触发close

奇怪,我确定已经在 deleteConn 加了go语句,为何还会死锁

from nbio.

lesismal avatar lesismal commented on June 6, 2024

还是用协程池吧,如果不想协程数量太多,把协程池size设小点就行了

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

c.Conn.Close()

把这个改成

go c.Conn.Close()

应该可以解决,考虑到可能破坏原来的设计**,看能不能加一个配置,用户选择是否异步执行?

from nbio.

lesismal avatar lesismal commented on June 6, 2024

这样看上去不太美丽,你们用size较小的协程池会有什么问题吗?

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

业务只是非常薄的一次wss->tcp转发,用异步处理感觉不划算

from nbio.

lesismal avatar lesismal commented on June 6, 2024

就用默认的协程池可以的不

from nbio.

lesismal avatar lesismal commented on June 6, 2024

如果在线量不是非常大,标准库同步方案延迟更低

from nbio.

liangmanlin avatar liangmanlin commented on June 6, 2024

嗯,我考虑一下

from nbio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.