Release imap client only when the pool fails to provide one.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user