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

Method Pop

src/brpc/rpc_dump.cpp:322–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322SampledRequest* SampleIterator::Pop(butil::IOBuf& buf, bool* format_error) {
323 char backing_buf[12];
324 const char* p = (const char*)buf.fetch(backing_buf, sizeof(backing_buf));
325 if (NULL == p) { // buf.length() < sizeof(backing_buf)
326 return NULL;
327 }
328 if (*(const uint32_t*)p != *(const uint32_t*)"PRPC") {
329 LOG(ERROR) << "Unmatched magic string";
330 *format_error = true;
331 return NULL;
332 }
333 uint32_t body_size;
334 uint32_t meta_size;
335 butil::RawUnpacker(p + 4).unpack32(body_size).unpack32(meta_size);
336 if (body_size > FLAGS_max_body_size) {
337 LOG(ERROR) << "Too big body=" << body_size;
338 *format_error = true;
339 return NULL;
340 } else if (buf.length() < sizeof(backing_buf) + body_size) {
341 return NULL;
342 }
343 if (meta_size > body_size) {
344 LOG(ERROR) << "meta_size=" << meta_size << " is bigger than body_size="
345 << body_size;
346 *format_error = true;
347 return NULL;
348 }
349 buf.pop_front(sizeof(backing_buf));
350 butil::IOBuf meta_buf;
351 buf.cutn(&meta_buf, meta_size);
352 std::unique_ptr<SampledRequest> req(new SampledRequest);
353 if (!ParsePbFromIOBuf(&req->meta, meta_buf)) {
354 LOG(ERROR) << "Fail to parse RpcDumpMeta";
355 *format_error = true;
356 return NULL;
357 }
358 buf.cutn(&req->request, body_size - meta_size);
359 return req.release();
360}
361
362#undef DUMPED_FILE_PREFIX
363

Callers

nothing calls this directly

Calls 7

RawUnpackerClass · 0.85
ParsePbFromIOBufFunction · 0.85
fetchMethod · 0.80
lengthMethod · 0.45
pop_frontMethod · 0.45
cutnMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected