Reentrant POST

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • a

    Reentrant POST

    Hi,

    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?

    Thanks,

    A


  • Colin McKinnon

    #2
    Re: Reentrant POST

    a wrote:
    [color=blue]
    >
    > 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?
    >[/color]

    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.getEl ementById("form Id").onsubmit() ) {
    document.getEle mentById("submi tId").disabled= true;
    document.getEle mentById("formI d").submit() ;
    }' value='Submit'>

    C.

    Comment

    • a

      #3
      Re: Reentrant POST

      Thanks for your reply.
      [color=blue]
      > I think you've misunderstood the meaning of 'reentrant'.
      >[/color]

      By "reentrant" I meant that the user would POST while a previous POST is
      still being processed on the server.
      [color=blue]
      > 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.getEl ementById("form Id").onsubmit() ) {
      > document.getEle mentById("submi tId").disabled= true;
      > document.getEle mentById("formI d").submit() ;
      > }' value='Submit'>
      >[/color]

      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.

      A


      Comment

      Working...