Accepting request 232846 from network:ha-clustering:Factory

Update to 1.4.25. Amended SR with missing patch information in .changes

OBS-URL: https://build.opensuse.org/request/show/232846
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/haproxy?expand=0&rev=4
This commit is contained in:
Stephan Kulow 2014-05-06 15:38:15 +00:00 committed by Git OBS Bridge
parent a0959c3526
commit 0b429848d7
22 changed files with 675 additions and 202 deletions

View File

@ -1,7 +1,7 @@
From 4a190f7d08857fec82fa0c07e29e8754d0ba9794 Mon Sep 17 00:00:00 2001
From 88c70beb5a24cf200a32c70a8a95865c8e97efb6 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 22 Nov 2013 08:28:03 +0100
Subject: [PATCH 1/5] MEDIUM: add systemd service
Subject: [PATCH 01/15] MEDIUM: add systemd service
---
.gitignore | 1 +
@ -52,5 +52,5 @@ index 000000000000..1a3d2c050f49
+[Install]
+WantedBy=multi-user.target
--
1.8.4
1.8.4.5

View File

@ -1,7 +1,7 @@
From 2e52a44546db246b89817711efec6b046c06d453 Mon Sep 17 00:00:00 2001
From 3fe5ee78e8ff11fc477a979df79c678720e042ea Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 22 Nov 2013 08:29:29 +0100
Subject: [PATCH 2/5] MEDIUM: add haproxy-systemd-wrapper
Subject: [PATCH 02/15] MEDIUM: add haproxy-systemd-wrapper
Currently, to reload haproxy configuration, you have to use "-sf".
@ -40,7 +40,7 @@ index 83d84083ca3e..ec1545a7a3df 100644
dlmalloc.c
00*.patch
diff --git a/Makefile b/Makefile
index 57692fe51ba6..6bb231a0213a 100644
index 60267e2e2b1a..658716a60a80 100644
--- a/Makefile
+++ b/Makefile
@@ -519,7 +519,7 @@ all:
@ -97,7 +97,7 @@ index 57692fe51ba6..6bb231a0213a 100644
@@ -586,6 +597,7 @@ clean:
for dir in . src include/* doc ebtree; do rm -f $$dir/*~ $$dir/*.rej $$dir/core; done
rm -f haproxy-$(VERSION).tar.gz haproxy-$(VERSION)$(SUBVERS).tar.gz
rm -f haproxy-$(VERSION) nohup.out gmon.out
rm -f haproxy-$(VERSION) haproxy-$(VERSION)$(SUBVERS) nohup.out gmon.out
+ rm -f haproxy-systemd-wrapper
tags:
@ -223,5 +223,5 @@ index 000000000000..596801591b9e
+ return EXIT_SUCCESS;
+}
--
1.8.4
1.8.4.5

View File

@ -1,7 +1,7 @@
From 8b79e7c45c86ef57317cbdbf451e49896a8ac239 Mon Sep 17 00:00:00 2001
From 44c4c476fac6efccb07c419873bb6c8d12d565a7 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 22 Nov 2013 08:34:52 +0100
Subject: [PATCH 3/5] MEDIUM: New cli option -Ds for systemd compatibility
Subject: [PATCH 03/15] MEDIUM: New cli option -Ds for systemd compatibility
This patch adds a new option "-Ds" which is exactly like "-D", but instead of
forking n times to get n jobs running and then exiting, prefers to wait for all the
@ -16,7 +16,7 @@ Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
3 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/doc/haproxy.1 b/doc/haproxy.1
index 001de15a2ff9..48717adefab4 100644
index 0150aa753475..26e35a21f0e2 100644
--- a/doc/haproxy.1
+++ b/doc/haproxy.1
@@ -57,6 +57,10 @@ starting up.
@ -43,7 +43,7 @@ index 7c5346b00b2d..d871939db21d 100644
/* list of last checks to perform, depending on config options */
#define LSTCHK_CAP_BIND 0x00000001 /* check that we can bind to any port */
diff --git a/src/haproxy.c b/src/haproxy.c
index 7a09e3fbfd72..494de5c85c29 100644
index 748c5535b37d..67e29b8bc8cc 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -42,6 +42,7 @@
@ -108,7 +108,7 @@ index 7a09e3fbfd72..494de5c85c29 100644
if (!(global.mode & (MODE_FOREGROUND | MODE_DEBUG)))
Warning("<nbproc> is only meaningful in daemon mode. Setting limit to 1 process.\n");
global.nbproc = 1;
@@ -1132,7 +1136,7 @@ int main(int argc, char **argv)
@@ -1133,7 +1137,7 @@ int main(int argc, char **argv)
}
/* open log & pid files before the chroot */
@ -117,7 +117,7 @@ index 7a09e3fbfd72..494de5c85c29 100644
int pidfd;
unlink(global.pidfile);
pidfd = open(global.pidfile, O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -1222,9 +1226,10 @@ int main(int argc, char **argv)
@@ -1223,9 +1227,10 @@ int main(int argc, char **argv)
argv[0], (int)limit.rlim_cur, global.maxconn, global.maxsock, global.maxsock);
}
@ -129,7 +129,7 @@ index 7a09e3fbfd72..494de5c85c29 100644
int proc;
/* the father launches the required number of processes */
@@ -1237,6 +1242,7 @@ int main(int argc, char **argv)
@@ -1238,6 +1243,7 @@ int main(int argc, char **argv)
}
else if (ret == 0) /* child breaks here */
break;
@ -137,7 +137,7 @@ index 7a09e3fbfd72..494de5c85c29 100644
if (pidfile != NULL) {
fprintf(pidfile, "%d\n", ret);
fflush(pidfile);
@@ -1262,8 +1268,13 @@ int main(int argc, char **argv)
@@ -1263,8 +1269,13 @@ int main(int argc, char **argv)
px = px->next;
}
@ -153,5 +153,5 @@ index 7a09e3fbfd72..494de5c85c29 100644
/* if we're NOT in QUIET mode, we should now close the 3 first FDs to ensure
* that we can detach from the TTY. We MUST NOT do it in other cases since
--
1.8.4
1.8.4.5

View File

@ -1,7 +1,8 @@
From f0b6dab91180d0f719ff486b4bdf4ba518436174 Mon Sep 17 00:00:00 2001
From f0eb767ac292c24ed37e5cec2a9a86d773df75d0 Mon Sep 17 00:00:00 2001
From: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Date: Fri, 22 Nov 2013 08:36:01 +0100
Subject: [PATCH 4/5] BUG/MEDIUM: systemd-wrapper: don't leak zombie processes
Subject: [PATCH 04/15] BUG/MEDIUM: systemd-wrapper: don't leak zombie
processes
Formerly, if A was replaced by B, and then B by C before
A finished exiting, we didn't wait for B to finish so it
@ -60,5 +61,5 @@ index 596801591b9e..8499b35188c5 100644
return EXIT_SUCCESS;
}
--
1.8.4
1.8.4.5

View File

@ -1,7 +1,7 @@
From 18d4a296b1a3bcdf6de904582d4766c1345a1b2f Mon Sep 17 00:00:00 2001
From b369ce63274ae800b76d45aed2d451557ac33499 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Fri, 22 Nov 2013 08:37:33 +0100
Subject: [PATCH 5/5] BUILD: stdbool is not portable (again)
Subject: [PATCH 05/15] BUILD: stdbool is not portable (again)
Another build issue on Solaris without c99. Please don't use stdbool.
---
@ -21,5 +21,5 @@ index 8499b35188c5..fb1a7fd92724 100644
#include <stdlib.h>
#include <string.h>
--
1.8.4
1.8.4.5

View File

@ -0,0 +1,54 @@
From 1c9ed41d4cdfdb31381e89f1a8b93df01220fe07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Fri, 22 Nov 2013 11:06:34 +0100
Subject: [PATCH 06/15] MEDIUM: haproxy-systemd-wrapper: Use haproxy in same
directory
Locate the wrapper and use a haproxy executable found in the
same directory.
This patch lets the wrapper work in openSUSE.
---
src/haproxy-systemd-wrapper.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index fb1a7fd92724..6546616b79ee 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -22,15 +22,30 @@ static char *pid_file = "/run/haproxy.pid";
static int main_argc;
static char **main_argv;
+static void locate_haproxy(char *buffer, size_t buffer_size)
+{
+ char* end;
+ readlink("/proc/self/exe", buffer, buffer_size);
+ end = strrchr(buffer, '/');
+ if (end == NULL)
+ strncpy(buffer, "/usr/sbin/haproxy", buffer_size);
+ end[1] = '\0';
+ strncat(buffer, "haproxy", buffer_size);
+}
+
static void spawn_haproxy(char **pid_strv, int nb_pid)
{
- pid_t pid = fork();
+ char haproxy_bin[512];
+ pid_t pid;
+
+ pid = fork();
if (!pid) {
/* 3 for "haproxy -Ds -sf" */
char **argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
int i;
int argno = 0;
- argv[argno++] = SBINDIR"/haproxy";
+ locate_haproxy(haproxy_bin, 512);
+ argv[argno++] = haproxy_bin;
for (i = 0; i < main_argc; ++i)
argv[argno++] = main_argv[i];
argv[argno++] = "-Ds";
--
1.8.4.5

