Jogging and Timeout

Runaway CGI's are feared and hated by developers and system administrators around the world. They can eat up memory, fill up hard drives and linger around wasting resources. On the other hand, long running CGI's can trick browsers into thinking that they have failed in some way, causing the browser to drop the connection.

The jogtimeout class provides methods for preventing runaway CGI's and helping out long running CGI's. Its initJogTimeout method takes two parameters: joginterval and timeout. Once called, every joginterval seconds, a carriage return will be sent to the browser. After timeout seconds, the CGI will be aborted.

The following CGI will jog the browser every 30 seconds and abort after 240 seconds.

#include <groundwork/jogtimeout.h>
#include <groundwork/cgimodule.h>

MAIN {

        ... initialize other classes ...

        ... send an http header ...

        jogtimeout      jt(APISTRUCT);
        jt.initJogTimeout(30,240);

        ... send the page data ...
}