<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/haproxy.git/src/hlua.c, branch haproxy-httpclient-lua-2021-10-06</title>
<subtitle>github.com: haproxy/haproxy.git
</subtitle>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/'/>
<entry>
<title>MINOR: httpclient/lua: supports headers via named arguments</title>
<updated>2021-10-06T13:21:02+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-10-06T08:57:44+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=746e6f3f8efe5646201f8d49d833393bacbc8c02'/>
<id>746e6f3f8efe5646201f8d49d833393bacbc8c02</id>
<content type='text'>
Migrate the httpclient:get() method to named arguments so we can
specify optional arguments.

This allows to pass headers as an optional argument as an array.

The () in the method call must be replaced by {}:

	local res = httpclient:get{url="http://127.0.0.1:9000/?s=99",
	            headers= {["X-foo"]  = { "salt" }, ["X-bar"] = {"pepper" }}}
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Migrate the httpclient:get() method to named arguments so we can
specify optional arguments.

This allows to pass headers as an optional argument as an array.

The () in the method call must be replaced by {}:

	local res = httpclient:get{url="http://127.0.0.1:9000/?s=99",
	            headers= {["X-foo"]  = { "salt" }, ["X-bar"] = {"pepper" }}}
</pre>
</div>
</content>
</entry>
<entry>
<title>BUG/MINOR: httpclient/lua: does not process headers when failed</title>
<updated>2021-10-06T13:15:03+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-10-05T14:19:31+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=ef574b2101458d3af6b4c1453a7b5edadf001b66'/>
<id>ef574b2101458d3af6b4c1453a7b5edadf001b66</id>
<content type='text'>
Do not try to process the header list when it is NULL. This case can
arrive when the request failed and did not return a response.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Do not try to process the header list when it is NULL. This case can
arrive when the request failed and did not return a response.
</pre>
</div>
</content>
</entry>
<entry>
<title>MINOR: httpclient/lua: implement garbage collection</title>
<updated>2021-10-06T13:15:03+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-09-28T17:10:38+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=f77f1de802ae9617f1f64c7169a9d592ee15b9e1'/>
<id>f77f1de802ae9617f1f64c7169a9d592ee15b9e1</id>
<content type='text'>
Implement the garbage collector of the lua httpclient.

This patch declares the __gc method of the httpclient object which only
does a httpclient_stop_and_destroy().
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Implement the garbage collector of the lua httpclient.

This patch declares the __gc method of the httpclient object which only
does a httpclient_stop_and_destroy().
</pre>
</div>
</content>
</entry>
<entry>
<title>MINOR: task: provide 3 task_new_* wrappers to simplify the API</title>
<updated>2021-10-01T16:36:29+00:00</updated>
<author>
<name>Willy Tarreau</name>
<email>w@1wt.eu</email>
</author>
<published>2021-10-01T16:23:30+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=beeabf531468bc2f40845a83e76726130dc9f98e'/>
<id>beeabf531468bc2f40845a83e76726130dc9f98e</id>
<content type='text'>
We'll need to improve the API to pass other arguments in the future, so
let's start to adapt better to the current use cases. task_new() is used:
  - 18 times as task_new(tid_bit)
  - 18 times as task_new(MAX_THREADS_MASK)
  - 2 times with a single bit (in a loop)
  - 1 in the debug code that uses a mask

This patch provides 3 new functions to achieve this:
  - task_new_here()     to create a task on the calling thread
  - task_new_anywhere() to create a task to be run anywhere
  - task_new_on()       to create a task to run on a specific thread

The change is trivial and will allow us to later concentrate the
required adaptations to these 3 functions only. It's still possible
to call task_new() if needed but a comment was added to encourage the
use of the new ones instead. The debug code was not changed and still
uses it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We'll need to improve the API to pass other arguments in the future, so
let's start to adapt better to the current use cases. task_new() is used:
  - 18 times as task_new(tid_bit)
  - 18 times as task_new(MAX_THREADS_MASK)
  - 2 times with a single bit (in a loop)
  - 1 in the debug code that uses a mask

This patch provides 3 new functions to achieve this:
  - task_new_here()     to create a task on the calling thread
  - task_new_anywhere() to create a task to be run anywhere
  - task_new_on()       to create a task to run on a specific thread

The change is trivial and will allow us to later concentrate the
required adaptations to these 3 functions only. It's still possible
to call task_new() if needed but a comment was added to encourage the
use of the new ones instead. The debug code was not changed and still
uses it.
</pre>
</div>
</content>
</entry>
<entry>
<title>BUG/MAJOR: lua: use task_wakeup() to properly run a task once</title>
<updated>2021-09-30T14:26:51+00:00</updated>
<author>
<name>Willy Tarreau</name>
<email>w@1wt.eu</email>
</author>
<published>2021-09-30T14:17:37+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=e3957f83e070fab55853d4803fcb3aba890091ce'/>
<id>e3957f83e070fab55853d4803fcb3aba890091ce</id>
<content type='text'>
The Lua tasks registered vi core.register_task() use a dangerous
task_schedule(task, now_ms) to start them, that will most of the
time work by accident, except when the time wraps every 49.7 days,
if now_ms is 0, because it's not valid to queue a task with an
expiration date set to TICK_ETERNITY, as it will fail all wakeup
checks and prevent all subsequent timers from being seen as expired.
The only solution in this case is to restart the process.

Fortunately for the vast majority of users it is extremely unlikely
to ever be met (only one millisecond every 49.7 days is at risk), but
this can be systematic for a process dealing with 1000 req/s, hence
the major tag.

