Re: Perl DBI::Pg - Stop button

From: Lincoln Yeoh <lyeoh(at)pop(dot)jaring(dot)my>
To: Richard Huxton <dev(at)archonet(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, psql-mail(at)freeuk(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Perl DBI::Pg - Stop button
Date: 2003-05-08 16:28:01
Message-ID: 5.2.1.1.1.20030508235456.033ebe38@mbox.jaring.my
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I don't see why HTTP being a stateless protocol should mean that an app
can't tell if a user disconnects from the webserver. The webserver in most
cases knows reasonably promptly, and the other cases after a timeout. If
that were not possible, webservers would be wasting a lot of resources by
keeping them around long after disconnects.

From my dim memory, if you are using CGI and Apache, when the stop button
is hit and when you try to print something, you get a SIGTERM and possibly
a SIGPIPE (but your app could be dead by then :) ). Plus the print returns
false if you are still around.

If you are using Modperl and Apache >=1.3.6, when the stop button is hit,
and you try to print something, you get a SIGPIPE, and the print returns a
false. I don't think you get a SIGTERM.

AFAIK the print doesn't return a false immediately even if you turn off
buffering, so expect a delay in detection - depends on how much and how
often you print (not sure if you can change this, e.g. tcp options etc).

If you are using FCGI (at least the versions I tested), when the stop
button is hit, and you try to print something, you don't get a SIGPIPE, nor
does the print fail. So if you want to detect disconnections, you would
want to serve such requests with either CGI or modperl.

For mod_perl see:
http://perl.apache.org/docs/1.0/guide/debug.html#Handling_the__User_pressed_Stop_button__case

Your mileage may vary. Test first.

So far if I don't want to print anything but need to check if still
connected, print "\0" does what I want.

As for sending a cancel. I'm not sure how to do it with DBI::Pg. Would be
good to know.

Have a nice day,
Link.

At 07:32 AM 5/7/2003 +0100, Richard Huxton wrote:

>I think the thrust of Matt's question was whether there is any way to know
>when the user presses "stop" in their browser from the server end.
>Unfortunately, since HTTP is a stateless protocol, the short answer is no.
>
>This is of course simple if you have a java applet sitting on your page
>connecting to your server - it can signal out of band.
>
>[Not often I follow-up a post by Tom ;-]
>--
> Richard Huxton
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: if posting/reading through Usenet, please send an appropriate
>subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
>message can get through to the mailing list cleanly

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2003-05-08 17:01:43 interval function question
Previous Message scott.marlowe 2003-05-08 16:14:23 Re: Creating functions and triggers