Skip to content

Commit

Permalink
Allow for disabling of auth timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Geoff Bourne committed Mar 22, 2017
1 parent e5b3672 commit 256cd88
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions poller/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ func NewSession(ctx context.Context, connection Connection, checksReconciler Che
func (s *EleSession) Auth() {
request := protocol.NewHandshakeRequest(s.cfg)
s.Send(request)
s.authTimer = time.AfterFunc(s.cfg.TimeoutAuth, func() {
log.WithField("prefix", s.logPrefix).Warn("Closing connection due to expired auth")
s.connection.Close()
s.EmitEvent(utils.NewEvent(EventTypeAuthTimeout, nil))
})
if s.cfg.TimeoutAuth > 0 {
s.authTimer = time.AfterFunc(s.cfg.TimeoutAuth, func() {
log.WithField("prefix", s.logPrefix).Warn("Closing connection due to expired auth")
s.connection.Close()
s.EmitEvent(utils.NewEvent(EventTypeAuthTimeout, nil))
})
}
}

// Send stages a frame for sending after setting the target and source.
Expand Down Expand Up @@ -169,7 +171,10 @@ func (s *EleSession) handleResponse(resp *protocol.FrameMsg) error {
if req := s.getCompletionRequest(resp); req != nil {
switch req.Method {
case protocol.MethodHandshakeHello:
s.authTimer.Stop()
if s.authTimer != nil {
s.authTimer.Stop()
s.authTimer = nil
}
resp := protocol.DecodeHandshakeResponse(resp)
if resp.Error != nil {
log.WithFields(log.Fields{
Expand Down

0 comments on commit 256cd88

Please sign in to comment.