Skip to content

Commit

Permalink
Dont wait on a disconnected follower
Browse files Browse the repository at this point in the history
There is no need to wait for a disconnected follower to be synced.
  • Loading branch information
spuun committed Dec 11, 2024
1 parent 256e916 commit 5c12a40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lavinmq/clustering/follower.cr
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module LavinMQ
def close(timeout : Time::Span = 30.seconds)
@closed = true
@actions.close
return if @socket.closed?
if lag_in_bytes > 0
Log.info { "Waiting for follower to be in sync" }
select
Expand Down
4 changes: 4 additions & 0 deletions src/lavinmq/clustering/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@ module LavinMQ
end
rescue ex : AuthenticationError
Log.warn { "Follower negotiation error" }
socket.close
rescue ex : InvalidStartHeaderError
Log.warn { ex.message }
socket.close
rescue ex : IO::EOFError
Log.info { "Follower disconnected" }
socket.close
rescue ex : IO::Error
Log.warn { "Follower disonnected: #{ex.message}" }
socket.close
ensure
follower.try &.close
end
Expand Down

0 comments on commit 5c12a40

Please sign in to comment.