as dealing with batches (13 Jul 2003)
* fix job modifications on batched, running jobs (13 Jul 2005)
* throttle faxq from running the scheduler more than once per
- second in order to keep faxq from eating up CPU (11 Jul 2005)
+ second in order to keep faxq from eating up CPU (11, 21 Jul 2005)
* fix job preparation failures in batches from causing faxq list
corruption which would trigger faxq failure and worse (11 Jul 2005)
* fix the abortion of the lead job in a batch from causing
#define JOBHASH(pri) (((pri) >> 4) & (NQHASH-1))
-faxQueueApp::SchedTimeout::SchedTimeout() { started = false; }
+faxQueueApp::SchedTimeout::SchedTimeout()
+{
+ started = false;
+ pending = false;
+ lastRun = Sys::now() - 1;
+}
+
faxQueueApp::SchedTimeout::~SchedTimeout() {}
void
faxQueueApp::SchedTimeout::timerExpired(long, long)
{
- started = false;
faxQueueApp::instance().runScheduler();
+ started = false;
}
void
faxQueueApp::SchedTimeout::start()
{
- if (!started) {
+ /*
+ * If we don't throttle the scheduler then large
+ * queues can halt the system with CPU consumption.
+ * So we keep the scheduler from running more than
+ * once per second.
+ */
+ if (!started && Sys::now() > lastRun) {
Dispatcher::instance().startTimer(0,1, this);
+ lastRun = Sys::now();
started = true;
+ pending = false;
+ } else {
+ if (!pending) {
+ /*
+ * The scheduler is either running now or has been run
+ * within the last second and there are no timers set
+ * to trigger another scheduler run. So we set a
+ * timer to go off in one second to avoid a stalled
+ * run queue.
+ */
+ Dispatcher::instance().startTimer(1,0, this);
+ lastRun = Sys::now() + 1;
+ pending = true;
+ }
}
}
{
fifo = -1;
quit = false;
- lastRun = Sys::now() - 1;
dialRules = NULL;
setupConfig();
void
faxQueueApp::pokeScheduler()
{
- /*
- * If we don't throttle the scheduler then large
- * queues can halt the system with CPU consumption.
- * So we keep the scheduler from running more than
- * once per second.
- */
- if (Sys::now() != lastRun) {
- schedTimeout.start();
- lastRun = Sys::now();
- }
+ schedTimeout.start();
}
/*