Detecting early termination by client

Jason Dixon jason at dixongroup.net
Sat Apr 16 03:43:09 UTC 2005


On Apr 15, 2005, at 8:14 PM, Stephen Carville wrote:

> I have a Perl CGI script that runs on Apache on Linux using mod_cgi.
> The script takes a XML document POSTed by the client, parses it, 
> validates the data, places the order into the Oracle database, sends a 
> response back to the customer, then creates a log entry of what 
> happened.  Unfortnately I have one customer who insists on not waiting 
> for an acknowlegment (even tho he requests one) but drops the 
> connection as soon as the data is on the wire.  This (I think) is 
> causing Apache to terminate the CGI process before it completes the 
> processing.  Sometimes the order gets placed, sometimes it does not. 
> Since logging happens at the end, I don't always know an order was 
> attempted.
>
> Is there any way I can capture this early terminaition so I can handle
> it intelligently?  I know how to set up a signal handler but I don't 
> know what signal -- if any --  to look for.

First, this is a perl/CGI question, not a Red Hat question.  You would 
be better off asking this on PerlMonks.  Nevertheless...

Because HTTP is a stateless protocol, there is no such thing as a 
signal handler.  The best way for you to determine if this is what is 
causing your missing orders is to reproduce the client's behavior and 
track the partial(?) order with your session identifier.  I can't 
imagine how you might be losing an order, unless they're simply not 
hitting the final submit.  Presumably, you "fork" them into a loop, 
re-requesting a status update from the database every X seconds using 
the session ID.  In the case of your rogue customer, if they never 
return to get the status, the order should still be transmitted... they 
just don't get a summary.

At least, that's my opinion on your situation given a complete lack of 
technical details.  :)

--
Jason Dixon
DixonGroup Consulting
http://www.dixongroup.net





More information about the redhat-list mailing list