MINOR: lua: add function which return true if the channel is full.

Add function which return true if the channel is full. It is
useful for triggering some process when the buffer is full.
This commit is contained in:
Thierry FOURNIER / OZON.IO 2016-11-07 15:28:40 +01:00 committed by Willy Tarreau
parent a7da4d24f5
commit 65192f35d2
4 changed files with 30 additions and 5 deletions

View File

@ -8,12 +8,12 @@ Single
-2
1200 2
1 1 0 1 0 7 50 -1 -1 0.000 1 0.0000 4500 1620 1260 585 4500 1620 5760 2205
2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 9
2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 8
1170 1350 1170 1890 2790 1890 2790 2070 3240 1620 2790 1170
2790 1350 1170 1350 1170 1350
2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 9
2790 1350 1170 1350
2 3 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 8
5760 1350 5760 1890 7380 1890 7380 2070 7830 1620 7380 1170
7380 1350 5760 1350 5760 1350
7380 1350 5760 1350
2 1 1 1 0 7 50 -1 -1 1.000 0 0 -1 1 0 2
5 1 1.00 60.00 120.00
6210 540 6210 1440
@ -51,4 +51,5 @@ Single
4 0 0 50 -1 12 12 0.0000 4 150 720 6300 1110 send()\001
4 0 0 50 -1 12 12 0.0000 4 165 1560 6255 2205 get_out_len()\001
4 0 0 50 -1 16 12 0.0000 4 150 1230 6120 2520 read functions\001
4 1 0 50 -1 16 12 0.0000 4 150 1650 4500 540 both side functions\001
4 1 0 50 -1 16 12 0.0000 4 150 1650 4500 315 both side functions\001
4 1 0 50 -1 12 12 0.0000 4 150 1080 4500 540 is_full()\001

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1070,6 +1070,11 @@ Channel class
:param class_channel channel: The manipulated Channel.
:param integer int: The amount of data which will be forwarded.
.. js:function:: Channel.is_full(channel)
This function returns true if the buffer channel is full.
:returns: a boolean
.. _http_class:

View File

@ -2859,6 +2859,24 @@ __LJMP static int hlua_channel_get_in_len(lua_State *L)
return 1;
}
/* Returns true if the channel is full. */
__LJMP static int hlua_channel_is_full(lua_State *L)
{
struct channel *chn;
int rem;
MAY_LJMP(check_args(L, 1, "is_full"));
chn = MAY_LJMP(hlua_checkchannel(L, 1));
rem = chn->buf->size;
rem -= chn->buf->o; /* Output size */
rem -= chn->buf->i; /* Input size */
rem -= global.tune.maxrewrite; /* Rewrite reserved size */
lua_pushboolean(L, rem <= 0);
return 1;
}
/* Just returns the number of bytes available in the output
* side of the buffer. This function never fails.
*/
@ -6765,6 +6783,7 @@ void hlua_init(void)
hlua_class_function(gL.T, "forward", hlua_channel_forward);
hlua_class_function(gL.T, "get_in_len", hlua_channel_get_in_len);
hlua_class_function(gL.T, "get_out_len", hlua_channel_get_out_len);
hlua_class_function(gL.T, "is_full", hlua_channel_is_full);
lua_rawset(gL.T, -3);