Re: FastCGI and SIGPIPE

David Birnbaum <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Andrej,

If the response fits all the way into the httpd cache, then the FastCGI 
application will dump the output to httpd and go on to the next request before 
it knows the user has closed the connection.  That is one possibility.

David.

-----

On Tue, 7 Feb 2006, Andrej van der Zee wrote:

> Hi,
>
> I am experiencing some problems with users aborting a request. When a
> user closes the broswer, then my fast-cgi application never sees a
> SIGPIPE.  I wrote the small program below for testing but untill now I
> have never seen a SISPIPE.
>
> Sombody?
>
> Andrej
>
>
> #include <stdlib.h>
> #include <time.h>
> #include <sys/wait.h>
> #include <syslog.h>
> #include <sys/time.h>
> #include "fcgiapp.h"
>
> #define SIGNAL(sig, x)              \
>      do {                              \
>                struct sigaction sa;            \
>                sa.sa_sigaction = x;            \
>                sa.sa_flags = SA_SIGINFO;       \
>                sigfillset(&sa.sa_mask);        \
>                sigaction(sig, &sa, NULL);      \
>              } while (0)
>
> bool signal_raised = false;
>
> static void handle_sigs(int sig, siginfo_t * si, void * context)
> {
>    switch(sig)
>    {
>        case SIGUSR1:
>        case SIGTERM:
>        case SIGPIPE:
>        case SIGALRM:
>            signal_raised = true;
>            break;
>        default:
>            break;
>    }
> }
>
> int main(void)
> {
>    int i,scale;
>    char* pathInfo;
>    FCGX_Stream *in, *out, *err;
>    FCGX_ParamArray envp;
>
>    SIGNAL(SIGPIPE, handle_sigs);
>    SIGNAL(SIGUSR1, handle_sigs);
>    SIGNAL(SIGTERM, handle_sigs);
>    SIGNAL(SIGALRM, handle_sigs);
>
>    while (!signal_raised && FCGX_Accept(&in, &out, &err, &envp) >= 0)
>    {
>        FCGX_FPrintF(out,"Content-type: text/html\r\n\r\n");
>        FCGX_FPrintF(out,"<h2>Going into while...</h2>");
>        FCGX_FFlush(out);
>
>        while (!signal_raised)
>        {
>            struct timeval begin;
>            gettimeofday(&begin, NULL);
>
>            int delta = 0;
>
>            while (delta < 10)
>            {
>                struct timeval end;
>                gettimeofday(&end, NULL);
>                delta = end.tv_sec - begin.tv_sec;
>            }
>
>             // keep connection alive by sending spaces
>            FCGX_FPrintF(out," ");
>            FCGX_FFlush(out);
>        }
>
>        syslog(LOG_ERR, "SIGNAL RAISED!");
>    }
>
>    return 0;
> }
>
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
>
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.