add write queue again

module
ffdfgdfg 2019-09-02 00:18:52 +08:00
parent 51a3787708
commit 3413ceb7c2
2 changed files with 8 additions and 13 deletions

View File

@ -148,12 +148,7 @@ func (s *conn) Close() (err error) {
}
func (s *conn) closeProcess() {
if s.isClose {
logs.Warn("has closed ", s.connId)
return
}
s.isClose = true
s.readWait = false
s.mux.connMap.Delete(s.connId)
common.CopyBuff.Put(s.readBuffer)
close(s.readCh)

View File

@ -41,7 +41,7 @@ func NewMux(c net.Conn, connType string) *Mux {
go m.readSession()
//ping
go m.ping()
//go m.writeSession()
go m.writeSession()
return m
}
@ -107,13 +107,13 @@ func (s *Mux) sendInfo(flag uint8, id int32, content []byte) {
if pack.Flag == common.MUX_NEW_CONN {
logs.Warn("sendinfo mux new conn, insert to write queue", pack.Id)
}
//s.writeQueue <- buf
_, err = buf.WriteTo(s.conn)
if err != nil {
s.Close()
logs.Warn("write err, close mux", err)
}
common.BuffPool.Put(buf)
s.writeQueue <- buf
//_, err = buf.WriteTo(s.conn)
//if err != nil {
// s.Close()
// logs.Warn("write err, close mux", err)
//}
//common.BuffPool.Put(buf)
return
}