update server/stop

This commit is contained in:
曹海迪 2020-11-06 08:26:03 +08:00
parent 91f120371c
commit 600bd1f875

View File

@ -27,6 +27,7 @@ import (
"math/big"
"net"
"net/http"
"reflect"
"strings"
"time"
@ -316,7 +317,14 @@ func (svr *Service) Run() {
// Stop 停止服务
func (svr *Service) Stop() error {
err := svr.muxer.Close()
var err error
value := reflect.ValueOf(svr.muxer)
lnValue := value.Elem().FieldByName("ln")
ln, ok := lnValue.Interface().(net.Listener)
if ok && ln != nil {
err = ln.Close()
}
if svr.listener != nil {
_ = svr.listener.Close()
}