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

Function sam_parent_handler

lib/sam.c:1095–1257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093}
1094
1095static enum sam_parent_action_t sam_parent_handler (
1096 int parent_fd_in,
1097 int parent_fd_out,
1098 pid_t child_pid)
1099{
1100 int poll_error;
1101 int action;
1102 int status;
1103 ssize_t bytes_read;
1104 char command;
1105 int time_interval;
1106 struct pollfd pfds[2];
1107 nfds_t nfds;
1108 cs_error_t err;
1109 sam_recovery_policy_t recpol;
1110
1111 status = 0;
1112
1113 action = SAM_PARENT_ACTION_CONTINUE;
1114 recpol = sam_internal_data.recovery_policy;
1115
1116 while (action == SAM_PARENT_ACTION_CONTINUE) {
1117 pfds[0].fd = parent_fd_in;
1118 pfds[0].events = POLLIN;
1119 pfds[0].revents = 0;
1120 nfds = 1;
1121
1122 if (status == 1 && sam_internal_data.time_interval != 0) {
1123 time_interval = sam_internal_data.time_interval;
1124 } else {
1125 time_interval = -1;
1126 }
1127
1128 if (recpol & SAM_RECOVERY_POLICY_QUORUM) {
1129 pfds[nfds].fd = sam_internal_data.quorum_fd;
1130 pfds[nfds].events = POLLIN;
1131 pfds[nfds].revents = 0;
1132 nfds++;
1133 }
1134
1135 poll_error = poll (pfds, nfds, time_interval);
1136
1137 if (poll_error == -1) {
1138 /*
1139 * Error in poll
1140 * If it is EINTR, continue, otherwise QUIT
1141 */
1142 if (errno != EINTR) {
1143 action = SAM_PARENT_ACTION_ERROR;
1144 }
1145 }
1146
1147 if (poll_error == 0) {
1148 /*
1149 * Time limit expires
1150 */
1151 if (status == 0) {
1152 action = SAM_PARENT_ACTION_QUIT;

Callers 1

sam_registerFunction · 0.85

Calls 9

sam_parent_kill_childFunction · 0.85
sam_safe_readFunction · 0.85
sam_cmap_update_keyFunction · 0.85
sam_parent_data_storeFunction · 0.85
quorum_dispatchFunction · 0.85

Tested by

no test coverage detected