-
Enhancement
-
Resolution: Done
-
Major
-
None
-
None
UNDERTOW-1099 fix introduced a different bug which results in listeners not being called.
private void decrementRequests() { if (shutdown) { //we don't read the request count until after checking the shutdown variable //otherwise we could read the request count as zero, a new request could state, and then we shutdown //see https://issues.jboss.org/browse/UNDERTOW-1099 long active = activeRequestsUpdater.decrementAndGet(this); synchronized (lock) { if (active == 0) { shutdownComplete(); } } } else { activeRequestsUpdater.decrementAndGet(this); } }
Thread T1 calls decrementRequests. Shutdown is false, so this thread will follow the 'else' path in preparation for decrementAndGet
Thread T2 calls shutdown. Increments from 1 to 2, sets shutdown=true, and calls decrementRequests where decrementAndGet results in 1
Thread T1 completes the decrementRequests invocation reducing the active request count to zero in the else path without calling shutdownComplete.
flaviarnn I don't have permissions to reopen this, would you prefer that I open a new ticket?
I would propose using a bit mask to represent both shutdownRequested and shutdownComplete to allow state changes within individual cas operations.
- is caused by
-
UNDERTOW-1099 Thread safety issue with GracefulShutdownHandler#decrementRequests
- Resolved