Skip to content

Commit

Permalink
only handle ping when next state is ping
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Oct 2, 2023
1 parent 87814f2 commit e87b140
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmds/liter-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ func handler(c *liter.Conn){
var conn *liter.Conn
if conn, err = liter.Dial(svr.Target); err != nil {
ploger.Errorf("Cannot dial to %q: %v", svr.Target, err)
ploger.Debugf("Handle ping connection for server %q", svr.Id)
handleServerStatus(ploger, c, "Closed", svr.MotdFailed)
if hp.NextState == liter.NextPingState {
ploger.Debugf("Handle ping connection for server %q", svr.Id)
handleServerStatus(ploger, c, "Closed", svr.MotdFailed)
}
return
}
ploger.Debugf("Target %q connected", svr.Id)
Expand All @@ -339,8 +341,10 @@ func handler(c *liter.Conn){
// try read to ensure the connection is ok
if n, err := cr.Read(buf); err != nil {
ploger.Errorf("First read failed for %q: %v", svr.Target, err)
ploger.Debugf("Handle ping connection for server %q", svr.Id)
handleServerStatus(ploger, c, "Closed", svr.MotdFailed)
if hp.NextState == liter.NextPingState {
ploger.Debugf("Handle ping connection for server %q", svr.Id)
handleServerStatus(ploger, c, "Closed", svr.MotdFailed)
}
return
}else if _, err = rc.Write(buf[:n]); err != nil {
ploger.Errorf("First write failed: %v", err)
Expand Down

0 comments on commit e87b140

Please sign in to comment.