View File

@ -1,32 +0,0 @@
Index: examples/examples.cfg
===================================================================
--- examples/examples.cfg.orig
+++ examples/examples.cfg
@@ -3,8 +3,8 @@
# log 127.0.0.1 local1
maxconn 4000
ulimit-n 8000
- uid 0
- gid 0
+ user haproxy
+ group haproxy
# chroot /tmp
# nbproc 2
# daemon
Index: examples/haproxy.cfg
===================================================================
--- examples/haproxy.cfg.orig
+++ examples/haproxy.cfg
@@ -5,9 +5,9 @@
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
- chroot /usr/share/haproxy
- uid 99
- gid 99
+ chroot /var/lib/haproxy
+ user haproxy
+ group haproxy
daemon
#debug
#quiet

View File

@ -0,0 +1,61 @@
From e2f3c212072dcf1e9b809fc2cb774946eaba665f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Fri, 22 Nov 2013 11:09:39 +0100
Subject: [PATCH 07/15] MEDIUM: systemd-wrapper: Kill child processes when
interrupted
Send SIGINT to child processes when killed. This ensures that
the haproxy process managed by the systemd-wrapper is stopped
when "systemctl stop haproxy.service" is called.
---
src/haproxy-systemd-wrapper.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index 6546616b79ee..d337f4c0d44e 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -83,7 +83,7 @@ static int read_pids(char ***pid_strv)
return read;
}
-static void signal_handler(int signum __attribute__((unused)))
+static void sigusr2_handler(int signum __attribute__((unused)))
{
int i;
char **pid_strv = NULL;
@@ -96,6 +96,21 @@ static void signal_handler(int signum __attribute__((unused)))
free(pid_strv);
}
+static void sigint_handler(int signum __attribute__((unused)))
+{
+ int i, pid;
+ char **pid_strv = NULL;
+ int nb_pid = read_pids(&pid_strv);
+ for (i = 0; i < nb_pid; ++i) {
+ pid = atoi(pid_strv[i]);
+ if (pid > 0) {
+ kill(pid, SIGINT);
+ free(pid_strv[i]);
+ }
+ }
+ free(pid_strv);
+}
+
static void init(int argc, char **argv)
{
while (argc > 1) {
@@ -117,7 +132,8 @@ int main(int argc, char **argv)
init(argc, argv);
- signal(SIGUSR2, &signal_handler);
+ signal(SIGINT, &sigint_handler);
+ signal(SIGUSR2, &sigusr2_handler);
spawn_haproxy(NULL, 0);
while (-1 != wait(NULL) || errno == EINTR);
--
1.8.4.5

View File

@ -1,13 +0,0 @@
Index: Makefile
===================================================================
--- Makefile.orig
+++ Makefile
@@ -460,7 +460,7 @@ ifneq ($(USE_PCRE)$(USE_STATIC_PCRE),)
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
ifneq ($(PCREDIR),)
PCRE_INC := $(PCREDIR)/include
-PCRE_LIB := $(PCREDIR)/lib
+PCRE_LIB := $(PCREDIR)/$(LIB)
endif
ifeq ($(USE_STATIC_PCRE),)

View File

@ -0,0 +1,65 @@
From d581d9a037bfffe7900a1e5a1ec740e67002f974 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Fri, 22 Nov 2013 11:11:54 +0100
Subject: [PATCH 08/15] LOW: systemd-wrapper: Write debug information to stdout
Write the command line used to call haproxy to stdout, as
well as the return code returned by the haproxy process.
---
src/haproxy-systemd-wrapper.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index d337f4c0d44e..4ca86dd3b8c0 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -55,6 +55,12 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
argv[argno++] = pid_strv[i];
}
argv[argno] = NULL;
+
+ printf("%s", "haproxy-systemd-wrapper: executing ");
+ for (i = 0; argv[i]; ++i)
+ printf("%s ", argv[i]);
+ puts("");
+
execv(argv[0], argv);
exit(0);
}
@@ -104,6 +110,7 @@ static void sigint_handler(int signum __attribute__((unused)))
for (i = 0; i < nb_pid; ++i) {
pid = atoi(pid_strv[i]);
if (pid > 0) {
+ printf("haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
kill(pid, SIGINT);
free(pid_strv[i]);
}
@@ -126,9 +133,11 @@ static void init(int argc, char **argv)
int main(int argc, char **argv)
{
+ int status;
+
--argc; ++argv;
- main_argc = argc;
- main_argv = argv;
+ main_argc = argc;
+ main_argv = argv;
init(argc, argv);
@@ -136,7 +145,10 @@ int main(int argc, char **argv)
signal(SIGUSR2, &sigusr2_handler);
spawn_haproxy(NULL, 0);
- while (-1 != wait(NULL) || errno == EINTR);
+ status = -1;
+ while (-1 != wait(&status) || errno == EINTR)
+ ;
+ printf("haproxy-systemd-wrapper: exit, haproxy RC=%d\n", status);
return EXIT_SUCCESS;
}
--
1.8.4.5

View File

@ -1,124 +0,0 @@
From bf1c645a89c2c6df3c35cf489b3dba53e91e69c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Fri, 22 Nov 2013 10:47:27 +0100
Subject: [PATCH] MEDIUM: haproxy-systemd-wrapper: Revised implementation
* Locate haproxy using location of the wrapper
* Kill children when killed
* Write information to stdout
---
src/haproxy-systemd-wrapper.c | 57 +++++++++++++++++++++++++++++++++++++------
1 file changed, 50 insertions(+), 7 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index fb1a7fd92724..4ca86dd3b8c0 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -22,15 +22,30 @@ static char *pid_file = "/run/haproxy.pid";
static int main_argc;
static char **main_argv;
+static void locate_haproxy(char *buffer, size_t buffer_size)
+{
+ char* end;
+ readlink("/proc/self/exe", buffer, buffer_size);
+ end = strrchr(buffer, '/');
+ if (end == NULL)
+ strncpy(buffer, "/usr/sbin/haproxy", buffer_size);
+ end[1] = '\0';
+ strncat(buffer, "haproxy", buffer_size);
+}
+
static void spawn_haproxy(char **pid_strv, int nb_pid)
{
- pid_t pid = fork();
+ char haproxy_bin[512];
+ pid_t pid;
+
+ pid = fork();
if (!pid) {
/* 3 for "haproxy -Ds -sf" */
char **argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
int i;
int argno = 0;
- argv[argno++] = SBINDIR"/haproxy";
+ locate_haproxy(haproxy_bin, 512);
+ argv[argno++] = haproxy_bin;
for (i = 0; i < main_argc; ++i)
argv[argno++] = main_argv[i];
argv[argno++] = "-Ds";
@@ -40,6 +55,12 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
argv[argno++] = pid_strv[i];
}
argv[argno] = NULL;
+
+ printf("%s", "haproxy-systemd-wrapper: executing ");
+ for (i = 0; argv[i]; ++i)
+ printf("%s ", argv[i]);
+ puts("");
+
execv(argv[0], argv);
exit(0);
}
@@ -68,7 +89,7 @@ static int read_pids(char ***pid_strv)
return read;
}
-static void signal_handler(int signum __attribute__((unused)))
+static void sigusr2_handler(int signum __attribute__((unused)))
{
int i;
char **pid_strv = NULL;
@@ -81,6 +102,22 @@ static void signal_handler(int signum __attribute__((unused)))
free(pid_strv);
}
+static void sigint_handler(int signum __attribute__((unused)))
+{
+ int i, pid;
+ char **pid_strv = NULL;
+ int nb_pid = read_pids(&pid_strv);
+ for (i = 0; i < nb_pid; ++i) {
+ pid = atoi(pid_strv[i]);
+ if (pid > 0) {
+ printf("haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
+ kill(pid, SIGINT);
+ free(pid_strv[i]);
+ }
+ }
+ free(pid_strv);
+}
+
static void init(int argc, char **argv)
{
while (argc > 1) {
@@ -96,16 +133,22 @@ static void init(int argc, char **argv)
int main(int argc, char **argv)
{
+ int status;
+
--argc; ++argv;
- main_argc = argc;
- main_argv = argv;
+ main_argc = argc;
+ main_argv = argv;
init(argc, argv);
- signal(SIGUSR2, &signal_handler);
+ signal(SIGINT, &sigint_handler);
+ signal(SIGUSR2, &sigusr2_handler);
spawn_haproxy(NULL, 0);
- while (-1 != wait(NULL) || errno == EINTR);
+ status = -1;
+ while (-1 != wait(&status) || errno == EINTR)
+ ;
+ printf("haproxy-systemd-wrapper: exit, haproxy RC=%d\n", status);
return EXIT_SUCCESS;
}
--
1.8.4

View File

@ -0,0 +1,45 @@
From cb214d574a4d0474427fca9c05ac1a72d075c45e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Tue, 6 May 2014 08:43:11 +0200
Subject: [PATCH 09/15] openSUSE: Configure haproxy user
---
examples/examples.cfg | 4 ++--
examples/haproxy.cfg | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/examples/examples.cfg b/examples/examples.cfg
index 3499e7bd76b0..ed75c758952f 100644
--- a/examples/examples.cfg
+++ b/examples/examples.cfg
@@ -3,8 +3,8 @@ global
# log 127.0.0.1 local1
maxconn 4000
ulimit-n 8000
- uid 0
- gid 0
+ user haproxy
+ group haproxy
# chroot /tmp
# nbproc 2
# daemon
diff --git a/examples/haproxy.cfg b/examples/haproxy.cfg
index 1c71d617716e..6f8a4ac51d0b 100644
--- a/examples/haproxy.cfg
+++ b/examples/haproxy.cfg
@@ -5,9 +5,9 @@ global
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
- chroot /usr/share/haproxy
- uid 99
- gid 99
+ chroot /var/lib/haproxy
+ user haproxy
+ group haproxy
daemon
#debug
#quiet
--
1.8.4.5

View File

@ -0,0 +1,25 @@
From 9f7b45fa88460a20da5d6c907694f2d07eb1a90c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristoffer=20Gr=C3=B6nlund?= <krig@koru.se>
Date: Tue, 6 May 2014 08:44:24 +0200
Subject: [PATCH 10/15] openSUSE: Fix path to PCRE library
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 658716a60a80..99516a819e28 100644
--- a/Makefile
+++ b/Makefile
@@ -460,7 +460,7 @@ ifneq ($(USE_PCRE)$(USE_STATIC_PCRE),)
PCREDIR := $(shell pcre-config --prefix 2>/dev/null || echo /usr/local)
ifneq ($(PCREDIR),)
PCRE_INC := $(PCREDIR)/include
-PCRE_LIB := $(PCREDIR)/lib
+PCRE_LIB := $(PCREDIR)/$(LIB)
endif
ifeq ($(USE_STATIC_PCRE),)
--
1.8.4.5

View File

@ -0,0 +1,42 @@
From 6bc058f3417b98d3c4c8766d50db4dc22a23e550 Mon Sep 17 00:00:00 2001
From: Lukas Tribus <luky-37@hotmail.com>
Date: Tue, 10 Dec 2013 07:32:56 +0100
Subject: [PATCH 11/15] BUILD/MINOR: systemd: fix compiler warning about unused
result
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
BUILD/MINOR: systemd: fix compiler warning about unused result
There is a compiler warning after commit 1b6e75fa84 ("MEDIUM: haproxy-
systemd-wrapper: Use haproxy in same directory"):
src/haproxy-systemd-wrapper.c: In function ‘locate_haproxy’:
src/haproxy-systemd-wrapper.c:28:10: warning: ignoring return value of ‘readlink’, declared with attribute warn_unused_result [-Wunused-result]
Fix the compiler warning by checking the return value of readlink().
---
src/haproxy-systemd-wrapper.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index 4ca86dd3b8c0..c63f41ff7df6 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -24,9 +24,9 @@ static char **main_argv;
static void locate_haproxy(char *buffer, size_t buffer_size)
{
- char* end;
- readlink("/proc/self/exe", buffer, buffer_size);
- end = strrchr(buffer, '/');
+ char* end = NULL;
+ if (readlink("/proc/self/exe", buffer, buffer_size) > 0)
+ end = strrchr(buffer, '/');
if (end == NULL)
strncpy(buffer, "/usr/sbin/haproxy", buffer_size);
end[1] = '\0';
--
1.8.4.5

View File

@ -0,0 +1,51 @@
From e8dcf678f2b3fafd18c09eb957e4d4a83e792d54 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w@1wt.eu>
Date: Mon, 14 Apr 2014 13:34:34 +0200
Subject: [PATCH 12/15] BUG/MEDIUM: systemd-wrapper: fix locating of haproxy
binary
BUG/MEDIUM: systemd-wrapper: fix locating of haproxy binary
OpenBSD complains this way due to strncat() :
src/haproxy-systemd-wrapper.o(.text+0xd5): In function `spawn_haproxy':
src/haproxy-systemd-wrapper.c:33: warning: strcat() is almost always misused, please use strlcat()
In fact, the code before strncat() here is wrong, because it may
dereference a NULL if /proc/self/exe is not readable. So fix it
and get rid of strncat() at the same time.
No backport is needed.
---
src/haproxy-systemd-wrapper.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index c63f41ff7df6..8485dcd11da8 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -24,13 +24,18 @@ static char **main_argv;
static void locate_haproxy(char *buffer, size_t buffer_size)
{
- char* end = NULL;
+ char *end = NULL;
+
if (readlink("/proc/self/exe", buffer, buffer_size) > 0)
end = strrchr(buffer, '/');
- if (end == NULL)
+
+ if (end == NULL) {
strncpy(buffer, "/usr/sbin/haproxy", buffer_size);
+ return;
+ }
end[1] = '\0';
- strncat(buffer, "haproxy", buffer_size);
+ strncpy(end + 1, "haproxy", buffer + buffer_size - (end + 1));
+ buffer[buffer_size - 1] = '\0';
}
static void spawn_haproxy(char **pid_strv, int nb_pid)
--
1.8.4.5

View File

@ -0,0 +1,117 @@
From 07d130730feffcf64ab0709273f09c5374588b85 Mon Sep 17 00:00:00 2001
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 17 Apr 2014 13:39:28 +0300
Subject: [PATCH 13/15] MINOR: systemd wrapper: re-execute on SIGUSR2
MINOR: systemd wrapper: re-execute on SIGUSR2
Re-execute the systemd wrapper on SIGUSR2 and before reloading HAProxy,
making it possible to load a completely new version of HAProxy
(including a new version of the systemd wrapper) gracefully.
Since the wrapper accepts no command-line arguments of its own,
re-execution is signaled using the HAPROXY_SYSTEMD_REEXEC environment
variable.
This is primarily intended to help seamless upgrades of distribution
packages.
---
src/haproxy-systemd-wrapper.c | 54 ++++++++++++++++++++++++++++++++-----------
1 file changed, 40 insertions(+), 14 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index 8485dcd11da8..e373483d5085 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -18,9 +18,11 @@
#include <unistd.h>
#include <sys/wait.h>
+#define REEXEC_FLAG "HAPROXY_SYSTEMD_REEXEC"
+
static char *pid_file = "/run/haproxy.pid";
-static int main_argc;
-static char **main_argv;
+static int wrapper_argc;
+static char **wrapper_argv;
static void locate_haproxy(char *buffer, size_t buffer_size)
{
@@ -42,6 +44,11 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
{
char haproxy_bin[512];
pid_t pid;
+ int main_argc;
+ char **main_argv;
+
+ main_argc = wrapper_argc - 1;
+ main_argv = wrapper_argv + 1;
pid = fork();
if (!pid) {
@@ -96,15 +103,10 @@ static int read_pids(char ***pid_strv)
static void sigusr2_handler(int signum __attribute__((unused)))
{
- int i;
- char **pid_strv = NULL;
- int nb_pid = read_pids(&pid_strv);
+ setenv(REEXEC_FLAG, "1", 1);
+ printf("haproxy-systemd-wrapper: re-executing\n");
- spawn_haproxy(pid_strv, nb_pid);
-
- for (i = 0; i < nb_pid; ++i)
- free(pid_strv[i]);
- free(pid_strv);
+ execv(wrapper_argv[0], wrapper_argv);
}
static void sigint_handler(int signum __attribute__((unused)))
@@ -140,16 +142,40 @@ int main(int argc, char **argv)
{
int status;
+ wrapper_argc = argc;
+ wrapper_argv = argv;
+
--argc; ++argv;
- main_argc = argc;
- main_argv = argv;
-
init(argc, argv);
signal(SIGINT, &sigint_handler);
signal(SIGUSR2, &sigusr2_handler);
- spawn_haproxy(NULL, 0);
+ if (getenv(REEXEC_FLAG) != NULL) {
+ /* We are being re-executed: restart HAProxy gracefully */
+ int i;
+ char **pid_strv = NULL;
+ int nb_pid = read_pids(&pid_strv);
+ sigset_t sigs;
+
+ unsetenv(REEXEC_FLAG);
+ spawn_haproxy(pid_strv, nb_pid);
+
+ /* Unblock SIGUSR2 which was blocked by the signal handler
+ * before re-exec */
+ sigprocmask(SIG_BLOCK, NULL, &sigs);
+ sigdelset(&sigs, SIGUSR2);
+ sigprocmask(SIG_SETMASK, &sigs, NULL);
+
+ for (i = 0; i < nb_pid; ++i)
+ free(pid_strv[i]);
+ free(pid_strv);
+ }
+ else {
+ /* Start a fresh copy of HAProxy */
+ spawn_haproxy(NULL, 0);
+ }
+
status = -1;
while (-1 != wait(&status) || errno == EINTR)
;
--
1.8.4.5

View File

@ -0,0 +1,72 @@
From 21fef94beeba672fff22406d863a5423a27bed23 Mon Sep 17 00:00:00 2001
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 17 Apr 2014 13:39:29 +0300
Subject: [PATCH 14/15] MINOR: systemd wrapper: improve logging
MINOR: systemd wrapper: improve logging
Use standard error for logging messages, as it seems that this gets
messages to the systemd journal more reliably. Also use systemd's
support for specifying log levels via stderr to apply different levels
to messages.
---
src/haproxy-systemd-wrapper.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index e373483d5085..d4baa90c266e 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -19,6 +19,8 @@
#include <sys/wait.h>
#define REEXEC_FLAG "HAPROXY_SYSTEMD_REEXEC"
+#define SD_DEBUG "<7>"
+#define SD_NOTICE "<5>"
static char *pid_file = "/run/haproxy.pid";
static int wrapper_argc;
@@ -68,10 +70,10 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
}
argv[argno] = NULL;
- printf("%s", "haproxy-systemd-wrapper: executing ");
+ fprintf(stderr, SD_DEBUG "haproxy-systemd-wrapper: executing ");
for (i = 0; argv[i]; ++i)
- printf("%s ", argv[i]);
- puts("");
+ fprintf(stderr, "%s ", argv[i]);
+ fprintf(stderr, "\n");
execv(argv[0], argv);
exit(0);
@@ -104,7 +106,7 @@ static int read_pids(char ***pid_strv)
static void sigusr2_handler(int signum __attribute__((unused)))
{
setenv(REEXEC_FLAG, "1", 1);
- printf("haproxy-systemd-wrapper: re-executing\n");
+ fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: re-executing\n");
execv(wrapper_argv[0], wrapper_argv);
}
@@ -117,7 +119,7 @@ static void sigint_handler(int signum __attribute__((unused)))
for (i = 0; i < nb_pid; ++i) {
pid = atoi(pid_strv[i]);
if (pid > 0) {
- printf("haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
+ fprintf(stderr, SD_DEBUG "haproxy-systemd-wrapper: SIGINT -> %d\n", pid);
kill(pid, SIGINT);
free(pid_strv[i]);
}
@@ -180,6 +182,7 @@ int main(int argc, char **argv)
while (-1 != wait(&status) || errno == EINTR)
;
- printf("haproxy-systemd-wrapper: exit, haproxy RC=%d\n", status);
+ fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: exit, haproxy RC=%d\n",
+ status);
return EXIT_SUCCESS;
}
--
1.8.4.5

View File

@ -0,0 +1,28 @@
From 27b806b87289b403728d373020c4aeb5f79eb4bc Mon Sep 17 00:00:00 2001
From: Apollon Oikonomopoulos <apoikos@debian.org>
Date: Thu, 17 Apr 2014 13:39:30 +0300
Subject: [PATCH 15/15] MINOR: systemd wrapper: propagate exit status
MINOR: systemd wrapper: propagate exit status
Use HAProxy's exit status as the systemd wrapper's exit status instead
of always returning EXIT_SUCCESS, permitting the use of systemd's
`Restart = on-failure' logic.
---
src/haproxy-systemd-wrapper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/haproxy-systemd-wrapper.c b/src/haproxy-systemd-wrapper.c
index d4baa90c266e..ba07ebe01ccc 100644
--- a/src/haproxy-systemd-wrapper.c
+++ b/src/haproxy-systemd-wrapper.c
@@ -184,5 +184,5 @@ int main(int argc, char **argv)
fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: exit, haproxy RC=%d\n",
status);
- return EXIT_SUCCESS;
+ return status;
}
--
1.8.4.5

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:680928f4d001be3b59b69d4501f41aeea69e7e56bf183fa032ad6144cf97c7ef
size 836768

3
haproxy-1.4.25.tar.gz Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:84408ec1e37bf308c6b45ae3c7e66f2a9d2f762cb689ab6d322c67bba691db62
size 838775

View File

@ -1,3 +1,54 @@
-------------------------------------------------------------------
Tue May 6 06:12:08 UTC 2014 - kgronlund@suse.com
- update to 1.4.25 (bnc#876438)
- DOC: typo: nosepoll self reference in config guide
- BUG/MINOR: deinit: free fdinfo while doing cleanup
- BUG/MEDIUM: server: set the macro for server's max weight SRV_UWGHT_MAX to SRV_UWGHT_RANGE
- BUG/MINOR: use the same check condition for server as other algorithms
- BUG/MINOR: stream-int: also consider ENOTCONN in addition to EAGAIN for recv()
- BUG/MINOR: fix forcing fastinter in "on-error"
- BUG/MEDIUM: http/auth: Sometimes the authentication credentials can be mix between two requests
- BUG/MAJOR: http: don't emit the send-name-header when no server is available
- BUG/MEDIUM: http: "option checkcache" fails with the no-cache header
- MEDIUM: session: disable lingering on the server when the client aborts
- MINOR: config: warn when a server with no specific port uses rdp-cookie
- MEDIUM: increase chunk-size limit to 2GB-1
- DOC: add a mention about the limited chunk size
- MEDIUM: http: add "redirect scheme" to ease HTTP to HTTPS redirection
- BUILD: proto_tcp: remove a harmless warning
- BUG/MINOR: acl: remove patterns from the tree before freeing them
- BUG/MEDIUM: checks: fix slow start regression after fix attempt
- BUG/MAJOR: server: weight calculation fails for map-based algorithms
- BUG/MINOR: backend: fix target address retrieval in transparent mode
- BUG/MEDIUM: stick: completely remove the unused flag from the store entries
- BUG/MEDIUM: stick-tables: complete the latest fix about store-responses
- BUG/MEDIUM: checks: tracking servers must not inherit the MAINT flag
- BUG/MINOR: stats: report correct throttling percentage for servers in slowstart
- BUG/MINOR: stats: correctly report throttle rate of low weight servers
- BUG/MINOR: checks: successful check completion must not re-enable MAINT servers
- BUG/MEDIUM: stats: the web interface must check the tracked servers before enabling
- BUG/MINOR: channel: initialize xfer_small/xfer_large on new buffers
- BUG/MINOR: stream-int: also consider ENOTCONN in addition to EAGAIN
- BUG/MEDIUM: http: don't start to forward request data before the connect
- DOC: fix misleading information about SIGQUIT
- BUILD: simplify the date and version retrieval in the makefile
- BUILD: prepare the makefile to skip format lines in SUBVERS and VERDATE
- BUILD: use format tags in VERDATE and SUBVERS files
- Reorganized patches and backported fixes for systemd wrapper:
- Renamed 0006-haproxy-1.2.16_config_haproxy_user.patch to 0009-openSUSE-Configure-haproxy-user.patch
- Renamed 0007-haproxy-makefile_lib.patch to 0010-openSUSE-Fix-path-to-PCRE-library.patch
- Removed 0008-MEDIUM-haproxy-systemd-wrapper-Revised-implementatio.patch
- Added 0006-MEDIUM-haproxy-systemd-wrapper-Use-haproxy-in-same-d.patch
- Added 0007-MEDIUM-systemd-wrapper-Kill-child-processes-when-int.patch
- Added 0008-LOW-systemd-wrapper-Write-debug-information-to-stdou.patch
- Added 0011-BUILD-MINOR-systemd-fix-compiler-warning-about-unuse.patch
- Added 0012-BUG-MEDIUM-systemd-wrapper-fix-locating-of-haproxy-b.patch
- Added 0013-MINOR-systemd-wrapper-re-execute-on-SIGUSR2.patch
- Added 0014-MINOR-systemd-wrapper-improve-logging.patch
- Added 0015-MINOR-systemd-wrapper-propagate-exit-status.patch
-------------------------------------------------------------------
Fri Nov 22 09:54:48 UTC 2013 - kgronlund@suse.com

View File

@ -1,7 +1,7 @@
#
# spec file for package haproxy
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -17,7 +17,7 @@
Name: haproxy
Version: 1.4.24
Version: 1.4.25
Release: 0
#
#
@ -35,14 +35,37 @@ Url: http://haproxy.1wt.eu/
Source: http://haproxy.1wt.eu/download/1.4/src/haproxy-%{version}.tar.gz
Source1: %{pkg_name}.init
Source2: http://haproxy.1wt.eu/download/contrib/haproxy.vim
# PATCH-FEATURE-UPSTREAM
Patch1: 0001-MEDIUM-add-systemd-service.patch
# PATCH-FEATURE-UPSTREAM
Patch2: 0002-MEDIUM-add-haproxy-systemd-wrapper.patch
# PATCH-FIX-UPSTREAM
Patch3: 0003-MEDIUM-New-cli-option-Ds-for-systemd-compatibility.patch
# PATCH-FIX-UPSTREAM
Patch4: 0004-BUG-MEDIUM-systemd-wrapper-don-t-leak-zombie-process.patch
# PATCH-FIX-UPSTREAM
Patch5: 0005-BUILD-stdbool-is-not-portable-again.patch
Patch6: 0006-haproxy-1.2.16_config_haproxy_user.patch
Patch7: 0007-haproxy-makefile_lib.patch
Patch8: 0008-MEDIUM-haproxy-systemd-wrapper-Revised-implementatio.patch
# PATCH-FIX-UPSTREAM
Patch6: 0006-MEDIUM-haproxy-systemd-wrapper-Use-haproxy-in-same-d.patch
# PATCH-FIX-UPSTREAM
Patch7: 0007-MEDIUM-systemd-wrapper-Kill-child-processes-when-int.patch
# PATCH-FIX-UPSTREAM
Patch8: 0008-LOW-systemd-wrapper-Write-debug-information-to-stdou.patch
# PATCH-FIX-OPENSUSE
Patch9: 0009-openSUSE-Configure-haproxy-user.patch
# PATCH-FIX-OPENSUSE
Patch10: 0010-openSUSE-Fix-path-to-PCRE-library.patch
# PATCH-FIX-UPSTREAM
Patch11: 0011-BUILD-MINOR-systemd-fix-compiler-warning-about-unuse.patch
# PATCH-FIX-UPSTREAM
Patch12: 0012-BUG-MEDIUM-systemd-wrapper-fix-locating-of-haproxy-b.patch
# PATCH-FIX-UPSTREAM
Patch13: 0013-MINOR-systemd-wrapper-re-execute-on-SIGUSR2.patch
# PATCH-FIX-UPSTREAM
Patch14: 0014-MINOR-systemd-wrapper-improve-logging.patch
# PATCH-FIX-UPSTREAM
Patch15: 0015-MINOR-systemd-wrapper-propagate-exit-status.patch
Source99: haproxy-rpmlintrc
#
Summary: The Reliable, High Performance TCP/HTTP Load Balancer
@ -73,9 +96,16 @@ the most work done from every CPU cycle.
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p0
%patch7 -p0
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%build
%{__make} \