]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
EXAMPLES: maintain haproxy 2.8 retrocompatibility for lua mailers script
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 11 Jul 2023 09:32:55 +0000 (11:32 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 11 Jul 2023 14:04:22 +0000 (16:04 +0200)
Because of b58bd97 ("MINOR: hlua_fcn/mailers: handle timeout mail from
mailers section"), latest examples/lua/mailers.lua file wouldn't work
if loaded with haproxy < 2.8.2 (which is not yet released), unless it
is manually recompiled from the latest code sources.

But this can be an issue given that direct URL may be referenced in
guides/tutorials as download link for the the script, independently
from the related haproxy source code revision.
ie: http://git.haproxy.org/?p=haproxy-2.8.git;a=blob_plain;f=examples/lua/mailers.lua;hb=HEAD

Thus, in order to make examples/lua/mailers.lua work with previous 2.8
versions, we ensure that the script stays compatible with pre-b58bd97
code by adding extra checks in the script.

This must be backported in 2.8 with b58bd97

examples/lua/mailers.lua

index 0d146ff173eb391eb984989af862698f0c634a06..1c496d3af9b6919bdfb5345fe98384a93cd4e083 100644 (file)
@@ -57,7 +57,7 @@ function smtp_send_email(server, timeout, domain, from, to, data)
                 end
         end
 
-       if timeout ~= 0 then
+       if timeout ~= nil and timeout > 0 then
                tcp:settimeout(timeout / 1000)
        end