Ver código fonte

修改优化代码

niujiuru 2 meses atrás
pai
commit
3911927b3c
1 arquivos alterados com 5 adições e 5 exclusões
  1. 5 5
      networkd.service/main.go

+ 5 - 5
networkd.service/main.go

@@ -29,7 +29,7 @@ type program struct {
 	name        string
 	core_server *jsonrpc2.RPCServer
 	http_server *http.Server
-	http_done   chan struct{}
+	done        chan struct{}
 }
 
 // Start should not block. Do the actual work async.
@@ -80,7 +80,7 @@ func (p *program) Start(s service.Service) error {
 		Handler: mux,
 	}
 
-	p.http_done = make(chan struct{})
+	p.done = make(chan struct{})
 
 	go p.run()
 
@@ -89,7 +89,7 @@ func (p *program) Start(s service.Service) error {
 
 // Do work here
 func (p *program) run() {
-	defer close(p.http_done)
+	defer close(p.done)
 
 	err := p.http_server.ListenAndServe() // 同步阻塞
 
@@ -112,8 +112,8 @@ func (p *program) Stop(s service.Service) error {
 		_ = p.http_server.Shutdown(ctx)
 	}
 
-	if p.http_done != nil {
-		<-p.http_done
+	if p.done != nil {
+		<-p.done
 	}
 
 	netmgrd.ModemExit()