added ReqStopAllServerConns() to the Server type
This commit is contained in:
parent
c901f88023
commit
eef1941dea
@ -23,6 +23,10 @@ type server_ctl_server_conns struct {
|
||||
s *Server
|
||||
}
|
||||
|
||||
type server_ctl_server_conns_id struct {
|
||||
s *Server
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
@ -63,7 +67,7 @@ func (ctl *server_ctl_server_conns) ServeHTTP(w http.ResponseWriter, req *http.R
|
||||
if err = je.Encode(js); err != nil { goto oops }
|
||||
|
||||
case http.MethodDelete:
|
||||
// TODO s.ReqStopAllServerConns()
|
||||
s.ReqStopAllServerConns()
|
||||
status_code = http.StatusNoContent; w.WriteHeader(status_code)
|
||||
|
||||
default:
|
||||
@ -78,3 +82,9 @@ oops:
|
||||
s.log.Write("", LOG_ERROR, "[%s] %s %s - %s", req.RemoteAddr, req.Method, req.URL.String(), err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
func (ctl *server_ctl_server_conns_id) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
// TODO:
|
||||
}
|
||||
|
11
server.go
11
server.go
@ -895,6 +895,17 @@ func (s *Server) AddNewServerConn(remote_addr *net.Addr, local_addr *net.Addr, p
|
||||
return &cts, nil
|
||||
}
|
||||
|
||||
func (s *Server) ReqStopAllServerConns() {
|
||||
var cts *ServerConn
|
||||
|
||||
s.cts_mtx.Lock()
|
||||
defer s.cts_mtx.Unlock()
|
||||
|
||||
for _, cts = range s.cts_map {
|
||||
cts.ReqStop()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) RemoveServerConn(cts *ServerConn) {
|
||||
s.cts_mtx.Lock()
|
||||
delete(s.cts_map, cts.caddr)
|
||||
|
Loading…
x
Reference in New Issue
Block a user