You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Gabriel Pap <pa...@gulo.sk> on 2007/10/18 16:05:37 UTC

timeout on request handler

Hi!

I need to abort the request handler in my module after a timeout.
What is the proper way to do it? Do I have to poll for the current time? How 
can I set an alarm?

request_handler(request_rec* r) {
...

while () {

  .. do some time demanding processing
  if (timeout)
    return HTTP_SERVICE_TEMPORARY_UNAVAILABLE; // or whatever

  }

...

}

Thanks,
Gabriel 


Re: timeout on request handler

Posted by ed <ed...@s5h.net>.
On Thu, 18 Oct 2007 16:05:37 +0200
"Gabriel Pap" <pa...@gulo.sk> wrote:

> I need to abort the request handler in my module after a timeout.
> What is the proper way to do it? Do I have to poll for the current
> time? How can I set an alarm?
> 
> request_handler(request_rec* r) {
> ...
> 
> while () {
> 
>   .. do some time demanding processing
>   if (timeout)
>     return HTTP_SERVICE_TEMPORARY_UNAVAILABLE; // or whatever
> 
>   }
> 
> ...
> 
> }

I'm quite new to Apache modules, but if you set an alarm the signal
will go to the whole process and possibly kill it, which is probably
not what a busy server would want.

It would be better, if your work has a blocking read, to use select(),
and as you suggest, probably the time(), to leave the loop when the
time has exceeded and tell apache to return a 500 or something.

-- 
The dirt trail to the playstation is down because of a screwed
up .procmailrc file. RedHat is wished well in their future endeavors.
:: http://www.s5h.net/ :: http://www.s5h.net/gpg