1
0
Fork 0
mirror of https://github.com/eosswedenorg/thalos synced 2026-06-17 04:30:03 +02:00

main.go: in readerLoop() bail out of function if error returned from shClient.Read is "socket closed".

This commit is contained in:
Henrik Hautakoski 2022-11-29 16:46:34 +01:00
parent 7a24e9d684
commit 433b23b77b

11
main.go
View file

@ -78,14 +78,21 @@ func readerLoop() {
case RS_READ:
err := shClient.Read()
if err != nil {
log.WithError(err).Error("Failed to read from ship")
if shErr, ok := err.(shipclient.ShipClientError); ok {
// Bail out if socket is closed
if shErr.Type == shipclient.ErrSockClosed {
log.Info("Socket closed, Exiting")
return
}
// Reconnect
if shErr.Type == shipclient.ErrSockRead || shErr.Type == shipclient.ErrNotConnected {
state = RS_CONNECT
}
}
log.WithError(err).Error("Failed to read from ship")
}
}
}