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

Function hc_callback_thread

lib/sam.c:1400–1460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1398}
1399
1400static void *hc_callback_thread (void *unused_param)
1401{
1402 int poll_error;
1403 int status;
1404 ssize_t bytes_readed;
1405 char command;
1406 int time_interval, tmp_time_interval;
1407 int counter;
1408 struct pollfd pfds;
1409
1410 status = 0;
1411 counter = 0;
1412
1413 time_interval = sam_internal_data.time_interval >> 2;
1414
1415 while (1) {
1416 pfds.fd = sam_internal_data.cb_rpipe_fd;
1417 pfds.events = POLLIN;
1418 pfds.revents = 0;
1419
1420 if (status == 1) {
1421 tmp_time_interval = time_interval;
1422 } else {
1423 tmp_time_interval = -1;
1424 }
1425
1426 poll_error = poll (&pfds, 1, tmp_time_interval);
1427
1428 if (poll_error == 0) {
1429 if (sam_hc_send () == CS_OK) {
1430 counter++;
1431 }
1432
1433 if (counter >= 4) {
1434 if (sam_internal_data.hc_callback () != 0) {
1435 status = 3;
1436 }
1437
1438 counter = 0;
1439 }
1440 }
1441
1442 if (poll_error > 0) {
1443 bytes_readed = sam_safe_read (sam_internal_data.cb_rpipe_fd, &command, 1);
1444
1445 if (bytes_readed > 0) {
1446 if (status == 0 && command == SAM_COMMAND_START)
1447 status = 1;
1448
1449 if (status == 1 && command == SAM_COMMAND_STOP)
1450 status = 0;
1451
1452 }
1453 }
1454 }
1455
1456 /*
1457 * This makes compiler happy, it's same as return (NULL);

Callers

nothing calls this directly

Calls 2

sam_hc_sendFunction · 0.85
sam_safe_readFunction · 0.85

Tested by

no test coverage detected