| 7682 | */ |
| 7683 | |
| 7684 | static void |
| 7685 | run_printer(ippeve_printer_t *printer) /* I - Printer */ |
| 7686 | { |
| 7687 | int num_fds; /* Number of file descriptors */ |
| 7688 | struct pollfd polldata[3]; /* poll() data */ |
| 7689 | ippeve_client_t *client; /* New client */ |
| 7690 | |
| 7691 | |
| 7692 | #ifndef _WIN32 |
| 7693 | /* |
| 7694 | * Set signal handlers for SIGINT and SIGTERM... |
| 7695 | */ |
| 7696 | |
| 7697 | signal(SIGINT, signal_handler); |
| 7698 | signal(SIGTERM, signal_handler); |
| 7699 | #endif // !_WIN32 |
| 7700 | |
| 7701 | /* |
| 7702 | * Setup poll() data for the DNS-SD service socket and IPv4/6 listeners... |
| 7703 | */ |
| 7704 | |
| 7705 | polldata[0].fd = printer->ipv4; |
| 7706 | polldata[0].events = POLLIN; |
| 7707 | |
| 7708 | polldata[1].fd = printer->ipv6; |
| 7709 | polldata[1].events = POLLIN; |
| 7710 | |
| 7711 | num_fds = 2; |
| 7712 | |
| 7713 | #ifdef HAVE_MDNSRESPONDER |
| 7714 | polldata[num_fds ].fd = DNSServiceRefSockFD(DNSSDMaster); |
| 7715 | polldata[num_fds ++].events = POLLIN; |
| 7716 | #endif /* HAVE_MDNSRESPONDER */ |
| 7717 | |
| 7718 | /* |
| 7719 | * Loop until we are killed or have a hard error... |
| 7720 | */ |
| 7721 | |
| 7722 | for (;;) |
| 7723 | { |
| 7724 | if (poll(polldata, (nfds_t)num_fds, 1000) < 0 && errno != EINTR) |
| 7725 | { |
| 7726 | perror("poll() failed"); |
| 7727 | break; |
| 7728 | } |
| 7729 | |
| 7730 | #ifndef _WIN32 |
| 7731 | if (StopPrinter) |
| 7732 | break; |
| 7733 | #endif // !_WIN32 |
| 7734 | |
| 7735 | if (polldata[0].revents & POLLIN) |
| 7736 | { |
| 7737 | if ((client = create_client(printer, printer->ipv4)) != NULL) |
| 7738 | { |
| 7739 | _cups_thread_t t = _cupsThreadCreate((_cups_thread_func_t)process_client, client); |
| 7740 | |
| 7741 | if (t) |
no test coverage detected