Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-1099

Thread safety issue with GracefulShutdownHandler#decrementRequests

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.4.16.Final
    • Fix Version/s: 2.0.0.Beta1, 1.4.17.Final
    • Component/s: None
    • Labels:
      None

      Description

      Given the GracefulShutdownHandler#decrementRequests function!

          private void decrementRequests() {
              long active = activeRequestsUpdater.decrementAndGet(this);
              // A
              if (shutdown) {
                  synchronized (lock) {
                      if (active == 0) {
                          shutdownComplete();
                      }
                  }
              }
          }
      

      A thread T1 is at A. During this instant:

      • A thread T2 handles a new request GracefulShutdownHandler#handleRequest
      • A thread T3 shutdown the handler GracefulShutdownHandler#shutdown() but after T2 has started to handle its request (ie. after the if (shutdown) condition.

      In this case even if there is an active request, T0 will call shutdownComplete()

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  swd847 Stuart Douglas
                  Reporter:
                  nlabrot Nicolas Labrot
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: