panjf2000 / gnet

🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.
https://gnet.host
Apache License 2.0
9.66k stars 1.04k forks source link

Question about the "read" function of "eventloop" #371

Closed zhu121 closed 1 year ago

zhu121 commented 2 years ago

Please fill out the following system information before opening an issue:

What is your question about gnet? Whether it need to use lock to prevent multiple conn data confusion when fd is reused on unix.

panjf2000 commented 2 years ago

不是很明白你的问题。

zhu121 commented 2 years ago

不是很明白你的问题。

想请教下,gnet是否会遇到这样的问题:

panjf2000 commented 2 years ago

连接 A 关闭之后 gnet 会清理掉保存的 connection 数据,所以 fd 被复用也不会有问题。

lesismal commented 2 years ago

框架层也需要考虑一些应用层实际应用的问题:

  1. 通常应用层逻辑会使用额外的逻辑协程池
  2. 除了http类的无状态服务比较容易做到跟框架一块Close & Clear,其他很多业务类型,应用层都会持有Conn并且不太容易保证同步Close & Clear。比如一个队列模块会异步Conn Write,如果此时的Conn即使调用写也不会真正写入原来的fd那没什么问题,如果仍然能够写入原fd,则需要考虑窜号的问题
lesismal commented 2 years ago

另外,对于ringbuffer之类的使用,我之前给gev提过一个issue,也都是需要考虑应用层在使用poller框架封装实际业务时需要面对的问题也可以讨论下,我就不单独开帖了: https://github.com/Allenxuxu/gev/issues/114