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

ghttp/ghttp_server_router_group: Concurrency Panic Issue with ghttp.Server Route Registration #4128

Open
linliyuan opened this issue Jan 21, 2025 · 0 comments
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@linliyuan
Copy link

Go version

go 1.19

GoFrame version

v2.5.7

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

As shown in the image, we have two HTTP servers: one for web interfaces and another for monitoring services. However, if both are started using the Server.Run method, a race condition occurs. Shouldn't preBindItems be an attribute of the Server rather than a global variable?

Image

What did you see happen?

Here is our code:

Image

Step 1: Use go func to register the monitoring HTTP service routes and start the service.
Step 2: Register the web routes and start the web service.

Result: Both HTTP services concurrently write to and read from the global preBindItems variable, leading to a race condition.

What did you expect to see?

Shouldn't preBindItems be an attribute of the Server rather than a global variable?

@linliyuan linliyuan added the bug It is confirmed a bug, but don't worry, we'll handle it. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

No branches or pull requests

1 participant