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

go_ws/server.go #9

Open
anxiaowen opened this issue Jan 10, 2024 · 5 comments
Open

go_ws/server.go #9

anxiaowen opened this issue Jan 10, 2024 · 5 comments

Comments

@anxiaowen
Copy link

read方法里面修改全局变量clientMsg,难道不会有并发问题?

@hezhizheng
Copy link
Owner

read方法里面修改全局变量clientMsg,难道不会有并发问题?

尝试修复了

@anxiaowen
Copy link
Author

你这个明显不对,消息不能用全局变量存,不然并发上去肯定会出错.

@hezhizheng hezhizheng reopened this Feb 20, 2024
@anxiaowen
Copy link
Author

你不应该使用全局的变量,应该使用局部变量,然后通过方法传递.或者使用结构体方法的方式

@hezhizheng
Copy link
Owner

你不应该使用全局的变量,应该使用局部变量,然后通过方法传递.或者使用结构体方法的方式

ok 谢谢指出 有空我再验证一下

@anxiaowen
Copy link
Author

anxiaowen commented Feb 22, 2024

server.go 不应该 使用select {} 来挂起,这样会内存泄露,我不知你为什么要注释掉

	
		select {
		case <-done:
			return
		}
	

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