Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-61197

Canceling a session should await completion of its operations on the baton

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Won't Fix
    • None
    • None
    • Internal Code
    • ALL

    Description

      When ending a session (i.e., an instance of transport::Session), we should ensure it awaits completion of any inflight operations on the networking baton, and then safely removes itself from the baton. Currently, this is not the case:

      bool TransportLayerASIO::BatonASIO::cancelSession(Session& session) noexcept override {
          const auto id = session.id();
          stdx::unique_lock lk(_mutex);
          if (_sessions.find(id) == _sessions.end()) {
              return false;
          }
       
          _safeExecute(std::move(lk), [ id, this ](stdx::unique_lock<Mutex> lk) noexcept {
              auto iter = _sessions.find(id);
              if (iter == _sessions.end()) {
                  return;
              }
              auto session = std::exchange(iter->second, {});
              _sessions.erase(iter);
              lk.unlock();
       
              session.promise.setError(kCanceled);
          });
          return true;
      }
      

      Since the baton uses the reactor thread to poll on the sessions, we should ensure the baton is not running anything on behalf of the session before removing it.

      Attachments

        Issue Links

          Activity

            People

              backlog-server-servicearch Backlog - Service Architecture
              amirsaman.memaripour@mongodb.com Amirsaman Memaripour
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: