Sifmole has asked for the wisdom of the Perl Monks concerning the following question:

The problem is this. I have a CGI which can take a few minutes to process a request. It is important that this request not be processed twice. To that end I have set up tables and status codes for the request so that no matter how many times the User pounds on the submit button the request will only be processed once.

My problem is this: The solution requires a process to poll the interim table until the request has been completed. If the User hits the "Submit" button multiple times then multiple processes will be spawned that will start polling the table.

I want to avoid having several processes that poll the table at the same time. I figure a good way of doing that would be if the process could detect whether the browser that started the request is still listening to it. Is there a way to do this?

I know I can use javascript to disable the button so it can only be "submit"ed once. I will be doing this, however I want a solution that will not require the user to have javascript enabled.

Thanks in advance.

  • Comment on How to tell if a browser is still listening to a CGI

Replies are listed 'Best First'.
Re: How to tell if a browser is still listening to a CGI
by jj808 (Hermit) on Oct 24, 2001 at 17:04 UTC
Re: How to tell if a browser is still listening to a CGI
by ajt (Prior) on Oct 24, 2001 at 18:33 UTC
    merlyn has a column related to this topic...

    Even though he has only 68 columns, there seems to be one for every topic.

    Good luck, anyway.

Re: How to tell if a browser is still listening to a CGI
by graq (Curate) on Oct 24, 2001 at 18:26 UTC
    Perhaps you could assign an ID to the HTML form.
    Generate the HTML page from CGI, inserting the unique ID, and then just have a history/log table of requests and disallowing non-unique requests.

    Be nice and let them refresh the page with a new ID if they have caching or other problems.

    <a href="http://www.graq.co.uk">Graq</a>

Re: How to tell if a browser is still listening to a CGI
by davis (Vicar) on Oct 24, 2001 at 18:34 UTC
    Hi,
    The Apache::Connection Class from mod_perl provides a method known as aborted(), which should do what you want