]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: applet: fix reporting of broken write situation
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Sep 2015 17:11:55 +0000 (19:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Sep 2015 19:16:02 +0000 (21:16 +0200)
If an applet tries to write to a closed connection, it hangs forever.
This results in some "get map" commands on the CLI to leave orphaned
connections alive.

Now the applet wakeup function detects that the applet still wants to
write while the channel is closed for reads, which is the equivalent
to the common "broken pipe" situation. In this case, an error is
reported on the stream interface, just as it happens with connections
trying to perform a send() in a similar situation.

With this fix the stats socket is properly released.

src/stream_interface.c

index 18ff6b5e3974688200f3d4fa5b19f164d080ecb4..2341720b3e15834d5fcb44557b2882c783da0d08 100644 (file)
@@ -1343,6 +1343,14 @@ void stream_sock_read0(struct stream_interface *si)
  */
 void si_applet_wake_cb(struct stream_interface *si)
 {
+       struct channel *ic = si_ic(si);
+
+       /* If the applet wants to write and the channel is closed, it's a
+        * broken pipe and it must be reported.
+        */
+       if ((si->flags & SI_FL_WANT_PUT) && (ic->flags & CF_SHUTR))
+               si->flags |= SI_FL_ERR;
+
        /* update the stream-int, channels, and possibly wake the stream up */
        stream_int_notify(si);