Synchronize _runningSessionCount update with waitForRunningSessions

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Optimization
    • Fully Compatible
    • ALL
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The way _runningSessionCount is updated here permits a concurrent call to waitForRunningSessions to observe _runningSessionCount == 0 before the last thread has called notify().

      Then, the SessionHandler may be destroyed, making the notify() call unsafe.

      To prevent this, _notificationMutex should be acquired for the duration of the decrement and notify call.

      A concurrent waitForRunningSessions call will then either:

      • Block on the lock, then correctly observe sessions == 0 once the dying thread releases the lock and it is safe to destroy the session handler.
      • Acquire the lock, observe sessions == 1, wait on CV (releases the lock), wake when dying thread calls notify, re-acquire lock, observe sessions == 0.

            Assignee:
            James Harrison
            Reporter:
            Max Verbinnen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: