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

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

Closed
zhu121 opened this issue May 19, 2022 · 5 comments
Closed

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

zhu121 opened this issue May 19, 2022 · 5 comments
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@zhu121
Copy link

zhu121 commented May 19, 2022

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

  • OS : windows 11
  • Go version : 1.18.1
  • gnet version : v2.0.3

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

@zhu121 zhu121 added help wanted Extra attention is needed question Further information is requested labels May 19, 2022
@panjf2000
Copy link
Owner

不是很明白你的问题。

@zhu121
Copy link
Author

zhu121 commented May 23, 2022

不是很明白你的问题。

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

  • 连接A的fd是100
  • 调用eventloop的read()处理连接A的读取,但还没真的读走数据
  • 连接A被另一个goroutine关闭了
  • 此时有个连接B建立,且操作系统复用fd,连接B的fd也是100
  • 连接A真正读数据时,读到的是连接B的数据

@panjf2000
Copy link
Owner

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

@lesismal
Copy link

lesismal commented May 26, 2022

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

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

@lesismal
Copy link

lesismal commented May 26, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants