From da76459dc21b5af2449af2d36eb95226cb186ce2 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:35:11 +0200 Subject: Adding upstream version 2.6.12. Signed-off-by: Daniel Baumann --- tests/unit/test-inherited-fd.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/unit/test-inherited-fd.py (limited to 'tests/unit/test-inherited-fd.py') diff --git a/tests/unit/test-inherited-fd.py b/tests/unit/test-inherited-fd.py new file mode 100644 index 0000000..b4b076c --- /dev/null +++ b/tests/unit/test-inherited-fd.py @@ -0,0 +1,23 @@ +#!/usr/bin/python +""" +Python wrapper example to test the fd@ function, +You have to bind on fd@${NEWFD} in your haproxy configuration + +The configuration parsing should still work upon a reload with the master-worker +mode. + +""" + +import socket, subprocess, fcntl + +s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) +s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) +flags = fcntl.fcntl(s.fileno(), fcntl.F_GETFD) +flags &= ~fcntl.FD_CLOEXEC +fcntl.fcntl(s.fileno(), fcntl.F_SETFD, flags) + +s.bind((socket.gethostname(), 5555)) +s.listen(1) +FD = s.fileno() + +subprocess.Popen('NEWFD={} ./haproxy -W -f haproxy.cfg'.format(FD), shell=True, close_fds=False) -- cgit v1.2.3