ing
This commit is contained in:
parent
41d269f268
commit
e1f57d373a
10
client.go
10
client.go
|
@ -45,8 +45,7 @@ func (c *client) Start() {
|
||||||
|
|
||||||
c.ch.OnStart()
|
c.ch.OnStart()
|
||||||
|
|
||||||
c.stopWg.Add(1)
|
runClient(c)
|
||||||
go runClient(c)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) Stop() {
|
func (c *client) Stop() {
|
||||||
|
@ -66,7 +65,6 @@ func runClient(c *client) {
|
||||||
var err error
|
var err error
|
||||||
var stopping atomic.Value
|
var stopping atomic.Value
|
||||||
|
|
||||||
for {
|
|
||||||
dialChan := make(chan struct{})
|
dialChan := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
if conn, err = c.ch.Dial(); err != nil {
|
if conn, err = c.ch.Dial(); err != nil {
|
||||||
|
@ -93,17 +91,17 @@ func runClient(c *client) {
|
||||||
return
|
return
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
}
|
}
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClientConnection(c, conn)
|
go handleClientConnection(c, conn)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-c.stopChan:
|
case <-c.stopChan:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleClientConnection(c *client, conn io.ReadWriteCloser) {
|
func handleClientConnection(c *client, conn io.ReadWriteCloser) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user