service#Start, service#Stop signatures were changed

See https://github.com/tendermint/tmlibs/issues/45
This commit is contained in:
Anton Kaliaev
2017-11-06 13:20:39 -05:00
parent a393cf4109
commit 69b5da766c
38 changed files with 99 additions and 104 deletions

View File

@ -47,10 +47,10 @@ type WSClient struct {
onReconnect func()
// internal channels
send chan types.RPCRequest // user requests
backlog chan types.RPCRequest // stores a single user request received during a conn failure
reconnectAfter chan error // reconnect requests
readRoutineQuit chan struct{} // a way for readRoutine to close writeRoutine
send chan types.RPCRequest // user requests
backlog chan types.RPCRequest // stores a single user request received during a conn failure
reconnectAfter chan error // reconnect requests
readRoutineQuit chan struct{} // a way for readRoutine to close writeRoutine
wg sync.WaitGroup
@ -168,12 +168,12 @@ func (c *WSClient) OnStop() {}
// Stop overrides cmn.Service#Stop. There is no other way to wait until Quit
// channel is closed.
func (c *WSClient) Stop() bool {
success := c.BaseService.Stop()
func (c *WSClient) Stop() error {
err := c.BaseService.Stop()
// only close user-facing channels when we can't write to them
c.wg.Wait()
close(c.ResponsesCh)
return success
return err
}
// IsReconnecting returns true if the client is reconnecting right now.

View File

@ -196,7 +196,7 @@ func TestNotBlockingOnStop(t *testing.T) {
func startClient(t *testing.T, addr net.Addr) *WSClient {
c := NewWSClient(addr.String(), "/websocket")
_, err := c.Start()
err := c.Start()
require.Nil(t, err)
c.SetLogger(log.TestingLogger())
return c