From 1659d74938ea984a6fa81ea4d91c587095fb16ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Burak=20Kaan=20K=C3=B6se?= Date: Fri, 21 Jun 2024 00:32:45 +0200 Subject: [PATCH] Release imap client only when the pool fails to provide one. --- Wino.Core/Synchronizers/ImapSynchronizer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Wino.Core/Synchronizers/ImapSynchronizer.cs b/Wino.Core/Synchronizers/ImapSynchronizer.cs index bf74d266..4e8fc5eb 100644 --- a/Wino.Core/Synchronizers/ImapSynchronizer.cs +++ b/Wino.Core/Synchronizers/ImapSynchronizer.cs @@ -456,6 +456,8 @@ namespace Wino.Core.Synchronizers ImapClient executorClient = null; + bool isCrashed = false; + try { executorClient = await _clientPool.GetClientAsync(); @@ -467,11 +469,13 @@ namespace Wino.Core.Synchronizers item.Request.RevertUIChanges(); + isCrashed = true; throw; } finally { - if (executorClient != null) + // Make sure that the client is released from the pool for next usages if error occurs. + if (isCrashed && executorClient != null) { _clientPool.Release(executorClient); }