processEventsWhileBlocked not exception safe

Former-commit-id: 45b711f9d124a948a66e667992176b5387943512
This commit is contained in:
John Sully 2020-02-17 18:57:13 -05:00
parent 79e945f5e5
commit d90ebb9f85

View File

@ -3183,6 +3183,7 @@ void unpauseClientsIfNecessary()
*
* The function returns the total number of events processed. */
int processEventsWhileBlocked(int iel) {
serverAssert(GlobalLocksAcquired());
int iterations = 4; /* See the function top-comment. */
int count = 0;
@ -3194,12 +3195,25 @@ int processEventsWhileBlocked(int iel) {
}
aeReleaseLock();
serverAssertDebug(!GlobalLocksAcquired());
while (iterations--) {
int events = 0;
events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT);
events += handleClientsWithPendingWrites(iel);
if (!events) break;
count += events;
try
{
while (iterations--) {
int events = 0;
events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT);
events += handleClientsWithPendingWrites(iel);
if (!events) break;
count += events;
}
}
catch (...)
{
// Caller expects us to be locked so fix and rethrow
AeLocker locker;
if (c != nullptr)
c->lock.lock();
locker.arm(c);
locker.release();
throw;
}
AeLocker locker;
if (c != nullptr)