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

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

    • Service Arch
    • ALL

      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.

            Assignee:
            backlog-server-servicearch [DO NOT USE] Backlog - Service Architecture
            Reporter:
            amirsaman.memaripour@mongodb.com Amirsaman Memaripour
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: