Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 662AB200C0F for ; Thu, 2 Feb 2017 16:51:33 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 647E6160B57; Thu, 2 Feb 2017 15:51:33 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 89198160B54 for ; Thu, 2 Feb 2017 16:51:32 +0100 (CET) Received: (qmail 45834 invoked by uid 500); 2 Feb 2017 15:51:31 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 45824 invoked by uid 99); 2 Feb 2017 15:51:31 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Feb 2017 15:51:31 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 13A271A04BB for ; Thu, 2 Feb 2017 15:51:31 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.379 X-Spam-Level: ** X-Spam-Status: No, score=2.379 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id uyoU4lvR6VJe for ; Thu, 2 Feb 2017 15:51:29 +0000 (UTC) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 1ACD85F5C4 for ; Thu, 2 Feb 2017 15:51:29 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id b65so96486686wmf.0 for ; Thu, 02 Feb 2017 07:51:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=4R7ptyXsii3z+sBHHIVh+Jij+JSuWOk1k2a08/f5zrE=; b=Y9QCcaI54MeNeJU7GMLLFhgt62jcr+zMFLkq7hsUMxCuQDU7z7FzxlrZ8JeTAZCuYa x4++xrqdGo1/2PfgJKU1LDwXKJ/tQn9pCIJsoFWuTjz59fs+1eV+mZlCdcIAxY3s24kW P0ypycCZjnGIng3PX5OFZaXrsQm2K4WMhyibxLp15IcEHM4pCWcCffLeecM+iT7224wi SI2hICNXb85aAzxcTkkUoKm9ZiAWrUbba9DOPqYvwtS94IUXY/hNNmDkJxSg+tcqUR8L g23j0NXQrDbS++yZFysU48RRkSx8Jkw/2Dsq53yvuHwfk5tepGIpE9DdzNovKzAuUZ6x MPdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=4R7ptyXsii3z+sBHHIVh+Jij+JSuWOk1k2a08/f5zrE=; b=aBZfwARaJjOAiORpYbB/Gs5qOVPXpIRU5Dlz+xN9GED9TBT4TciYaZQoVVRqdYQxI7 wDZ99TnvWOhleiX8w74F8snK8oOZ6+GeYeZg97z3hhbEz2/8OvMu4ToKFQvLj7dVGwgF GmJ54BoQCPgrnvcOOozueecB7IVF29jSHaqPQm0daOZkP2uBTiuGAVUZTYnJGzrF1ZEq k+lIobHf/UfaMTKFJmIfmlIoZPfFUzVAI7HhC2tcA7DxLu5Tze168uaYlaRWBWFo09Q1 R0+hv+W2Qj1HnqeHozs8U00If61G1bdVCUsT0xz/9A/LRMkffjENFV7LzUL8K6LRYo/x dmIg== X-Gm-Message-State: AIkVDXKTjuOmxSepbYalwwwB3CWmku6L6ivEzM/2yniIQznuANg7GgUx+H9doD8iXMNLiTY2VYGwNR7PYoz5ww== X-Received: by 10.223.163.199 with SMTP id m7mr8026755wrb.63.1486050684997; Thu, 02 Feb 2017 07:51:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.25.2 with HTTP; Thu, 2 Feb 2017 07:51:24 -0800 (PST) In-Reply-To: References: From: Luca Toscano Date: Thu, 2 Feb 2017 16:51:24 +0100 Message-ID: Subject: Re: [Bug 56188] mod_proxy_fcgi does not send FCGI_ABORT_REQUEST on client disconnect To: Apache HTTP Server Development List Content-Type: multipart/alternative; boundary=f403045f200e3298e505478e23ab archived-at: Thu, 02 Feb 2017 15:51:33 -0000 --f403045f200e3298e505478e23ab Content-Type: text/plain; charset=UTF-8 2017-01-30 21:58 GMT+01:00 Yann Ylavic : > On Mon, Jan 30, 2017 at 7:17 PM, Luca Toscano > wrote: > > > > The use case that I had (the one that caused me to check the original > > bugzilla task/patch and work on it) was a long running PHP script > (running > > on HHVM) that wasn't returning anything until the end of the job > (minutes), > > causing mod-proxy-fcgi to keep waiting even if the client disconnected. > In > > the beginning I also thought that there was a way to "signal" the FCGI > > backend to stop whatever was doing (FCGI_ABORT), but it turned out to be > not > > widely implemented (at least from what I have checked, more info in > > bugzilla). Timeout and ProxyTimeout could be a good compromise for this > > particular issue, but it is a "one size fits all" solution that some > users > > didn't like (providing a patch with the pollset solution). > > I think that's what CGIDScriptTimeout or ProxyTimeout are for: avoid > waiting too much for the script or backend (above some reasonably > configured limit). > > > > > If we remove the above use case (I fixed it in my Production environment > > with a long Timeout value), would it be fine to rely on something like > the > > conn->aborted flag (afaics set by the output filter's chain while > writing to > > the client's conn)? It would simplify a lot the problem :) > > AFAICT, if forwarding data to the client fails (e.g. socket > disconnected), ap_pass_brigade() returns an error and the loop exits. > Yes confirmed with a test (that flushes data to output periodically), the connection->aborted flag is set and mod_proxy_fcgi behaves correctly. > Maybe what is missing is nonblocking reads on the backend side, and on > EAGAIN flush on the client side to detect potential socket errors? > Interesting.. So the idea would be to be non blocking while reading from the FCGI backend, and in case of EAGAIN flush to the client in order to force ap_pass_brigade to detect if the client aborted the connection. The flushing part might be tricky to implement (at least for me, but I'll try to work on it :). In any case, it seems like we are in agreement to discard the client connection polling idea (if anybody has more thoughts please speak up). In any case, I believe that this use case would need to be documented properly in the docs to warn users assuming that FCGI_ABORT is implemented. Thanks for the review! Luca --f403045f200e3298e505478e23ab Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


