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

fixed bug. Multi routine call WriteMessage will make race for same bu… #30

Closed
wants to merge 1 commit into from

Conversation

lpflpf
Copy link

@lpflpf lpflpf commented Jun 17, 2019

// issue.go
package main

import (
    "time"
    "gopkg.in/Graylog2/go-gelf.v2/gelf"
)

func main() {
    addr := ""
	writer, _ := gelf.NewTCPWriter(addr)
	parall := 10000
	goroutineSize := 100
	for q := 0; q < goroutineSize; q++ {
		go func() {
			for j := 0; j < parall/goroutineSize; j++ {
				writer.WriteMessage(&gelf.Message{
					Version:  "1.0",
					Host:     "hostname",
					Short:    "-",
					TimeUnix: float64(time.Now().UnixNano()),
					Level:    6,
					Facility: "",
				})
			}
		}()
	}
	select {}
}

run go run -race issue.go; will get DATA RACE WARNING.
it is a bugfix: https://github.com/lpflpf/go-gelf/tree/v2

@CLAassistant
Copy link

CLAassistant commented Jun 17, 2019

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@lpflpf lpflpf closed this Jun 17, 2019
@lpflpf lpflpf deleted the v2 branch June 17, 2019 11:03
@dennisoelkers
Copy link
Member

Hey @lpflpf, thanks for your submission. What is the reason you closed this PR?

@lpflpf
Copy link
Author

lpflpf commented Jun 18, 2019

It has a mistake in submission. It have been submited again.

#31

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

Successfully merging this pull request may close these issues.

3 participants