Skip to content

Commit

Permalink
Merge branch 'dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
0-haha authored Mar 3, 2024
2 parents ecdf787 + f6b0d30 commit 6191b85
Show file tree
Hide file tree
Showing 32 changed files with 339 additions and 191 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below).
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -71,4 +71,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
31 changes: 12 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ jobs:
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

- name: Checkout repository
uses: actions/checkout@v3
cache: false

- name: Setup and run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.52.2
version: v1.56.2
args: -v -E gofumpt -E gocritic -E misspell -E revive -E godot --timeout 5m
test:
needs: lint
Expand All @@ -64,12 +65,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand All @@ -86,27 +87,19 @@ jobs:
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
${{ steps.go-env.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go-ci
- name: Run unit tests for packages
run: go test $(go list ./... | tail -n +2)

- name: Run integration tests
run: go test -v -race -coverprofile="codecov.report" -covermode=atomic -timeout 15m -failfast

- name: Upload the code coverage report to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./codecov.report
flags: unittests
name: codecov-gnet
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31 changes: 12 additions & 19 deletions .github/workflows/test_gc_opt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,19 @@ jobs:
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

- name: Checkout repository
uses: actions/checkout@v3
cache: false

- name: Setup and run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.52.2
version: v1.56.2
args: -v -E gofumpt -E gocritic -E misspell -E revive -E godot --timeout 5m
test:
needs: lint
Expand All @@ -64,12 +65,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

Expand All @@ -86,27 +87,19 @@ jobs:
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
${{ steps.go-env.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go-ci
- name: Run unit tests for packages
run: go test $(go list ./... | tail -n +2)

- name: Run integration tests
run: go test -v -race -tags=gc_opt -coverprofile="codecov.report" -covermode=atomic -timeout 15m -failfast

- name: Upload the code coverage report to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./codecov.report
flags: unittests
name: codecov-gnet
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31 changes: 12 additions & 19 deletions .github/workflows/test_poll_opt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ jobs:
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

- name: Checkout repository
uses: actions/checkout@v3
cache: false

- name: Setup and run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.52.2
version: v1.56.2
args: -v -E gofumpt -E gocritic -E misspell -E revive -E godot
test:
needs: lint
Expand All @@ -60,12 +61,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

Expand All @@ -82,27 +83,19 @@ jobs:
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
${{ steps.go-env.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go-ci
- name: Run unit tests for packages
run: go test $(go list ./... | tail -n +2)

- name: Run integration tests with -tags=poll_opt
run: go test -v -tags=poll_opt -coverprofile="codecov.report" -covermode=atomic -timeout 10m -failfast

- name: Upload the code coverage report to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./codecov.report
flags: unittests
name: codecov-gnet-poll_opt
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
31 changes: 12 additions & 19 deletions .github/workflows/test_poll_opt_gc_opt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,19 @@ jobs:
name: Run golangci-lint
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

- name: Checkout repository
uses: actions/checkout@v3
cache: false

- name: Setup and run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.52.2
version: v1.56.2
args: -v -E gofumpt -E gocritic -E misspell -E revive -E godot
test:
needs: lint
Expand All @@ -60,12 +61,12 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: '^1.17'

Expand All @@ -82,27 +83,19 @@ jobs:
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "GO_CACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
- name: Cache go modules
uses: actions/cache@v3
with:
path: |
${{ steps.go-env.outputs.GO_CACHE }}
~/go/pkg/mod
key: ${{ runner.os }}-${{ matrix.go }}-go-ci-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go }}-go-ci
- name: Run unit tests for packages
run: go test $(go list ./... | tail -n +2)

- name: Run integration tests with -tags=poll_opt
run: go test -v -tags=poll_opt,gc_opt -coverprofile="codecov.report" -covermode=atomic -timeout 10m -failfast

- name: Upload the code coverage report to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: ./codecov.report
flags: unittests
name: codecov-gnet-poll_opt
fail_ci_if_error: true
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
13 changes: 8 additions & 5 deletions acceptor_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@

package gnet

// The canonical BSD sockets implementation will inherit file status flags
// from the listening socket, so we don't need to set the non-blocking flag
// for the accepted sockets explicitly.
func setNonBlock(_ int, _ bool) error {
return nil
import "github.com/panjf2000/gnet/v2/internal/netpoll"

func (eng *engine) accept(fd int, filter netpoll.IOEvent, flags netpoll.IOFlags) error {
return eng.accept1(fd, filter, flags)
}

func (el *eventloop) accept(fd int, filter netpoll.IOEvent, flags netpoll.IOFlags) error {
return el.accept1(fd, filter, flags)
}
10 changes: 7 additions & 3 deletions acceptor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@

package gnet

import "golang.org/x/sys/unix"
import "github.com/panjf2000/gnet/v2/internal/netpoll"

func setNonBlock(fd int, nonBlocking bool) error {
return unix.SetNonblock(fd, nonBlocking)
func (eng *engine) accept(fd int, ev netpoll.IOEvent) error {
return eng.accept1(fd, ev, 0)
}

func (el *eventloop) accept(fd int, ev netpoll.IOEvent) error {
return el.accept1(fd, ev, 0)
}
Loading

0 comments on commit 6191b85

Please sign in to comment.