| 560 | } |
| 561 | |
| 562 | void Master::CloseSession(const CloseSessionRequest* req, |
| 563 | CloseSessionResponse* resp, MyClosure done) { |
| 564 | MasterSession* session = nullptr; |
| 565 | { |
| 566 | mu_.lock(); |
| 567 | auto iter = sessions_.find(req->session_handle()); |
| 568 | if (iter == sessions_.end()) { |
| 569 | mu_.unlock(); |
| 570 | done(errors::Aborted( |
| 571 | "Session ", req->session_handle(), |
| 572 | " is not found. Possibly, this master has restarted.")); |
| 573 | return; |
| 574 | } |
| 575 | // NOTE(mrry): One reference to the session is transferred from |
| 576 | // `sessions_[req->session_handle()]` to `session`. |
| 577 | session = iter->second; |
| 578 | sessions_.erase(iter); |
| 579 | mu_.unlock(); |
| 580 | } |
| 581 | |
| 582 | // Session Close() blocks on thread shutdown. Therefore, we need to |
| 583 | // delete it in non-critical thread. |
| 584 | SchedClosure([session, done]() { |
| 585 | Status s = session->Close(); |
| 586 | session->Unref(); |
| 587 | done(s); |
| 588 | }); |
| 589 | } |
| 590 | |
| 591 | void Master::ListDevices(const ListDevicesRequest* req, |
| 592 | ListDevicesResponse* resp, MyClosure done) { |
nothing calls this directly
no test coverage detected