2017-01-30 21:58 GMT+01:00 Yann Ylavic <ylavic.dev@gmail.com>= ;:
On Mon, Jan 30= , 2017 at 7:17 PM, Luca Toscano <toscano.luca@gmail.com> wrote:
>
> The use case that I had (the one that caused me to check the original<= br> > bugzilla task/patch and work on it) was a long running PHP script (run= ning
> on HHVM) that wasn't returning anything until the end of the job (= minutes),
> causing mod-proxy-fcgi to keep waiting even if the client disconnected= . In
> the beginning I also thought that there was a way to "signal"= ; the FCGI
> backend to stop whatever was doing (FCGI_ABORT), but it turned out to = be not
> widely implemented (at least from what I have checked, more info in > bugzilla). Timeout and ProxyTimeout could be a good compromise for thi= s
> particular issue, but it is a "one size fits all" solution t= hat some users
> didn't like (providing a patch with the pollset solution).

I think that's what CGIDScriptTimeout or ProxyTimeout are for: a= void
waiting too much for the script or backend (above some reasonably
configured limit).

>
> If we remove the above use case (I fixed it in my Production environme= nt
> with a long Timeout value), would it be fine to rely on something like= the
> conn->aborted flag (afaics set by the output filter's chain whi= le writing to
> the client's conn)? It would simplify a lot the problem :)

AFAICT, if forwarding data to the client fails (e.g. socket
disconnected), ap_pass_brigade() returns an error and the loop exits.

Yes confirmed with a test (that flushes data= to output periodically), the connection->aborted flag is set and mod_pr= oxy_fcgi behaves correctly.
=C2=A0
Maybe what is missing is nonblocking reads on the backend side, and on
EAGAIN flush on the client side to detect potential socket errors?

Interesting.. So the idea would be to be non bl= ocking while reading from the FCGI backend, and in case of EAGAIN flush to = the client in order to force ap_pass_brigade to detect if the client aborte= d the connection. The flushing part might be tricky to implement (at least = for me, but I'll try to work on it :).

In any = case, it seems like we are in agreement to discard the client connection po= lling idea (if anybody has more thoughts please speak up). In any case, I b= elieve that this use case would need to be documented properly in the docs = to warn users assuming that FCGI_ABORT is implemented.

=
Thanks for the review!

Luca

--f403045f200e3298e505478e23ab--