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

Function select_timeout

scheduler/main.c:1635–1787  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1633 */
1634
1635static long /* O - Number of seconds */
1636select_timeout(int fds) /* I - Number of descriptors returned */
1637{
1638 long timeout; /* Timeout for select */
1639 time_t now; /* Current time */
1640 cupsd_client_t *con; /* Client information */
1641 cupsd_job_t *job; /* Job information */
1642 const char *why; /* Debugging aid */
1643
1644
1645 cupsdLogMessage(CUPSD_LOG_DEBUG2, "select_timeout: JobHistoryUpdate=%ld",
1646 (long)JobHistoryUpdate);
1647
1648 /*
1649 * Check to see if any of the clients have pending data to be
1650 * processed; if so, the timeout should be 0...
1651 */
1652
1653 for (con = (cupsd_client_t *)cupsArrayFirst(Clients);
1654 con;
1655 con = (cupsd_client_t *)cupsArrayNext(Clients))
1656 if (httpGetReady(con->http))
1657 return (0);
1658
1659 /*
1660 * If select has been active in the last second (fds > 0) or we have
1661 * many resources in use then don't bother trying to optimize the
1662 * timeout, just make it 1 second.
1663 */
1664
1665 if (fds > 0 || cupsArrayCount(Clients) > 50)
1666 return (1);
1667
1668 /*
1669 * Otherwise, check all of the possible events that we need to wake for...
1670 */
1671
1672 now = time(NULL);
1673 timeout = now + 86400; /* 86400 == 1 day */
1674 why = "do nothing";
1675
1676#ifdef __APPLE__
1677 /*
1678 * When going to sleep, wake up to abort jobs that don't complete in time.
1679 */
1680
1681 if (SleepJobs > 0 && SleepJobs < timeout)
1682 {
1683 timeout = SleepJobs;
1684 why = "abort jobs before sleeping";
1685 }
1686#endif /* __APPLE__ */
1687
1688 /*
1689 * Check whether we are accepting new connections...
1690 */
1691
1692 if (ListeningPaused > 0 && cupsArrayCount(Clients) < MaxClients &&

Callers 1

mainFunction · 0.85

Calls 6

cupsdLogMessageFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
httpGetReadyFunction · 0.85
cupsArrayCountFunction · 0.85
httpGetActivityFunction · 0.85

Tested by

no test coverage detected