| 5573 | } |
| 5574 | |
| 5575 | static void *accept_thread(void *arg) |
| 5576 | { |
| 5577 | comdb2_name_thread(__func__); |
| 5578 | netinfo_type *netinfo_ptr; |
| 5579 | struct pollfd pol; |
| 5580 | int rc; |
| 5581 | int listenfd = 0; |
| 5582 | int polltm; |
| 5583 | struct linger linger_data; |
| 5584 | struct sockaddr_in cliaddr; |
| 5585 | connect_and_accept_t *ca; |
| 5586 | pthread_t tid; |
| 5587 | char paddr[64]; |
| 5588 | socklen_t clilen; |
| 5589 | socklen_t len; |
| 5590 | int new_fd; |
| 5591 | int flag = 1; |
| 5592 | SBUF2 *sb; |
| 5593 | portmux_fd_t *portmux_fds = NULL; |
| 5594 | unsigned int last_stat_dump_time = comdb2_time_epochms(); |
| 5595 | |
| 5596 | thrman_register(THRTYPE_GENERIC); |
| 5597 | thread_started("net accept"); |
| 5598 | ENABLE_PER_THREAD_MALLOC(__func__); |
| 5599 | |
| 5600 | netinfo_ptr = (netinfo_type *)arg; |
| 5601 | |
| 5602 | netinfo_ptr->accept_thread_arch_tid = getarchtid(); |
| 5603 | |
| 5604 | logmsg(LOGMSG_INFO, "%s: starting, tid=%" PRIxPTR ".\n", __func__, |
| 5605 | (intptr_t) netinfo_ptr->accept_thread_arch_tid); |
| 5606 | |
| 5607 | if (netinfo_ptr->start_thread_callback) |
| 5608 | netinfo_ptr->start_thread_callback(netinfo_ptr->callback_data); |
| 5609 | |
| 5610 | logmsg(LOGMSG_INFO, "net %s my port is %d fd is %d\n", netinfo_ptr->service, |
| 5611 | netinfo_ptr->myport, netinfo_ptr->myfd); |
| 5612 | |
| 5613 | if (gbl_pmux_route_enabled) { |
| 5614 | portmux_fds = |
| 5615 | portmux_listen_setup(netinfo_ptr->app, netinfo_ptr->service, |
| 5616 | netinfo_ptr->instance, netinfo_ptr->myfd); |
| 5617 | if (!portmux_fds) { |
| 5618 | logmsg(LOGMSG_FATAL, "Could not get portmux_fds\n"); |
| 5619 | exit(1); |
| 5620 | } |
| 5621 | } else { |
| 5622 | /* We used to listen here. We now listen way earlier and get a file |
| 5623 | * descriptor passed in. This is to prevent 2 instances from coming up |
| 5624 | * against the same data. */ |
| 5625 | if (netinfo_ptr->myfd != -1) |
| 5626 | listenfd = netinfo_ptr->myfd; |
| 5627 | else |
| 5628 | listenfd = netinfo_ptr->myfd = net_listen(netinfo_ptr->myport); |
| 5629 | if (listenfd < 0) { |
| 5630 | logmsg(LOGMSG_FATAL, "Could not get listenfd\n"); |
| 5631 | exit(1); |
| 5632 | } |
nothing calls this directly
no test coverage detected