Skip to content

Commit

Permalink
add -race flags for go test and fix data race warning
Browse files Browse the repository at this point in the history
Signed-off-by: ruitianzhong <ruitian-zhong@outlook.com>
  • Loading branch information
ruitianzhong committed Mar 2, 2024
1 parent b12878b commit d70e863
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go-c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
make env
make nocore
- name: Test
run: go test -v ./...
run: go test -v -race ./...

build-on-ubuntu2204:
runs-on: ubuntu-22.04
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
make env
make nocore
- name: Test
run: go test -v ./...
run: go test -v -race ./...

build-on-ubuntu2004-arm64:
runs-on: ubuntu-22.04
Expand Down
3 changes: 1 addition & 2 deletions pkg/event_processor/http_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ func (hr *HTTPRequest) detect(payload []byte) error {
//hr.Init()
rd := bytes.NewReader(payload)
buf := bufio.NewReader(rd)
req, err := http.ReadRequest(buf)
_, err := http.ReadRequest(buf)
if err != nil {
return err
}
hr.request = req
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/event_processor/http_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,10 @@ func (hr *HTTPResponse) Write(b []byte) (int, error) {
func (hr *HTTPResponse) detect(payload []byte) error {
rd := bytes.NewReader(payload)
buf := bufio.NewReader(rd)
res, err := http.ReadResponse(buf, nil)
_, err := http.ReadResponse(buf, nil)
if err != nil {
return err
}
hr.response = res
return nil
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/event_processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ func (this *EventProcessor) Write(e event.IEventStruct) {
}

func (this *EventProcessor) Close() error {
this.Lock()
defer this.Unlock()
if len(this.workerQueue) > 0 {
return fmt.Errorf("EventProcessor.Close(): workerQueue is not empty:%d", len(this.workerQueue))
}
Expand Down

0 comments on commit d70e863

Please sign in to comment.