]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: lua: sockets don't have buffer to write data
authorThierry FOURNIER <tfournier@exceliance.fr>
Mon, 9 Mar 2015 16:51:43 +0000 (17:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 9 Mar 2015 17:46:48 +0000 (18:46 +0100)
When we try to write data in a session from another session, the "req"
buffer is not allowed. This patch try to allocate the buffer. The session
wait if the buffer is not yet avalaible.

src/hlua.c

index 8ddc0b664dd9445df0bb07997dbbfe13ea1ebc94..73bd94c2ac323e4d808031ce9f2115c0ed3d471b 100644 (file)
@@ -1368,6 +1368,16 @@ static int hlua_socket_write_yield(struct lua_State *L,int status, lua_KContext
        if (sent >= buf_len)
                return 1; /* Implicitly return the length sent. */
 
+       /* Check if the buffer is avalaible because HAProxy doesn't allocate
+        * the request buffer if its not required.
+        */
+       if (socket->s->req->buf->size == 0) {
+               if (!session_alloc_recv_buffer(socket->s, &socket->s->req->buf)) {
+                       socket->s->req->prod->flags |= SI_FL_WAIT_ROOM;
+                       goto hlua_socket_write_yield_return;
+               }
+       }
+
        /* Check for avalaible space. */
        len = buffer_total_space(socket->s->si[0].ib->buf);
        if (len <= 0)