MCPcopy Create free account
hub / github.com/apache/thrift / alarm_handler

Function alarm_handler

lib/cpp/test/TransportTest.cpp:357–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355bool g_teardown = false;
356
357void alarm_handler() {
358 TriggerInfo* info = nullptr;
359 {
360 apache::thrift::concurrency::Synchronized s(g_alarm_monitor);
361 // The alarm timed out, which almost certainly means we're stuck
362 // on a transport that is incorrectly blocked.
363 ++g_numTriggersFired;
364
365 // Note: we print messages to stdout instead of stderr, since
366 // tools/test/runner only records stdout messages in the failure messages for
367 // boost tests. (boost prints its test info to stdout.)
368 printf("Timeout alarm expired; attempting to unblock transport\n");
369 if (g_triggerInfo == nullptr) {
370 printf(" trigger stack is empty!\n");
371 }
372
373 // Pop off the first TriggerInfo.
374 // If there is another one, schedule an alarm for it.
375 info = g_triggerInfo;
376 g_triggerInfo = info->next;
377 }
378
379 // Write some data to the transport to hopefully unblock it.
380 auto* buf = new uint8_t[info->writeLength];
381 memset(buf, 'b', info->writeLength);
382 std::unique_ptr<uint8_t[]> array(buf);
383 info->transport->write(buf, info->writeLength);
384 info->transport->flush();
385
386 delete info;
387}
388
389void alarm_handler_wrapper() {
390 int64_t timeout = 0; // timeout of 0 means wait forever

Callers 1

alarm_handler_wrapperFunction · 0.85

Calls 2

writeMethod · 0.65
flushMethod · 0.45

Tested by

no test coverage detected