processEventsWhileBlocked not exception safe
Former-commit-id: 1ef187533c26bfa0c084a815b8b80de92ba1cf0b
This commit is contained in:
parent
4d01660331
commit
96c4f5ecfc
@ -3065,6 +3065,7 @@ void unpauseClientsIfNecessary()
|
|||||||
*
|
*
|
||||||
* The function returns the total number of events processed. */
|
* The function returns the total number of events processed. */
|
||||||
int processEventsWhileBlocked(int iel) {
|
int processEventsWhileBlocked(int iel) {
|
||||||
|
serverAssert(GlobalLocksAcquired());
|
||||||
int iterations = 4; /* See the function top-comment. */
|
int iterations = 4; /* See the function top-comment. */
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@ -3074,14 +3075,30 @@ int processEventsWhileBlocked(int iel) {
|
|||||||
serverAssert(c->flags & CLIENT_PROTECTED);
|
serverAssert(c->flags & CLIENT_PROTECTED);
|
||||||
c->lock.unlock();
|
c->lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
aeReleaseLock();
|
aeReleaseLock();
|
||||||
while (iterations--) {
|
serverAssertDebug(!GlobalLocksAcquired());
|
||||||
int events = 0;
|
try
|
||||||
events += aeProcessEvents(g_pserver->rgthreadvar[iel].el, AE_FILE_EVENTS|AE_DONT_WAIT);
|
{
|
||||||
events += handleClientsWithPendingWrites(iel);
|
while (iterations--) {
|
||||||
if (!events) break;
|
int events = 0;
|
||||||
count += events;
|
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;
|
AeLocker locker;
|
||||||
if (c != nullptr)
|
if (c != nullptr)
|
||||||
c->lock.lock();
|
c->lock.lock();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user