| 134 | // ------------------------------------------------------------------------------------ |
| 135 | |
| 136 | void read_thread ( |
| 137 | impl1::bsp_con* con, |
| 138 | unsigned long node_id, |
| 139 | unsigned long sender_id, |
| 140 | impl1::thread_safe_message_queue& msg_buffer |
| 141 | ) |
| 142 | { |
| 143 | try |
| 144 | { |
| 145 | while(true) |
| 146 | { |
| 147 | impl1::msg_data msg; |
| 148 | deserialize(msg.msg_type, con->stream); |
| 149 | msg.sender_id = sender_id; |
| 150 | |
| 151 | if (msg.msg_type == MESSAGE_HEADER) |
| 152 | { |
| 153 | msg.data.reset(new std::vector<char>); |
| 154 | deserialize(msg.epoch, con->stream); |
| 155 | deserialize(*msg.data, con->stream); |
| 156 | } |
| 157 | |
| 158 | msg_buffer.push_and_consume(msg); |
| 159 | |
| 160 | if (msg.msg_type == NODE_TERMINATE) |
| 161 | break; |
| 162 | } |
| 163 | } |
| 164 | catch (std::exception& e) |
| 165 | { |
| 166 | impl1::msg_data msg; |
| 167 | msg.data.reset(new std::vector<char>); |
| 168 | vectorstream sout(*msg.data); |
| 169 | sout << "An exception was thrown while attempting to receive a message from processing node " << sender_id << ".\n"; |
| 170 | sout << " Sending processing node address: " << con->con->get_foreign_ip() << ":" << con->con->get_foreign_port() << std::endl; |
| 171 | sout << " Receiving processing node address: " << con->con->get_local_ip() << ":" << con->con->get_local_port() << std::endl; |
| 172 | sout << " Receiving processing node id: " << node_id << std::endl; |
| 173 | sout << " Error message in the exception: " << e.what() << std::endl; |
| 174 | |
| 175 | msg.sender_id = sender_id; |
| 176 | msg.msg_type = READ_ERROR; |
| 177 | |
| 178 | msg_buffer.push_and_consume(msg); |
| 179 | } |
| 180 | catch (...) |
| 181 | { |
| 182 | impl1::msg_data msg; |
| 183 | msg.data.reset(new std::vector<char>); |
| 184 | vectorstream sout(*msg.data); |
| 185 | sout << "An exception was thrown while attempting to receive a message from processing node " << sender_id << ".\n"; |
| 186 | sout << " Sending processing node address: " << con->con->get_foreign_ip() << ":" << con->con->get_foreign_port() << std::endl; |
| 187 | sout << " Receiving processing node address: " << con->con->get_local_ip() << ":" << con->con->get_local_port() << std::endl; |
| 188 | sout << " Receiving processing node id: " << node_id << std::endl; |
| 189 | |
| 190 | msg.sender_id = sender_id; |
| 191 | msg.msg_type = READ_ERROR; |
| 192 | |
| 193 | msg_buffer.push_and_consume(msg); |
nothing calls this directly
no test coverage detected