Reentrant POST

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have the following setup: PHP 5.1.x on Apache 2.x on Windows XP.

A php script receives data from a form upon user submit, and then execs a  
Windows process, which may take some time to complete (actually this process  
performs a quite complex task which involves starting another process and  
then requesting a Windows service to perform yet other tasks). Everything  
works fine as long as the user submits the form and then patiently waits for  
the processing to end. However, if the user clicks on submit while the php  
script is still waiting for the windows process to end, than the browser  
will remain in this state indefinitely, the Windows processes never complete  
their tasks and sometimes Apache crashes.

Is there a way to handle this so the work in progress is either allowed to  
end or instructed to stop, before moving on to processing the new submit?



Re: Reentrant POST

a wrote:

Quoted text here. Click to load it

I think you've misunderstood the meaning of 'reentrant'.

Interfering with the existing process is not trivial. Wouldn't it be simpler
to not allow the user to POST more than once - something like:

<input type='button' id='submitId' onclick='
        if (document.getElementById("formId").onsubmit()) {
        }' value='Submit'>


Re: Reentrant POST

Thanks for your reply.

Quoted text here. Click to load it

By "reentrant" I meant that the user would POST while a previous POST is  
still being processed on the server.

Quoted text here. Click to load it

Yes, this would prevent the user from resubmitting a form, but there is also  
the issue of allowing the user to cancel a lengthy processing, in which case  
a new post would still have to be sent.

I'm leaning now more toward an asynchronous solution in which the windows  
process that is exec-ed by the php script starts another process to do the  
actual work and then returns immediately, allowing the php script to  
continue. There will have to be a synchronization mechanism between the  
working process and the php script that will signal when the data is ready,  
or will allow the processing to be canceled.


Re: Reentrant POST

Kimmo Laine wrote:
Quoted text here. Click to load it

Unless next_page.php generates PHP, the script with this include will
only get HTML.

Quoted text here. Click to load it


    if (isset($_GET['foo'])) {
      echo '<?php echo $_GET[\'foo\']; ?>';
    } else {
      echo '<?php echo \'Not available\'; ?>';

File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot

Site Timeline