Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,16 @@ private boolean resume(final Runnable handler) {
stateLock.readLock().unlock();
}
stateLock.writeLock().lock();
state = RESUMED;
stateLock.writeLock().unlock();
try {
// Re-check under write lock: another thread may have changed state
// between releasing the read lock and acquiring the write lock.
if (state != SUSPENDED) {
return false;
}
state = RESUMED;
} finally {
stateLock.writeLock().unlock();
}

try {
responder.runtime.requestScope.runInScope(requestContext, handler);
Expand Down Expand Up @@ -1019,9 +1027,20 @@ private boolean cancel(final Value<Response> responseValue) {
}

stateLock.writeLock().lock();
state = RESUMED;
cancelled = true;
stateLock.writeLock().unlock();
try {
// Re-check under write lock: another thread may have changed state
// between releasing the read lock and acquiring the write lock.
if (cancelled) {
return true;
}
if (state != SUSPENDED) {
return false;
}
state = RESUMED;
cancelled = true;
} finally {
stateLock.writeLock().unlock();
}

responder.runtime.requestScope.runInScope(requestContext, new Runnable() {
@Override
Expand Down