Skip to content

Commit efb7d8a

Browse files
committed
Address PR feedback: restore removed comment, add _isSubscribed pre-lock check in CleanupAsync
1 parent 2c402d9 commit efb7d8a

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/Foundatio.Redis/Messaging/RedisMessageBus.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ private async Task OnMessage(ChannelMessage channelMessage)
128128
}
129129
catch (Exception ex)
130130
{
131+
// Catch any other unexpected exceptions for defensive purposes
131132
_logger.LogError(ex, "OnMessage({Channel}) Error in subscriber: {Message}", channelMessage.Channel, ex.Message);
132133
}
133134
}
@@ -165,6 +166,9 @@ await _subscriber.PublishAsync(_channel, data, CommandFlags.FireAndForget),
165166

166167
protected override async Task CleanupAsync()
167168
{
169+
if (!_isSubscribed)
170+
return;
171+
168172
using (await _lock.LockAsync().AnyContext())
169173
{
170174
if (_channelMessageQueue is not null)

0 commit comments

Comments
 (0)