[FASTCGI] Trying to detect aborted client requests

Guillermo Arias del Río ariasdelrio at gmail.com
Thu Jun 27 05:47:24 EDT 2013

Hi, all!

I'm developing a FastCGI application using Apache, mod_cgi and the fcgio.h
API. Everything works so far, but I'm failing to detect aborted
connections. We need to control them, because we are sometimes doing
expensive operations which have to be aborted when the user aborts the
request. I'm trying to use the SIGPIPE as indicated in the documentation,
but it doesn't seem to work.

This is my system configuration:

CLIENT: Makes a XMLHttpRequest from Javascript and aborts it with the abort()


Linux Debian 3.2.46-1 x86_64
Apache2 (2.2.22-13)
mod_fastcgi (SNAP-0910052141)

This is my mod_fastcgi configuration:

FastCgiExternalServer $file -idle-timeout 3000 -socket $socket

And this is my code:

void FastcgiServer::sigpipe_handler(int signo) {
        std::cerr << "PIPE SIGNAL RECEIVED" << std::endl;

void FastcgiServer::run(){
    FCGX_Request request_i;

    FCGX_InitRequest(&request_i, socketfd, 0);

    struct sigaction sa;
    sa.sa_handler = sigpipe_handler;
    sa.sa_flags = 0;
    sigaction(SIGPIPE, &sa, NULL);

    RequestState state;
    while (FCGX_Accept_r(&request_i) == 0)
            this->state = &state;
            state.response->http_status.code = 200;
            try {
                    fill_request(request_i, *state.request);

If I send the signal with kill -13, I see the message, but if the client
aborts the connection nothing happens. The client socket of the
FastCGIApplication seems to remain open as well.

Can anybody help me? Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.fastcgi.com/pipermail/fastcgi-developers/attachments/20130627/d8ddf5b9/attachment.html>

More information about the FastCGI-developers mailing list