browse_time, /* Next browse send time */
senddoc_time, /* Send-Document time */
expire_time, /* Subscription expire time */
- report_time; /* Malloc/client/job report time */
+ report_time, /* Malloc/client/job report time */
+ event_time; /* Last time an event notification was done */
long timeout; /* Timeout for cupsdDoSelect() */
struct rlimit limit; /* Runtime limit */
#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
* Loop forever...
*/
- browse_time = time(NULL);
- expire_time = time(NULL);
+ current_time = time(NULL);
+ browse_time = current_time;
+ event_time = current_time;
+ expire_time = current_time;
fds = 1;
report_time = 0;
- senddoc_time = time(NULL);
+ senddoc_time = current_time;
while (!stop_scheduler)
{
* times.
*/
- timeout = select_timeout(fds);
+ if ((timeout = select_timeout(fds)) > 1 && LastEvent)
+ timeout = 1;
#if HAVE_LAUNCHD
/*
* accumulated. Don't send these more than once a second...
*/
- if (LastEvent)
+ if (LastEvent && (current_time - event_time) >= 1)
{
#ifdef HAVE_NOTIFY_POST
if (LastEvent & (CUPSD_EVENT_PRINTER_ADDED |
* Reset the accumulated events...
*/
- LastEvent = CUPSD_EVENT_NONE;
+ LastEvent = CUPSD_EVENT_NONE;
+ event_time = current_time;
}
}