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

Gopher的listeners的初始化问题 #139

Closed
zhu121 opened this issue Oct 30, 2021 · 4 comments
Closed

Gopher的listeners的初始化问题 #139

zhu121 opened this issue Oct 30, 2021 · 4 comments

Comments

@zhu121
Copy link

zhu121 commented Oct 30, 2021

以下代码是不是重复了(Is the following code repeated)?:

  1. gopher_std.go/L95,listeners: make([]*poller, len(conf.Addrs))
  2. gopher_std.go/L24:g.listeners = make([]*poller, len(g.addrs))
@lesismal
Copy link
Owner

是的,应该是早期实现的时候 windows 和 uni* 差别,后来整理了没那么细,但是只有windows上面重复了,而且没什么影响,uni*没有第二次make:
https://github.com/lesismal/nbio/blob/master/gopher_unix.go#L23

并且这种make后没使用的内存不会真正分配内存

我把windows重复的这句去掉,感谢反馈!

@zhu121
Copy link
Author

zhu121 commented Oct 30, 2021

gopher实现的相关疑惑:
gopher_unix.go/L36:for j := 0; j < len(g.lfds); j++ {}多余的吗?没有看到lfds的初始化或其他使用
gopher_std.go/L22:g.lfds = []int{}也是类似的

@lesismal
Copy link
Owner

lesismal commented Oct 30, 2021

gopher实现的相关疑惑: gopher_unix.go/L36:for j := 0; j < len(g.lfds); j++ {}多余的吗?没有看到lfds的初始化或其他使用 gopher_std.go/L22:g.lfds = []int{}也是类似的

应该是多余的,最早时候是用的 syscall,单个 epoll 单个 goroutine 处理多个 listener fd 的,后来改成直接用标准库了,清理的时候漏掉了、遗留下的,不影响使用。
难得有人来阅读代码,有兴趣欢迎来 pr 一下、多多指正一些

@lesismal
Copy link
Owner

lesismal commented Nov 8, 2021

这个可以先关闭了吗?

@zhu121 zhu121 closed this as completed Nov 12, 2021
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