Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-1019

SslHandler flushScheduledEvents race condition

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.0.9
    • 2.0.13
    • SSL
    • None

    Description

      From what I've seen, the SslFilter class schedules events onto the SslHandler and then flushes them via the SslHandler.flushScheduledEvents() method.

      Within SslHandler.flushScheduledEvents() the lock can only be accumulated by a single thread, and all other threads that try to accumulate the lock instead follow through and not block waiting to get the lock.

      ...
      if (sslLock.tryLock()) {
      ...

      This leads to the race condition where a thread may call SslHandler.scheduleFilterWrite() followed by SslHandler.flushScheduledEvents() while another thread holds the sslLock and has finished dequeuing the SslHandler.filterWriteEventQueue and is currently dequeuing the SslHandler.messageReceivedEventQueue.

      I've actually hit this race condition quite a few times today and have added in a small fix which essentially tracks the number of times SslHandler.flushScheduledEvents() has been called. There's probably a much better solution but yeah just letting you guys know what I've found.

      Thanks,
      Terence

      Attachments

        1. SslFilterTest.java
          4 kB
          Terence Marks
        2. fix.java
          1 kB
          Terence Marks

        Activity

          People

            Unassigned Unassigned
            tezm Terence Marks
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: