Re: CGI Child Process Question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



André Warnier wrote:
"A cgi-bin program is a separate process from the Apache child that runs
it."

My tests (and the whole cgi logic in a web server) concluded that the
cgi-script is a child of apache. This because the the ppid() of the
cgi-script is the pid() of the apache server daemon. ;)


Thanks for the tip, I haven?t thought on using an Apache Filter. But anyway,
I think that the SIGPIPE signal has the same effect as an Apache Filter. I'm
not sure, but I think Apache already has filters that send this kind of
singnals to the cgi-script when the socket is closed. That's what SIGPIPE is
all about. Apache routes the stdout from my cgi-script to the clients socket
through a pipe, when the socket is closed, apache sends a SIGPIPE the my
cgi-script telling that the client has disconnected.

After all, I am not interested if the client has received 100% of the data.
I am interested to know, how close to 100% did the client received. The
cgi-script I'm writing, is a bit selfish. All he wants to know is yes or no,
how much data did the client wasted on his request. If the data was not 100%
received by the client because he cancelled, that's his problem, he can
request again later. 

-----Original Message-----
From: André Warnier [mailto:aw@xxxxxxxxxx] 
Sent: Saturday, March 21, 2009 1:03 PM
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  Re: CGI Child Process Question

Lihet Ruben wrote:
[...]
I would look at this in another way.
A cgi-bin program is a separate process from the Apache child that runs
it.  The Apache process starts the cgi-bin process, and arranges to read
back everything that the cgi-bin writes to STDOUT.  Then Apache sends
this to the browser.  In-between, there is buffering, so as someone
pointed out, it is possible that after your cgi-bin has already finished
its job of producing the output and has exited, Apache is still busy
sending some chunks of output to the browser, and then the user cancels.
In that case, your script would think that everything has been sent,
while this is not the case.

What I would thus do, is to implement your logic of verifying that the
user has received everything, in an Apache output filter.  It is still
not perfect, but much "closer" to the browser. If the user interrupts
the connection by hitting cancel, the filter would know, because it
would get an i/o error when writing to the response socket.  And it
could notify your application.

Now understand that if your client is behind a proxy that does
buffering, then the proxy will still hold some data, while Apache is
long done and the filter has told your application that everything was
sent. And the user can still hit cancel then.

So ultimately, to be 100% sure, the only solution is to ask the user,
when he has finished downloading, to acknowledge receipt.

I cannot think of an easy way to do that with a standard browser, but I
can imagine a Java applet which gets the file from your server, writes
it to a local file, and when it is done, makes a POST to the server to
say it was done.




---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux