ing
This commit is contained in:
parent
63fd249b1b
commit
33c01a5e3c
|
@ -29,16 +29,11 @@ func (crw *ClientReadWriter) HandleConnection(conn *Conn) {
|
|||
|
||||
logging.Logger().Infof("connected")
|
||||
|
||||
stopChan := make(chan struct{})
|
||||
|
||||
readerDoneChan := make(chan error)
|
||||
writerDoneChan := make(chan error)
|
||||
|
||||
var err error
|
||||
|
||||
for {
|
||||
if nil != err {
|
||||
if io.EOF == err || io.ErrUnexpectedEOF == err {
|
||||
if IsUnexpectedCloseError(err) || io.EOF == err || io.ErrUnexpectedEOF == err {
|
||||
crw.DisconnectedChan <- struct{}{}
|
||||
newConn := <-crw.ReconnectedChan
|
||||
if nil == newConn {
|
||||
|
@ -50,6 +45,11 @@ func (crw *ClientReadWriter) HandleConnection(conn *Conn) {
|
|||
}
|
||||
}
|
||||
|
||||
stopChan := make(chan struct{})
|
||||
|
||||
readerDoneChan := make(chan error)
|
||||
writerDoneChan := make(chan error)
|
||||
|
||||
go connReadHandler(crw.ReadwriteHandler, conn, stopChan, readerDoneChan, crw.ReadChan)
|
||||
go connWriteHandler(crw.ReadwriteHandler, conn, stopChan, writerDoneChan, crw.WriteChan)
|
||||
|
||||
|
|
|
@ -107,14 +107,20 @@ RC_LOOP:
|
|||
continue RC_LOOP
|
||||
}
|
||||
|
||||
logging.Logger().Debugf("connection lost")
|
||||
|
||||
for indexI := 0; indexI < c.ReconnectTryTime; indexI++ {
|
||||
logging.Logger().Debugf("trying reconnect[%d]", indexI)
|
||||
|
||||
conn, err := c.connect()
|
||||
if nil == err {
|
||||
logging.Logger().Debugf("reconnected")
|
||||
c.reconnectedChan <- conn
|
||||
continue RC_LOOP
|
||||
}
|
||||
time.Sleep(c.ReconnectInterval)
|
||||
}
|
||||
logging.Logger().Debugf("reconnecting has been failed")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user