| 1099 | } |
| 1100 | |
| 1101 | bool |
| 1102 | DmtcpCoordinator::validateNewWorkerProcess( |
| 1103 | DmtcpMessage &hello_remote, |
| 1104 | jalib::JSocket &remote, |
| 1105 | CoordClient *client, |
| 1106 | const struct sockaddr_storage *remoteAddr, |
| 1107 | socklen_t remoteLen) |
| 1108 | { |
| 1109 | // Coming from dmtcp_launch or fork(), ssh(), etc. |
| 1110 | if (hello_remote.state != WorkerState::RUNNING && |
| 1111 | hello_remote.state != WorkerState::UNKNOWN) { |
| 1112 | JWARNING(false) (hello_remote.state) |
| 1113 | .Text("state is not RUNNING or UNKNOWN; rejecting new connection"); |
| 1114 | return false; |
| 1115 | } |
| 1116 | |
| 1117 | if (hello_remote.virtualPid != -1) { |
| 1118 | JWARNING(false) (hello_remote.virtualPid) |
| 1119 | .Text("virtualPid is not -1; rejecting new connection"); |
| 1120 | return false; |
| 1121 | } |
| 1122 | |
| 1123 | const struct sockaddr_in *sin = (const struct sockaddr_in *)remoteAddr; |
| 1124 | string remoteIP = inet_ntoa(sin->sin_addr); |
| 1125 | DmtcpMessage hello_local(DMT_ACCEPT); |
| 1126 | |
| 1127 | client->virtualPid(getNewVirtualPid()); |
| 1128 | |
| 1129 | hello_local.virtualPid = client->virtualPid(); |
| 1130 | ComputationStatus s = getStatus(); |
| 1131 | |
| 1132 | if (workersRunningAndSuspendMsgSent == true) { |
| 1133 | // Handshake |
| 1134 | hello_local.compGroup = compId; |
| 1135 | remote << hello_local; |
| 1136 | |
| 1137 | ResendDoCheckpointMsgToWorker(client); |
| 1138 | } else if (s.numPeers > 0 && s.minimumState != WorkerState::RUNNING && |
| 1139 | s.minimumState != WorkerState::UNKNOWN) { |
| 1140 | // If some of the processes are not in RUNNING state |
| 1141 | JNOTE("Current computation not in RUNNING state." |
| 1142 | " Refusing to accept new connections.") |
| 1143 | (compId) (hello_remote.from) |
| 1144 | (s.numPeers) (s.minimumState); |
| 1145 | hello_local.type = DMT_REJECT_NOT_RUNNING; |
| 1146 | remote << hello_local; |
| 1147 | remote.close(); |
| 1148 | return false; |
| 1149 | } else if (hello_remote.compGroup != UniquePid()) { |
| 1150 | // New Process trying to connect to Coordinator but already has compGroup |
| 1151 | JNOTE("New process not part of currently running computation group" |
| 1152 | "on this theCoordinator. Rejecting.") |
| 1153 | (hello_remote.compGroup); |
| 1154 | |
| 1155 | hello_local.type = DMT_REJECT_WRONG_COMP; |
| 1156 | remote << hello_local; |
| 1157 | remote.close(); |
| 1158 | return false; |
nothing calls this directly
no test coverage detected