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

Method Next

src/brpc/rpc_dump.cpp:275–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

273}
274
275SampledRequest* SampleIterator::Next() {
276 if (!_cur_buf.empty()) {
277 bool error = false;
278 SampledRequest* r = Pop(_cur_buf, &error);
279 if (r) {
280 return r;
281 }
282 if (error) {
283 _cur_buf.clear();
284 if (_cur_fd >= 0) {
285 ::close(_cur_fd);
286 _cur_fd = -1;
287 }
288 }
289 }
290 while (1) {
291 while (_cur_fd >= 0) {
292 ssize_t nr = _cur_buf.append_from_file_descriptor(_cur_fd, 524288);
293 if (nr < 0) {
294 if (errno != EAGAIN && errno != EINTR) {
295 PLOG(ERROR) << "Fail to read fd=" << _cur_fd;
296 break;
297 }
298 } else if (nr == 0) { // EOF
299 break;
300 } else {
301 return Next(); // tailr
302 }
303 }
304 _cur_buf.clear();
305 if (_cur_fd >= 0) {
306 ::close(_cur_fd);
307 _cur_fd = -1;
308 }
309
310 if (_enum == NULL) {
311 _enum = new butil::FileEnumerator(
312 _dir, false, butil::FileEnumerator::FILES);
313 }
314 butil::FilePath filename = _enum->Next();
315 if (filename.empty()) {
316 return NULL;
317 }
318 _cur_fd = open(filename.value().c_str(), O_RDONLY);
319 }
320}
321
322SampledRequest* SampleIterator::Pop(butil::IOBuf& buf, bool* format_error) {
323 char backing_buf[12];

Callers 15

cutnMethod · 0.45
check_emptinessMethod · 0.45
putnMethod · 0.45
put_u8Method · 0.45
OpenMethod · 0.45
RemoveSpansBeforeMethod · 0.45
FindSpansFunction · 0.45
GzipCompressFunction · 0.45
GzipDecompressBaseFunction · 0.45
Crc32cComputeFunction · 0.45
Crc32cVerifyFunction · 0.45

Calls 5

emptyMethod · 0.45
clearMethod · 0.45
c_strMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected