summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfy-J <[email protected]>2018-06-07 18:21:39 +0300
committerWolfy-J <[email protected]>2018-06-07 18:21:39 +0300
commit64f644a1892f1e1606481ca4f89cb81ea2c1491f (patch)
tree881a4c7d952207ce753c7680f39ff6395ada58ad
parentf90b62e5cb55d03af928119cfd7831ddd759fed2 (diff)
more tests
-rw-r--r--rpc/service.go25
-rw-r--r--rpc/service_test.go1
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) {