MCPcopy Create free account
hub / github.com/OpenPrinting/cups / run_printer

Function run_printer

tools/ippeveprinter.c:7684–7791  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7682 */
7683
7684static void
7685run_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)

Callers 1

mainFunction · 0.85

Calls 8

DNSServiceRefSockFDFunction · 0.85
create_clientFunction · 0.85
_cupsThreadCreateFunction · 0.85
_cupsThreadDetachFunction · 0.85
delete_clientFunction · 0.85
DNSServiceProcessResultFunction · 0.85
register_printerFunction · 0.85
clean_jobsFunction · 0.85

Tested by

no test coverage detected