Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ English | [中文](README_ZH.md)

# 🚀 Features

## 🦖 Milestone
## 🦖 Milestones

- [x] [High-performance](#-performance) event-driven looping based on a networking model of multiple threads/goroutines
- [x] Built-in goroutine pool powered by the library [ants](https://github.com/panjf2000/ants)
Expand Down Expand Up @@ -212,7 +212,7 @@ Test duration : 15s

[![](https://github.com/panjf2000/gnet_benchmarks/raw/master/results/echo_packet_macos.png)]((https://github.com/gnet-io/gnet-benchmarks))

### Comparison with Rust
### Combat with Rust

[![](https://res.strikefreedom.top/static_res/blog/figures/Gjfx2GoXAAA5haW.jpeg)](https://www.youtube.com/watch?v=31R8Ef9A0iw)

Expand Down
4 changes: 2 additions & 2 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

# 🚀 功能

## 🦖 当前支持
## 🦖 里程碑

- [x] 基于多线程/协程网络模型的[高性能](#-性能测试)事件驱动循环
- [x] 内置 goroutine 池,由开源库 [ants](https://github.com/panjf2000/ants) 提供支持
Expand All @@ -51,7 +51,7 @@
- [x] 多网络地址绑定
- [x] 支持注册新的连接到事件循环

## 🕊 未来计划
## 🕊 蓝图

- [ ] 支持 **TLS**
- [ ] 支持 [io_uring](https://github.com/axboe/liburing/wiki/io_uring-and-networking-in-2023)
Expand Down
2 changes: 2 additions & 0 deletions client_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ func (cli *Client) EnrollContext(c net.Conn, ctx any) (Conn, error) {
var dupFD int
e := rc.Control(func(fd uintptr) {
dupFD, err = unix.Dup(int(fd))
// Set the socket to close-on-exec, so that the socket is closed when the process forks
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment is inaccurate. The close-on-exec flag prevents the file descriptor from being inherited by child processes created via exec() system calls, not fork(). After fork(), file descriptors are inherited by default, but close-on-exec ensures they are closed when exec() is called. The comment should be updated to reflect this distinction.

Suggested change
// Set the socket to close-on-exec, so that the socket is closed when the process forks
// Set the socket to close-on-exec so that the duplicated descriptor is not inherited by exec'ed child processes.

Copilot uses AI. Check for mistakes.
unix.CloseOnExec(dupFD)
Comment on lines 213 to +215
Copy link

Copilot AI Dec 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CloseOnExec call is missing error handling. If unix.Dup() fails (line 213), dupFD will be 0 (the zero value for int), and calling unix.CloseOnExec(0) could incorrectly set the close-on-exec flag on stdin. The error from unix.Dup should be checked before calling CloseOnExec, or CloseOnExec should only be called if dupFD is valid (greater than 0).

Suggested change
dupFD, err = unix.Dup(int(fd))
// Set the socket to close-on-exec, so that the socket is closed when the process forks
unix.CloseOnExec(dupFD)
newFD, dupErr := unix.Dup(int(fd))
if dupErr != nil {
err = dupErr
return
}
dupFD = newFD
// Set the socket to close-on-exec, so that the socket is closed when the process forks
if closeErr := unix.CloseOnExec(dupFD); closeErr != nil {
err = closeErr
}

Copilot uses AI. Check for mistakes.
})
if err != nil {
return nil, err
Expand Down
Loading