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

v7.2.1/socket/socket.go的默认实现 一条协程close 另一条协程WriteMessage 会panic,并不安全 #106

Open
WanT0011 opened this issue Jun 11, 2024 · 0 comments

Comments

@WanT0011
Copy link

version: v7.2.1
问题:github.com/andeya/erpc/[email protected]/socket/socket.go:35 的socket接口说是并发安全的;但是在一个协程执行close操作,另一个协程执行WriteMessage方法时可能会出现panic;具体是 在protocol.Pack(message)的时候 protocol为空,因为它已经在close中置为了nil;

func (s *socket) WriteMessage(message Message) error {
	s.mu.RLock()
	protocol := s.protocol
	s.mu.RUnlock()
	err := protocol.Pack(message)
	if err != nil && s.isActiveClosed() {
		err = ErrProactivelyCloseSocket
	}
	return err
}

异常示例如图:
image

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

1 participant