(clientconn *ClientConn)
| 125 | } |
| 126 | |
| 127 | func (s *Server) serveClient(clientconn *ClientConn) error { |
| 128 | |
| 129 | loggo.Info("serveClient accept new client %s", clientconn.conn.Info()) |
| 130 | |
| 131 | sendch := common.NewChannel(s.config.MainBuffer) |
| 132 | recvch := common.NewChannel(s.config.MainBuffer) |
| 133 | |
| 134 | clientconn.sendch = sendch |
| 135 | clientconn.recvch = recvch |
| 136 | |
| 137 | wg := thread.NewGroup("Server serveClient"+" "+clientconn.conn.Info(), s.wg, func() { |
| 138 | loggo.Info("group start exit %s", clientconn.conn.Info()) |
| 139 | clientconn.conn.Close() |
| 140 | sendch.Close() |
| 141 | recvch.Close() |
| 142 | if clientconn.input != nil { |
| 143 | clientconn.input.Close() |
| 144 | } |
| 145 | if clientconn.output != nil { |
| 146 | clientconn.output.Close() |
| 147 | } |
| 148 | loggo.Info("group end exit %s", clientconn.conn.Info()) |
| 149 | }) |
| 150 | |
| 151 | var pingflag int32 |
| 152 | var pongflag int32 |
| 153 | var pongtime int64 |
| 154 | |
| 155 | wg.Go("Server recvFrom"+" "+clientconn.conn.Info(), func() error { |
| 156 | return recvFrom(wg, recvch, clientconn.conn, s.config.MaxMsgSize, s.config.Encrypt) |
| 157 | }) |
| 158 | |
| 159 | wg.Go("Server sendTo"+" "+clientconn.conn.Info(), func() error { |
| 160 | return sendTo(wg, sendch, clientconn.conn, s.config.Compress, s.config.MaxMsgSize, s.config.Encrypt, &pingflag, &pongflag, &pongtime) |
| 161 | }) |
| 162 | |
| 163 | wg.Go("Server checkPingActive"+" "+clientconn.conn.Info(), func() error { |
| 164 | return checkPingActive(wg, sendch, recvch, &clientconn.ProxyConn, s.config.EstablishedTimeout, s.config.PingInter, s.config.PingTimeoutInter, s.config.ShowPing, &pingflag) |
| 165 | }) |
| 166 | |
| 167 | wg.Go("Server checkNeedClose"+" "+clientconn.conn.Info(), func() error { |
| 168 | return checkNeedClose(wg, &clientconn.ProxyConn) |
| 169 | }) |
| 170 | |
| 171 | wg.Go("Server process"+" "+clientconn.conn.Info(), func() error { |
| 172 | return s.process(wg, sendch, recvch, clientconn, &pongflag, &pongtime) |
| 173 | }) |
| 174 | |
| 175 | wg.Wait() |
| 176 | if clientconn.established { |
| 177 | s.clients.Delete(clientconn.name) |
| 178 | } |
| 179 | |
| 180 | loggo.Info("serveClient close client %s", clientconn.conn.Info()) |
| 181 | |
| 182 | return nil |
| 183 | } |
| 184 |
no test coverage detected