The bug was introduced in 1.6-dev with commit 24f335340 ("MEDIUM: lua:
add coroutine as tasks."), so the fix must be backported to all stable
branches.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The Lua tasks registered vi core.register_task() use a dangerous
task_schedule(task, now_ms) to start them, that will most of the
time work by accident, except when the time wraps every 49.7 days,
if now_ms is 0, because it's not valid to queue a task with an
expiration date set to TICK_ETERNITY, as it will fail all wakeup
checks and prevent all subsequent timers from being seen as expired.
The only solution in this case is to restart the process.

Fortunately for the vast majority of users it is extremely unlikely
to ever be met (only one millisecond every 49.7 days is at risk), but
this can be systematic for a process dealing with 1000 req/s, hence
the major tag.

The bug was introduced in 1.6-dev with commit 24f335340 ("MEDIUM: lua:
add coroutine as tasks."), so the fix must be backported to all stable
branches.
</pre>
</div>
</content>
</entry>
<entry>
<title>BUG/MEDIUM: lua: fix wakeup condition from sleep()</title>
<updated>2021-09-30T14:26:51+00:00</updated>
<author>
<name>Willy Tarreau</name>
<email>w@1wt.eu</email>
</author>
<published>2021-09-30T14:12:31+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=12c02701d304f29ca74f521cfcc5fe1bc6f3e03d'/>
<id>12c02701d304f29ca74f521cfcc5fe1bc6f3e03d</id>
<content type='text'>
A time comparison was wrong in hlua_sleep_yield(), making the sleep()
code do nothing for periods of 24 days every 49 days. An arithmetic
comparison was performed on now_ms instead of using tick_is_expired().

This bug was added in 1.6-dev by commit 5b8608f1e ("MINOR: lua: core:
add sleep functions") so the fix should be backported to all stable
versions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
A time comparison was wrong in hlua_sleep_yield(), making the sleep()
code do nothing for periods of 24 days every 49 days. An arithmetic
comparison was performed on now_ms instead of using tick_is_expired().

This bug was added in 1.6-dev by commit 5b8608f1e ("MINOR: lua: core:
add sleep functions") so the fix should be backported to all stable
versions.
</pre>
</div>
</content>
</entry>
<entry>
<title>MINOR: h1: Change T-E header parsing to fail if chunked encoding is found twice</title>
<updated>2021-09-28T14:21:25+00:00</updated>
<author>
<name>Christopher Faulet</name>
<email>cfaulet@haproxy.com</email>
</author>
<published>2021-09-28T07:36:25+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=545fbba2733a1f611ce940ecd5fbea1130b6d503'/>
<id>545fbba2733a1f611ce940ecd5fbea1130b6d503</id>
<content type='text'>
According to the RFC7230, "chunked" encoding must not be applied more than
once to a message body. To handle this case, h1_parse_xfer_enc_header() is
now responsible to fail when a parsing error is found. It also fails if the
"chunked" encoding is not the last one for a request.

To help the parsing, two H1 parser flags have been added: H1_MF_TE_CHUNKED
and H1_MF_TE_OTHER. These flags are set, respectively, when "chunked"
encoding and any other encoding are found. H1_MF_CHNK flag is used when
"chunked" encoding is the last one.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
According to the RFC7230, "chunked" encoding must not be applied more than
once to a message body. To handle this case, h1_parse_xfer_enc_header() is
now responsible to fail when a parsing error is found. It also fails if the
"chunked" encoding is not the last one for a request.

To help the parsing, two H1 parser flags have been added: H1_MF_TE_CHUNKED
and H1_MF_TE_OTHER. These flags are set, respectively, when "chunked"
encoding and any other encoding are found. H1_MF_CHNK flag is used when
"chunked" encoding is the last one.
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "head-truc"</title>
<updated>2021-09-24T17:19:37+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-09-24T17:13:04+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=4a4e663771f8d3644b05ad8eab30fe6362d1a45c'/>
<id>4a4e663771f8d3644b05ad8eab30fe6362d1a45c</id>
<content type='text'>
This reverts commit fe67e091859b07dca4622981a8d98a0b64de3cab.

Revert a development/test patch which was accidentely introduced.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit fe67e091859b07dca4622981a8d98a0b64de3cab.

Revert a development/test patch which was accidentely introduced.
</pre>
</div>
</content>
</entry>
<entry>
<title>head-truc</title>
<updated>2021-09-24T17:05:41+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-09-24T14:51:55+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=7d21836bc6b087b27da86a75af23204f4c79e7d4'/>
<id>7d21836bc6b087b27da86a75af23204f4c79e7d4</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>BUG/MINOR: httpclient/lua: return an error on argument check</title>
<updated>2021-09-24T12:57:15+00:00</updated>
<author>
<name>William Lallemand</name>
<email>wlallemand@haproxy.org</email>
</author>
<published>2021-09-24T12:51:44+00:00</published>
<link rel='alternate' type='text/html' href='http://91.123.203.49/cgit/delta/haproxy.git/commit/?id=79416cbd7abe63265d92f4c4dc0bc51a7cb2cf11'/>
<id>79416cbd7abe63265d92f4c4dc0bc51a7cb2cf11</id>
<content type='text'>
src/hlua.c:7074:6: error: variable 'url_str' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (lua_type(L, -1) == LUA_TSTRING)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hlua.c:7079:36: note: uninitialized use occurs here
        hlua_hc-&gt;hc-&gt;req.url = istdup(ist(url_str));
                                          ^~~~~~~

Return an error on the stack if the argument is not a string.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
src/hlua.c:7074:6: error: variable 'url_str' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
        if (lua_type(L, -1) == LUA_TSTRING)
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/hlua.c:7079:36: note: uninitialized use occurs here
        hlua_hc-&gt;hc-&gt;req.url = istdup(ist(url_str));
                                          ^~~~~~~

Return an error on the stack if the argument is not a string.
</pre>
</div>
</content>
</entry>
</feed>
