MCPcopy Create free account
hub / github.com/corosync/corosync / cpg_test

Function cpg_test

test/cpghum.c:435–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

433}
434
435static int cpg_test (
436 cpg_handle_t handle_in,
437 int write_size,
438 int delay_time,
439 int print_time)
440{
441 struct iovec iov;
442 unsigned int res;
443
444 alarm_notice = 0;
445 iov.iov_base = data;
446 iov.iov_len = write_size;
447
448 g_recv_count = 0;
449 alarm (print_time);
450
451 do {
452 send_counter++;
453 resend:
454 set_packet(write_size, send_counter);
455
456 res = cpg_mcast_joined (handle_in, CPG_TYPE_AGREED, &iov, 1);
457 if (res == CS_ERR_TRY_AGAIN) {
458 usleep(10000);
459 send_retries++;
460 goto resend;
461 }
462 if (res == CS_ERR_LIBRARY) {
463 send_counter--;
464 return -1;
465 }
466 if (res != CS_OK) {
467 cpgh_log_printf(CPGH_LOG_ERR, "send failed: %d\n", res);
468 send_fails++;
469 }
470 else {
471 packets_sent++;
472 }
473 usleep(delay_time*1000);
474 } while (alarm_notice == 0 && (res == CS_OK || res == CS_ERR_TRY_AGAIN) && stopped == 0);
475
476 if (!quiet) {
477 if (machine_readable) {
478 cpgh_log_printf(CPGH_LOG_RTT, "%d%c%ld%c%ld%c%ld\n", 0, delimiter, min_rtt, delimiter, avg_rtt, delimiter, max_rtt);
479 }
480 else {
481 cpgh_log_printf(CPGH_LOG_PERF, "%s: %5d message%s received, ", group_name.value, g_recv_count, g_recv_count==1?"":"s");
482 cpgh_log_printf(CPGH_LOG_PERF, "%5d bytes per write. ", write_size);
483 cpgh_log_printf(CPGH_LOG_RTT, "RTT min/avg/max: %ld/%ld/%ld\n", min_rtt, avg_rtt, max_rtt);
484 }
485 }
486 return 0;
487}
488
489static void sigalrm_handler (int num)
490{

Callers 1

mainFunction · 0.85

Calls 3

set_packetFunction · 0.85
cpg_mcast_joinedFunction · 0.85
cpgh_log_printfFunction · 0.85

Tested by

no test coverage detected