Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-3891

TNonblockingServer configured with more than one IO threads does not always return from serve() upon stop()

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.9.3
    • Fix Version/s: 0.11.0
    • Component/s: C++ - Library
    • Labels:
      None

      Description

      Using TNonblockingServer, when the number of IO threads is > 1, there is race condition in which stop() does not properly unblock serve().

      The problem manifests itself when stop() is called (obviously from a different thread) soon after serve().

      The core issue is that, event_base_loopbreak() is called within the stop() sequence without checking whether the IO thread has actually entered its event loop. The documentation of event_base_loopbreak() says (http://www.wangafu.net/~nickm/libevent-book/Ref3_eventloop.html)

      Note also that event_base_loopexit(base,NULL) and event_base_loopbreak(base) act differently when no event loop is running: loopexit schedules the next instance of the event loop to stop right after the next round of callbacks are run (as if it had been invoked with EVLOOP_ONCE) whereas loopbreak only stops a currently running loop, and has no effect if the event loop isn’t running.

      Attached is a patch (against the released 0.9.3 version of the codebase).

        Attachments

        1. patch.diff
          4 kB
          Buğra Gedik

          Activity

            People

            • Assignee:
              jking3 James E. King III
              Reporter:
              bgedik Buğra Gedik
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: