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

Thread safety issue with GracefulShutdownHandler#decrementRequests

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.0.0.Beta1, 1.4.17.Final
    • 1.4.16.Final
    • None
    • 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()

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: