| 4294 | } |
| 4295 | |
| 4296 | static void *reader_thread(void *arg) |
| 4297 | { |
| 4298 | // TODO: node! |
| 4299 | host_node_type *host_node_ptr; |
| 4300 | host_node_ptr = arg; |
| 4301 | |
| 4302 | char thdname[32]; |
| 4303 | snprintf(thdname, sizeof(thdname), "writer_thread %s", host_node_ptr->host); |
| 4304 | comdb2_name_thread(thdname); |
| 4305 | netinfo_type *netinfo_ptr; |
| 4306 | wire_header_type wire_header; |
| 4307 | int rc, set_qstat = 0; |
| 4308 | char fromhost[256], tohost[256]; |
| 4309 | |
| 4310 | thrman_register(THRTYPE_GENERIC); |
| 4311 | thread_started("net reader"); |
| 4312 | ENABLE_PER_THREAD_MALLOC(__func__); |
| 4313 | |
| 4314 | netinfo_ptr = host_node_ptr->netinfo_ptr; |
| 4315 | |
| 4316 | host_node_ptr->reader_thread_arch_tid = getarchtid(); |
| 4317 | if (gbl_verbose_net) |
| 4318 | host_node_printf(LOGMSG_DEBUG, host_node_ptr, "%s: starting tid=%d\n", __func__, |
| 4319 | host_node_ptr->reader_thread_arch_tid); |
| 4320 | |
| 4321 | if (netinfo_ptr->start_thread_callback) |
| 4322 | netinfo_ptr->start_thread_callback(netinfo_ptr->callback_data); |
| 4323 | |
| 4324 | while (!host_node_ptr->decom_flag && !host_node_ptr->closed && |
| 4325 | !netinfo_ptr->exiting) { |
| 4326 | |
| 4327 | if (set_qstat == 0 && netinfo_ptr->qstat_reader_rtn) { |
| 4328 | (netinfo_ptr->qstat_reader_rtn)(netinfo_ptr, host_node_ptr->qstat); |
| 4329 | set_qstat = 1; |
| 4330 | } |
| 4331 | |
| 4332 | host_node_ptr->timestamp = time(NULL); |
| 4333 | |
| 4334 | if (netinfo_ptr->trace && debug_switch_net_verbose()) |
| 4335 | logmsg(LOGMSG_USER, "RT: reading header %llu\n", gettmms()); |
| 4336 | |
| 4337 | rc = read_message_header(netinfo_ptr, host_node_ptr, &wire_header, |
| 4338 | fromhost, tohost); |
| 4339 | if (rc != 0) { |
| 4340 | if (!host_node_ptr->distress) { |
| 4341 | host_node_printf(LOGMSG_WARN, host_node_ptr, "entering distress mode\n"); |
| 4342 | } |
| 4343 | /* if we loop it should be ok; TODO: maybe wanna have |
| 4344 | * a modulo operation to report errors w/ a certain periodicity? */ |
| 4345 | host_node_ptr->distress++; |
| 4346 | break; |
| 4347 | } else { |
| 4348 | if (host_node_ptr->distress) { |
| 4349 | unsigned cycles = host_node_ptr->distress; |
| 4350 | host_node_ptr->distress = 0; |
| 4351 | host_node_printf(LOGMSG_INFO, host_node_ptr, |
| 4352 | "%s: leaving distress mode after %u cycles\n", |
| 4353 | __func__, cycles); |
nothing calls this directly
no test coverage detected