Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions src/brpc/policy/thrift_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ ReadThriftMessageBegin(butil::IOBuf* body,
uint32_t version_and_len_buf[2];
size_t k = body->copy_to(version_and_len_buf, sizeof(version_and_len_buf));
if (k != sizeof(version_and_len_buf) ) {
return butil::Status(-1, "Fail to copy %" PRIu64 " bytes from body",
return butil::Status(-1, "Fail to copy %zu bytes from body",
sizeof(version_and_len_buf));
}
*mtype = (apache::thrift::protocol::TMessageType)
Expand All @@ -95,7 +95,7 @@ ReadThriftMessageBegin(butil::IOBuf* body,
char buf[sizeof(version_and_len_buf) + method_name_length + 4];
k = body->cutn(buf, sizeof(buf));
if (k != sizeof(buf)) {
return butil::Status(-1, "Fail to cut %" PRIu64 " bytes", sizeof(buf));
return butil::Status(-1, "Fail to cut %zu bytes", sizeof(buf));
}
method_name->assign(buf + sizeof(version_and_len_buf), method_name_length);
// suppress strict-aliasing warning
Expand All @@ -120,7 +120,7 @@ WriteThriftMessageBegin(char* buf,
p += 4;
memcpy(p, method_name.data(), method_name.size());
p += method_name.size();
*p = htonl(seq_id);
*(uint32_t*)p = htonl(seq_id);
}

bool ReadThriftStruct(const butil::IOBuf& body,
Expand Down Expand Up @@ -163,6 +163,7 @@ bool ReadThriftStruct(const butil::IOBuf& body,
}

xfer += iprot.readStructEnd();
(void)xfer;
iprot.getTransport()->readEnd();
} catch (std::exception& e) {
LOG(WARNING) << "Catched thrift exception: " << e.what();
Expand Down Expand Up @@ -247,7 +248,7 @@ void ThriftClosure::DoRun() {
span->set_start_send_us(butil::cpuwide_time_us());
}
Socket* sock = accessor.get_sending_socket();
MethodStatus* method_status = (server->options().thrift_service ?
MethodStatus* method_status = (server->options().thrift_service ?
server->options().thrift_service->_status : NULL);
ConcurrencyRemover concurrency_remover(method_status, &_controller, _received_us);
if (!method_status) {
Expand Down Expand Up @@ -321,6 +322,7 @@ void ThriftClosure::DoRun() {
xfer += oprot.writeFieldEnd();
xfer += oprot.writeFieldStop();
xfer += oprot.writeStructEnd();
(void)xfer;

oprot.writeMessageEnd();
oprot.getTransport()->writeEnd();
Expand All @@ -343,7 +345,7 @@ void ThriftClosure::DoRun() {
write_buf.append(buf, sizeof(buf));
write_buf.append(_response.body.movable());
}

if (span) {
span->set_response_size(write_buf.size());
}
Expand Down Expand Up @@ -395,11 +397,9 @@ ParseResult ParseThriftMessage(butil::IOBuf* source,
return MakeMessage(msg);
}

inline void ProcessThriftFramedRequestNoExcept(ThriftService* service,
Controller* cntl,
ThriftFramedMessage* req,
ThriftFramedMessage* res,
ThriftClosure* done) {
inline void ProcessThriftFramedRequestNoExcept(ThriftService* service, Controller* cntl,
ThriftFramedMessage* req, ThriftFramedMessage* res,
ThriftClosure* done) {
// NOTE: done is not actually run before ResumeRunning() is called so that
// we can still set `cntl' in the catch branch.
done->SuspendRunning();
Expand Down Expand Up @@ -452,7 +452,7 @@ static void EndRunningCallMethodInPool(ThriftService* service,
};

void ProcessThriftRequest(InputMessageBase* msg_base) {
const int64_t start_parse_us = butil::cpuwide_time_us();
const int64_t start_parse_us = butil::cpuwide_time_us();

DestroyingPtr<MostCommonMessage> msg(static_cast<MostCommonMessage*>(msg_base));
SocketUniquePtr socket_guard(msg->ReleaseSocket());
Expand Down Expand Up @@ -623,7 +623,7 @@ void ProcessThriftResponse(InputMessageBase* msg_base) {
}

// Read presult

// MUST be ThriftFramedMessage (checked in SerializeThriftRequest)
ThriftFramedMessage* response = (ThriftFramedMessage*)cntl->response();
if (response) {
Expand Down Expand Up @@ -705,10 +705,11 @@ void SerializeThriftRequest(butil::IOBuf* request_buf, Controller* cntl,

// request's write
xfer += req->raw_instance()->Write(&oprot);

xfer += oprot.writeFieldEnd();
xfer += oprot.writeFieldStop();
xfer += oprot.writeStructEnd();
(void)xfer;

oprot.writeMessageEnd();
oprot.getTransport()->writeEnd();
Expand Down
Loading