MCPcopy Create free account
hub / github.com/apache/brpc / OnPing

Method OnPing

src/brpc/policy/http2_rpc_protocol.cpp:930–952  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

928}
929
930H2ParseResult H2Context::OnPing(
931 butil::IOBufBytesIterator& it, const H2FrameHead& frame_head) {
932 if (frame_head.payload_size != 8) {
933 LOG(ERROR) << "Invalid payload_size=" << frame_head.payload_size;
934 return MakeH2Error(H2_FRAME_SIZE_ERROR);
935 }
936 if (frame_head.stream_id != 0) {
937 LOG(ERROR) << "Invalid stream_id=" << frame_head.stream_id;
938 return MakeH2Error(H2_PROTOCOL_ERROR);
939 }
940 if (frame_head.flags & H2_FLAGS_ACK) {
941 return MakeH2Message(NULL);
942 }
943
944 char pongbuf[FRAME_HEAD_SIZE + 8];
945 SerializeFrameHead(pongbuf, 8, H2_FRAME_PING, H2_FLAGS_ACK, 0);
946 it.copy_and_forward(pongbuf + FRAME_HEAD_SIZE, 8);
947 if (WriteAck(_socket, pongbuf, sizeof(pongbuf)) != 0) {
948 LOG(WARNING) << "Fail to send ack of PING to " << *_socket;
949 return MakeH2Error(H2_PROTOCOL_ERROR);
950 }
951 return MakeH2Message(NULL);
952}
953
954static void* ProcessHttpResponseWrapper(void* void_arg) {
955 ProcessHttpResponse(static_cast<InputMessageBase*>(void_arg));

Callers

nothing calls this directly

Calls 5

MakeH2ErrorFunction · 0.85
MakeH2MessageFunction · 0.85
SerializeFrameHeadFunction · 0.85
WriteAckFunction · 0.85
copy_and_forwardMethod · 0.80

Tested by

no test coverage detected