]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: socket destroy before reading pending data
authorThierry FOURNIER <tfournier@arpalert.org>
Sun, 27 Sep 2015 17:29:38 +0000 (19:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 27 Sep 2015 19:50:26 +0000 (21:50 +0200)
When the channel is down, the applet is waked up. Before this patch,
the applet closes the stream and the unread data are discarded.

After this patch, the stream is not closed except if the buffers are
empty.

It will be closed later by the close function, or by the garbage collector.

src/hlua.c

index c9cbca037b75d9f15918a442567d4ce83d7b0bbf..0c8d1b128b35b5d45bf3e48fae1ef8ef9d234048 100644 (file)
@@ -1555,12 +1555,10 @@ static void hlua_socket_handler(struct appctx *appctx)
        struct stream_interface *si = appctx->owner;
        struct connection *c = objt_conn(si_opposite(si)->end);
 
-       /* Wakeup the main stream if the client connection is closed. */
-       if (!c || channel_output_closed(si_ic(si)) || channel_input_closed(si_oc(si))) {
-               if (appctx->ctx.hlua.socket) {
-                       appctx->ctx.hlua.socket->s = NULL;
-                       appctx->ctx.hlua.socket = NULL;
-               }
+       /* If the connection object is not avalaible, close all the
+        * streams and wakeup everithing waiting for.
+        */
+       if (!c) {
                si_shutw(si);
                si_shutr(si);
                si_ic(si)->flags |= CF_READ_NULL;
@@ -1569,6 +1567,14 @@ static void hlua_socket_handler(struct appctx *appctx)
                return;
        }
 
+       /* If we cant write, wakeup the pending write signals. */
+       if (channel_output_closed(si_ic(si)))
+               hlua_com_wake(&appctx->ctx.hlua.wake_on_write);
+
+       /* If we cant read, wakeup the pending read signals. */
+       if (channel_input_closed(si_oc(si)))
+               hlua_com_wake(&appctx->ctx.hlua.wake_on_read);
+
        /* if the connection is not estabkished, inform the stream that we want
         * to be notified whenever the connection completes.
         */