| 70 | } |
| 71 | |
| 72 | void SendNsheadPbResponse::Run() { |
| 73 | MethodStatus* saved_status = status; |
| 74 | const int64_t received_us = done->received_us(); |
| 75 | if (!cntl->IsCloseConnection()) { |
| 76 | adaptor->SerializeResponseToIOBuf(meta, cntl, pbres.get(), ns_res); |
| 77 | } |
| 78 | |
| 79 | const bool saved_failed = cntl->Failed(); |
| 80 | NsheadClosure* saved_done = done; |
| 81 | // The space is allocated by NsheadClosure, don't delete. |
| 82 | this->~SendNsheadPbResponse(); |
| 83 | |
| 84 | // NOTE: *this was destructed, don't touch anything. |
| 85 | |
| 86 | // FIXME(gejun): We can't put this after saved_done->Run() where the |
| 87 | // service containing saved_status may be destructed (upon server's |
| 88 | // quiting). Thus the latency does not include the time of sending |
| 89 | // back response. |
| 90 | if (saved_status) { |
| 91 | saved_status->OnResponded( |
| 92 | !saved_failed, butil::cpuwide_time_us() - received_us); |
| 93 | } |
| 94 | saved_done->Run(); |
| 95 | } |
| 96 | |
| 97 | void NsheadPbServiceAdaptor::ProcessNsheadRequest( |
| 98 | const Server& server, Controller* controller, |
no test coverage detected