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;
|
ImapClient executorClient = null;
|
||||||
|
|
||||||
|
bool isCrashed = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
executorClient = await _clientPool.GetClientAsync();
|
executorClient = await _clientPool.GetClientAsync();
|
||||||
@@ -467,11 +469,13 @@ namespace Wino.Core.Synchronizers
|
|||||||
|
|
||||||
item.Request.RevertUIChanges();
|
item.Request.RevertUIChanges();
|
||||||
|
|
||||||
|
isCrashed = true;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
finally
|
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);
|
_clientPool.Release(executorClient);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user