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

Thread safety issue with GracefulShutdownHandler#decrementRequests

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.0.0.Beta1, 1.4.17.Final
    • 1.4.16.Final
    • None
    • None

      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()

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              nlabrot Nicolas Labrot (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: