| 177 | } |
| 178 | |
| 179 | void InboundCall::SerializeResponseBuffer(const MessageLite& response, |
| 180 | bool is_success) { |
| 181 | if (PREDICT_FALSE(!response.IsInitialized())) { |
| 182 | LOG(ERROR) << "Invalid RPC response for " << ToString() |
| 183 | << ": protobuf missing required fields: " |
| 184 | << response.InitializationErrorString(); |
| 185 | // Send it along anyway -- the client will also notice the missing fields |
| 186 | // and produce an error on the other side, but this will at least |
| 187 | // make it clear on both sides of the RPC connection what kind of error |
| 188 | // happened. |
| 189 | } |
| 190 | |
| 191 | size_t protobuf_msg_size = response.ByteSizeLong(); |
| 192 | CHECK_LE(protobuf_msg_size, std::numeric_limits<uint32_t>::max()); |
| 193 | |
| 194 | ResponseHeader resp_hdr; |
| 195 | resp_hdr.set_call_id(header_.call_id()); |
| 196 | resp_hdr.set_is_error(!is_success); |
| 197 | int32_t sidecar_byte_size = 0; |
| 198 | for (const unique_ptr<RpcSidecar>& car : outbound_sidecars_) { |
| 199 | resp_hdr.add_sidecar_offsets(sidecar_byte_size + protobuf_msg_size); |
| 200 | size_t sidecar_bytes = car->TotalSize(); |
| 201 | DCHECK_LE(sidecar_byte_size, TransferLimits::kMaxTotalSidecarBytes - sidecar_bytes); |
| 202 | sidecar_byte_size += sidecar_bytes; |
| 203 | } |
| 204 | |
| 205 | serialization::SerializeMessage(response, &response_msg_buf_, |
| 206 | sidecar_byte_size, true); |
| 207 | int64_t main_msg_size = sidecar_byte_size + response_msg_buf_.size(); |
| 208 | serialization::SerializeHeader(resp_hdr, main_msg_size, |
| 209 | &response_hdr_buf_); |
| 210 | } |
| 211 | |
| 212 | void InboundCall::SerializeResponseTo(TransferPayload* slices) const { |
| 213 | TRACE_EVENT0("rpc", "InboundCall::SerializeResponseTo"); |
nothing calls this directly
no test coverage detected