Compare commits

..

No commits in common. "v3" and "v3.10.2" have entirely different histories.
v3 ... v3.10.2

18
tcp.go
View File

@ -1,5 +1,5 @@
// Package tcp implements a go-micro.Server // Package tcp implements a go-micro.Server
package tcp package tcp // import "go.unistack.org/micro-server-tcp/v3"
import ( import (
"context" "context"
@ -16,7 +16,7 @@ import (
"go.unistack.org/micro/v3/logger" "go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/register" "go.unistack.org/micro/v3/register"
"go.unistack.org/micro/v3/server" "go.unistack.org/micro/v3/server"
msync "go.unistack.org/micro/v3/sync"
"golang.org/x/net/netutil" "golang.org/x/net/netutil"
) )
@ -62,9 +62,6 @@ func (h *Server) Options() server.Options {
} }
func (h *Server) Init(opts ...server.Option) error { func (h *Server) Init(opts ...server.Option) error {
if h.opts.Wait == nil {
h.opts.Wait = msync.NewWaitGroup()
}
if len(opts) == 0 && h.init { if len(opts) == 0 && h.init {
return nil return nil
} }
@ -489,14 +486,15 @@ func (h *Server) serve(ln net.Listener, hd Handler) {
return return
} }
if h.opts.Wait != nil { if err != nil {
h.opts.Wait.Add(1) config.Logger.Error(config.Context, "tcp: accept err", err)
return
} }
h.opts.Wait.Add(1)
go func() { go func() {
hd.Serve(c) hd.Serve(c)
if h.opts.Wait != nil { h.opts.Wait.Done()
h.opts.Wait.Done()
}
}() }()
} }
} }