Commit 5098d3d4 authored by TousakaRin's avatar TousakaRin

In ScopedMethodStatus, use _controller->server() instead of _server.

parent e9c0b2c0
......@@ -132,7 +132,7 @@ ScopedMethodStatus::~ScopedMethodStatus() {
_status->OnResponded(_c->ErrorCode(), butil::cpuwide_time_us() - _start_parse_us);
_status = NULL;
}
ServerPrivateAccessor(_server).RemoveConcurrency(_c);
ServerPrivateAccessor(_c->server()).RemoveConcurrency(_c);
}
} // namespace brpc
......@@ -103,11 +103,9 @@ friend class ScopedMethodStatus;
class ScopedMethodStatus {
public:
ScopedMethodStatus(MethodStatus* status,
const Server* server,
Controller* c,
int64_t start_parse_us)
: _status(status)
, _server(server)
, _c(c)
, _start_parse_us(start_parse_us) {}
~ScopedMethodStatus();
......@@ -115,7 +113,6 @@ public:
private:
DISALLOW_COPY_AND_ASSIGN(ScopedMethodStatus);
MethodStatus* _status;
const Server* _server;
Controller* _c;
uint64_t _start_parse_us;
};
......
......@@ -147,8 +147,7 @@ void SendRpcResponse(int64_t correlation_id,
}
Socket* sock = accessor.get_sending_socket();
std::unique_ptr<Controller, LogErrorTextAndDelete> recycle_cntl(cntl);
ScopedMethodStatus method_status(method_status_raw, server,
cntl, received_us);
ScopedMethodStatus method_status(method_status_raw, cntl, received_us);
std::unique_ptr<const google::protobuf::Message> recycle_req(req);
std::unique_ptr<const google::protobuf::Message> recycle_res(res);
......
......@@ -558,8 +558,7 @@ static void SendHttpResponse(Controller *cntl,
span->set_start_send_us(butil::cpuwide_time_us());
}
std::unique_ptr<Controller, LogErrorTextAndDelete> recycle_cntl(cntl);
ScopedMethodStatus method_status(method_status_raw, server,
cntl, received_us);
ScopedMethodStatus method_status(method_status_raw,cntl, received_us);
std::unique_ptr<const google::protobuf::Message> recycle_req(req);
std::unique_ptr<const google::protobuf::Message> recycle_res(res);
Socket* socket = accessor.get_sending_socket();
......
......@@ -233,8 +233,7 @@ static void SendHuluResponse(int64_t correlation_id,
}
Socket* sock = accessor.get_sending_socket();
std::unique_ptr<HuluController, LogErrorTextAndDelete> recycle_cntl(cntl);
ScopedMethodStatus method_status(method_status_raw, server,
cntl, received_us);
ScopedMethodStatus method_status(method_status_raw, cntl, received_us);
std::unique_ptr<const google::protobuf::Message> recycle_req(req);
std::unique_ptr<const google::protobuf::Message> recycle_res(res);
......
......@@ -60,8 +60,7 @@ SendMongoResponse::~SendMongoResponse() {
void SendMongoResponse::Run() {
std::unique_ptr<SendMongoResponse> delete_self(this);
ScopedMethodStatus method_status(status, server,
&cntl, received_us);
ScopedMethodStatus method_status(status, &cntl, received_us);
Socket* socket = ControllerPrivateAccessor(&cntl).get_sending_socket();
if (cntl.IsCloseConnection()) {
......
......@@ -72,8 +72,7 @@ void NsheadClosure::Run() {
}
Socket* sock = accessor.get_sending_socket();
ScopedMethodStatus method_status(_server->options().nshead_service->_status,
_server, &_controller,
_received_us);
&_controller, _received_us);
if (!method_status) {
// Judge errors belongings.
// may not be accurate, but it does not matter too much.
......
......@@ -217,8 +217,7 @@ static void SendSofaResponse(int64_t correlation_id,
}
Socket* sock = accessor.get_sending_socket();
std::unique_ptr<Controller, LogErrorTextAndDelete> recycle_cntl(cntl);
ScopedMethodStatus method_status(method_status_raw, server,
cntl, received_us);
ScopedMethodStatus method_status(method_status_raw, cntl, received_us);
std::unique_ptr<const google::protobuf::Message> recycle_req(req);
std::unique_ptr<const google::protobuf::Message> recycle_res(res);
......
......@@ -225,7 +225,6 @@ void ThriftClosure::DoRun() {
// Recycle itself after `Run'
std::unique_ptr<ThriftClosure> recycle_ctx(this);
const Server* server = _controller.server();
ScopedRemoveConcurrency remove_concurrency_dummy(server, &_controller);
ControllerPrivateAccessor accessor(&_controller);
Span* span = accessor.span();
......@@ -236,7 +235,7 @@ void ThriftClosure::DoRun() {
ScopedMethodStatus method_status(
server->options().thrift_service ?
server->options().thrift_service->_status : NULL,
_server, &_controller, cpuwide_start_us());
&_controller, _received_us);
if (!method_status) {
// Judge errors belongings.
// may not be accurate, but it does not matter too much.
......@@ -350,10 +349,6 @@ void ThriftClosure::DoRun() {
// TODO: this is not sent
span->set_sent_us(butil::cpuwide_time_us());
}
if (method_status) {
method_status.release()->OnResponded(
!_controller.Failed(), butil::cpuwide_time_us() - _received_us);
}
}
ParseResult ParseThriftMessage(butil::IOBuf* source,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment