We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在 server.Serve()中添加了如下代码:
server.Serve()
//运行服务 func (s *Server) Serve() { s.Start() //TODO Server.Serve() 是否在启动服务的时候 还要处理其他的事情呢 可以在这里添加 //阻塞,否则主Go退出, listenner的go将会退出 exits := make(chan os.Signal, 1) signal.Notify(exits, os.Interrupt, os.Kill) select { case <-exits: s.Stop() return } }
client与server socket正常通信,在终端中手动停止掉 go run server.go, client方日志显示正常的socket关闭,但是在server这里执行connection.Close()卡住。
client
server
go run server.go
终端的一些日志:
connection add to ConnManager successfully: conn num = 1 [Writer Goroutine is running] [Reader Goroutine is running] ^C[STOP] Zinx server , name ZinxServerApp Conn Stop()...ConnID = 0 127.0.0.1:54887 [conn Writer exit!] read msg head error read tcp4 127.0.0.1:8999->127.0.0.1:54887: use of closed network connection Conn Stop()...ConnID = 0 127.0.0.1:54887 [conn Reader exit!] ^C^C^C^C^C^C^C^C^Z [1] + 43852 suspended go run server.go
The text was updated successfully, but these errors were encountered:
我也遇到这个卡住不退出的情况,跟了一下代码,根本原因是死锁问题导致的。 在调用Server.Stop() 的时候,执行了: s.ConnMgr.ClearConn() <------(1) 在ClearConn() 中,执行了conn.Stop()。 在conn.Stop()中又调用了ConMgr的Remove() <------(2)
在(1)和(2)中都要拿到锁connMgr.connLock.Lock(),所以在调用Remove()的时候就卡住了,这应该是一个bug。
Sorry, something went wrong.
@lauber00 感谢,刚才检查了代码,确实是这种情况,删除了 ClearConn里面的锁来解决了。
ClearConn
这问题似乎没有提交给维护团队, 那大家都直接魔改源码么
No branches or pull requests
变动
在
server.Serve()
中添加了如下代码:异常情景
client
与server
socket正常通信,在终端中手动停止掉go run server.go
,client
方日志显示正常的socket关闭,但是在server这里执行connection.Close()卡住。终端的一些日志:
The text was updated successfully, but these errors were encountered: