| 54 | } |
| 55 | |
| 56 | Status SendFramedMessageBlocking(Socket* sock, const MessageLite& header, const MessageLite& msg, |
| 57 | const MonoTime& deadline) { |
| 58 | DCHECK(sock != nullptr); |
| 59 | DCHECK(header.IsInitialized()) << "header protobuf must be initialized"; |
| 60 | DCHECK(msg.IsInitialized()) << "msg protobuf must be initialized"; |
| 61 | |
| 62 | // Ensure we are in blocking mode. |
| 63 | // These blocking calls are typically not in the fast path, so doing this for all build types. |
| 64 | RETURN_NOT_OK(CheckInBlockingMode(sock)); |
| 65 | |
| 66 | // Serialize message |
| 67 | faststring param_buf; |
| 68 | serialization::SerializeMessage(msg, ¶m_buf); |
| 69 | |
| 70 | // Serialize header and initial length |
| 71 | faststring header_buf; |
| 72 | serialization::SerializeHeader(header, param_buf.size(), &header_buf); |
| 73 | |
| 74 | // Write header & param to stream |
| 75 | size_t nsent; |
| 76 | RETURN_NOT_OK(sock->BlockingWrite(header_buf.data(), header_buf.size(), &nsent, deadline)); |
| 77 | RETURN_NOT_OK(sock->BlockingWrite(param_buf.data(), param_buf.size(), &nsent, deadline)); |
| 78 | |
| 79 | return Status::OK(); |
| 80 | } |
| 81 | |
| 82 | Status ReceiveFramedMessageBlocking(Socket* sock, faststring* recv_buf, |
| 83 | MessageLite* header, Slice* param_buf, const MonoTime& deadline) { |
no test coverage detected