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

rpc多次调用close #40

Open
kysshsy opened this issue Aug 5, 2021 · 0 comments
Open

rpc多次调用close #40

kysshsy opened this issue Aug 5, 2021 · 0 comments

Comments

@kysshsy
Copy link

kysshsy commented Aug 5, 2021

func (server *Server) ServeConn(conn io.ReadWriteCloser) {
	defer func() { _ = conn.Close() }()
    // ....

}
func (server *Server) serveCodec(cc codec.Codec) {
	sending := new(sync.Mutex) // make sure to send a complete response
	wg := new(sync.WaitGroup)  // wait until all request are handled
	for {
		//...
	}
	wg.Wait()
	_ = cc.Close() // 这里
}

gobCodec的close 直接调用了conn.close
这里好像多次调用了conn的close?

stackOverflow的讨论

似乎这样会出问题,我想应该有两种解决方案

  1. 把codec的close都实现成幂等的
  2. 把ServeConn的Close去掉

希望解惑 谢谢

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