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

出现fatal error: concurrent map read and map write。 #397

Open
wuchuwei opened this issue Nov 4, 2024 · 2 comments
Open

出现fatal error: concurrent map read and map write。 #397

wuchuwei opened this issue Nov 4, 2024 · 2 comments

Comments

@wuchuwei
Copy link

wuchuwei commented Nov 4, 2024

goroutine 5677 [running]: github.com/imroc/req/v3.parseRequestHeader(0xc000626dc0, 0xc000a44000) /root/go/pkg/mod/github.com/imroc/req/[email protected]/middleware.go:537 +0x391 github.com/imroc/req/v3.(*Request).do(0xc000a44000) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:660 +0xac7 github.com/imroc/req/v3.(*Request).Do(0xc000a44000, {0x0, 0x0, 0xc000e067b0?}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:636 +0x38f github.com/imroc/req/v3.(*Request).Send(0xc000a44000, {0xec2aad, 0x3}, {0xc000042540, 0x3c}) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:726 +0xfb github.com/imroc/req/v3.(*Request).Get(...) /root/go/pkg/mod/github.com/imroc/req/[email protected]/request.go:745 main.(*config).request.func4({0xc000042540, 0x3c}, 0x3, 0xc000590200) /opt/go-project/net_check/test2.go:529 +0x185 created by main.(*config).request in goroutine 5653 /opt/go-project/net_check/test2.go:527 +0x1265
请问这个问题要如何处理?

@wuchuwei
Copy link
Author

wuchuwei commented Nov 5, 2024

问题出现在client设置User-agent上。

@imroc
Copy link
Owner

imroc commented Nov 5, 2024

问题出现在client设置User-agent上。

正在处理请求的过程中设置 User-Agent? 这种应该可能有问题,一般都在用client前先设置好User-Agent,req本身没有加锁,默认加锁影响性能,如果实在要这么用(请求过程中改client User-Agent),可以自己在外围加锁控制下

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