diff options
author | Wolfy-J <[email protected]> | 2018-06-07 18:21:39 +0300 |
---|---|---|
committer | Wolfy-J <[email protected]> | 2018-06-07 18:21:39 +0300 |
commit | 64f644a1892f1e1606481ca4f89cb81ea2c1491f (patch) | |
tree | 881a4c7d952207ce753c7680f39ff6395ada58ad | |
parent | f90b62e5cb55d03af928119cfd7831ddd759fed2 (diff) |
more tests
-rw-r--r-- | rpc/service.go | 25 | ||||
-rw-r--r-- | rpc/service_test.go | 1 |
2 files changed, 15 insertions, 11 deletions
diff --git a/rpc/service.go b/rpc/service.go index 4454f8e6..71f6fc41 100644 --- a/rpc/service.go +++ b/rpc/service.go @@ -52,20 +52,23 @@ func (s *Service) Serve() error { } defer ln.Close() - for { - select { - case <-s.stop: - return nil - default: - conn, err := ln.Accept() - if err != nil { - continue + go func() { + for { + select { + case <-s.stop: + break + default: + conn, err := ln.Accept() + if err != nil { + continue + } + + go s.rpc.ServeCodec(goridge.NewCodec(conn)) } - - go s.rpc.ServeCodec(goridge.NewCodec(conn)) } - } + }() + <-s.stop return nil } diff --git a/rpc/service_test.go b/rpc/service_test.go index a83de388..8ccad644 100644 --- a/rpc/service_test.go +++ b/rpc/service_test.go @@ -30,6 +30,7 @@ func Test_RegisterNotConfigured(t *testing.T) { client, err := s.Client() assert.Nil(t, client) assert.Error(t, err) + assert.Error(t, s.Serve()) } func Test_Enabled(t *testing.T) { |