On Tue, Sep 04, 2012 at 05:56:14PM +1000, Duncan Hall wrote:
> On 04/09/12 09:37, Willy Tarreau wrote:
> >
> >Have a lot of fun and please report your success/failures,
> >Willy
> >
> >
> 
> Small issue when compiling on CentOS 5.8 64bit against RPM versions of 
> openssl-devel and e2fsprogs-devel-1.39-34.el5_8.1 I get the following:
> 
> make TARGET=linux2628 USE_OPENSSL=1
> gcc -Iinclude -Iebtree -Wall -O2 -g -fno-strict-aliasing 
> -DCONFIG_HAP_LINUX_SPLICE -DTPROXY -DCONFIG_HAP_LINUX_TPROXY 
> -DCONFIG_HAP_CRYPT -DENABLE_POLL -DENABLE_EPOLL -DENABLE_SEPOLL 
> -DNETFILTER -DUSE_GETSOCKNAME -DUSE_OPENSSL -DUSE_SYSCALL_FUTEX 
> -DCONFIG_HAPROXY_VERSION=\"1.5-dev11\" 
> -DCONFIG_HAPROXY_DATE=\"2012/06/04\" \
> -DBUILD_TARGET='"linux2628"' \
> -DBUILD_ARCH='""' \
> -DBUILD_CPU='"generic"' \
> -DBUILD_CC='"gcc"' \
> -DBUILD_CFLAGS='"-O2 -g -fno-strict-aliasing"' \
> -DBUILD_OPTIONS='""' \
> -c -o src/haproxy.o src/haproxy.c
> In file included from src/haproxy.c:83:
> include/proto/proto_http.h:111: error: conflicting types for ?error_message?
> /usr/include/et/com_err.h:37: error: previous declaration of 
> ?error_message? was here
> make: *** [src/haproxy.o] Error 1

This is very strange, this one is as old as 2006 ! I suspect that the
issue comes from new includes which uncovered this conflict. Just got
it too here, it indeed only happens with USE_OPENSSL=1.

Just found another build issue in futex which does not build on RHEL
due to missing u32 declaration. Fixed too. With this it builds for me.

I'm attaching the two patches.

Thanks for the report,
Willy

>From 783f25800cc0b10793817afd1d78615125be3a36 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w...@1wt.eu>
Date: Tue, 4 Sep 2012 12:19:04 +0200
Subject: [PATCH 1/2] BUILD: http: rename error_message http_error_message to 
fix conflicts on RHEL

Duncan Hall reported a build issue on CentOS where error_message conflicts
with another system declaration when SSL is enabled. Rename the function.
---
 include/proto/proto_http.h |    2 +-
 src/proto_http.c           |   56 ++++++++++++++++++++++----------------------
 src/session.c              |    2 +-
 3 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 69d932c..e7ad8ff 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -108,7 +108,7 @@ void http_reset_txn(struct session *s);
 
 struct http_req_rule *parse_http_req_cond(const char **args, const char *file, 
int linenum, struct proxy *proxy);
 void free_http_req_rules(struct list *r);
-struct chunk *error_message(struct session *s, int msgnum);
+struct chunk *http_error_message(struct session *s, int msgnum);
 
 /* to be used when contents change in an HTTP message */
 #define http_msg_move_end(msg, bytes) do { \
diff --git a/src/proto_http.c b/src/proto_http.c
index 4faff52..d7208d2 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -669,7 +669,7 @@ static void http_server_error(struct session *t, struct 
stream_interface *si,
  * and message.
  */
 
-struct chunk *error_message(struct session *s, int msgnum)
+struct chunk *http_error_message(struct session *s, int msgnum)
 {
        if (s->be->errmsg[msgnum].str)
                return &s->be->errmsg[msgnum];
@@ -841,25 +841,25 @@ void http_return_srv_error(struct session *s, struct 
stream_interface *si)
 
        if (err_type & SI_ET_QUEUE_ABRT)
                http_server_error(s, si, SN_ERR_CLICL, SN_FINST_Q,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else if (err_type & SI_ET_CONN_ABRT)
                http_server_error(s, si, SN_ERR_CLICL, SN_FINST_C,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else if (err_type & SI_ET_QUEUE_TO)
                http_server_error(s, si, SN_ERR_SRVTO, SN_FINST_Q,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else if (err_type & SI_ET_QUEUE_ERR)
                http_server_error(s, si, SN_ERR_SRVCL, SN_FINST_Q,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else if (err_type & SI_ET_CONN_TO)
                http_server_error(s, si, SN_ERR_SRVTO, SN_FINST_C,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else if (err_type & SI_ET_CONN_ERR)
                http_server_error(s, si, SN_ERR_SRVCL, SN_FINST_C,
-                                 503, error_message(s, HTTP_ERR_503));
+                                 503, http_error_message(s, HTTP_ERR_503));
        else /* SI_ET_CONN_OTHER and others */
                http_server_error(s, si, SN_ERR_INTERNAL, SN_FINST_C,
-                                 500, error_message(s, HTTP_ERR_500));
+                                 500, http_error_message(s, HTTP_ERR_500));
 }
 
 extern const char sess_term_cond[8];
@@ -2169,7 +2169,7 @@ int http_wait_for_request(struct session *s, struct 
channel *req, int an_bit)
                                session_inc_http_err_ctr(s);
                        }
                        txn->status = 408;
-                       stream_int_retnclose(req->prod, error_message(s, 
HTTP_ERR_408));
+                       stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_408));
                        msg->msg_state = HTTP_MSG_ERROR;
                        req->analysers = 0;
 
@@ -2195,7 +2195,7 @@ int http_wait_for_request(struct session *s, struct 
channel *req, int an_bit)
                        if (msg->err_pos >= 0)
                                http_capture_bad_message(&s->fe->invalid_req, 
s, msg, msg->msg_state, s->fe);
                        txn->status = 400;
-                       stream_int_retnclose(req->prod, error_message(s, 
HTTP_ERR_400));
+                       stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_400));
                        msg->msg_state = HTTP_MSG_ERROR;
                        req->analysers = 0;
 
@@ -2324,14 +2324,14 @@ int http_wait_for_request(struct session *s, struct 
channel *req, int an_bit)
                        if (ret) {
                                /* we fail this request, let's return 503 
service unavail */
                                txn->status = 503;
-                               stream_int_retnclose(req->prod, 
error_message(s, HTTP_ERR_503));
+                               stream_int_retnclose(req->prod, 
http_error_message(s, HTTP_ERR_503));
                                goto return_prx_cond;
                        }
                }
 
                /* nothing to fail, let's reply normaly */
                txn->status = 200;
-               stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_200));
+               stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_200));
                goto return_prx_cond;
        }
 
@@ -2498,7 +2498,7 @@ int http_wait_for_request(struct session *s, struct 
channel *req, int an_bit)
 
        txn->req.msg_state = HTTP_MSG_ERROR;
        txn->status = 400;
-       stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));
+       stream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_400));
 
        s->fe->fe_counters.failed_req++;
        if (s->listener->counters)
@@ -2812,7 +2812,7 @@ int http_process_req_common(struct session *s, struct 
channel *req, int an_bit,
                        txn->status = 403;
                        /* let's log the request time */
                        s->logs.tv_request = now;
-                       stream_int_retnclose(req->prod, error_message(s, 
HTTP_ERR_403));
+                       stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_403));
                        session_inc_http_err_ctr(s);
                        goto return_prx_cond;
                }
@@ -2834,7 +2834,7 @@ int http_process_req_common(struct session *s, struct 
channel *req, int an_bit,
        if (http_req_last_rule && http_req_last_rule->action == 
HTTP_REQ_ACT_DENY) {
                        txn->status = 403;
                        s->logs.tv_request = now;
-                       stream_int_retnclose(req->prod, error_message(s, 
HTTP_ERR_403));
+                       stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_403));
                        session_inc_http_err_ctr(s);
                        s->fe->fe_counters.denied_req++;
                        if (an_bit == AN_REQ_HTTP_PROCESS_BE)
@@ -2855,7 +2855,7 @@ int http_process_req_common(struct session *s, struct 
channel *req, int an_bit,
                        txn->status = 403;
                        /* let's log the request time */
                        s->logs.tv_request = now;
-                       stream_int_retnclose(req->prod, error_message(s, 
HTTP_ERR_403));
+                       stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_403));
                        session_inc_http_err_ctr(s);
                        goto return_prx_cond;
                }
@@ -3215,7 +3215,7 @@ int http_process_req_common(struct session *s, struct 
channel *req, int an_bit,
 
        txn->req.msg_state = HTTP_MSG_ERROR;
        txn->status = 400;
-       stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));
+       stream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_400));
 
        s->fe->fe_counters.failed_req++;
        if (s->listener->counters)
@@ -3500,7 +3500,7 @@ int http_process_request(struct session *s, struct 
channel *req, int an_bit)
        txn->req.msg_state = HTTP_MSG_ERROR;
        txn->status = 400;
        req->analysers = 0;
-       stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));
+       stream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_400));
 
        s->fe->fe_counters.failed_req++;
        if (s->listener->counters)
@@ -3541,7 +3541,7 @@ int http_process_tarpit(struct session *s, struct channel 
*req, int an_bit)
 
        txn->status = 500;
        if (!(req->flags & CF_READ_ERROR))
-               stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_500));
+               stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_500));
 
        req->analysers = 0;
        req->analyse_exp = TICK_ETERNITY;
@@ -3643,7 +3643,7 @@ int http_process_request_body(struct session *s, struct 
channel *req, int an_bit
 
        if ((req->flags & CF_READ_TIMEOUT) || tick_is_expired(req->analyse_exp, 
now_ms)) {
                txn->status = 408;
-               stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_408));
+               stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_408));
 
                if (!(s->flags & SN_ERR_MASK))
                        s->flags |= SN_ERR_CLITO;
@@ -3676,7 +3676,7 @@ int http_process_request_body(struct session *s, struct 
channel *req, int an_bit
  return_bad_req: /* let's centralize all bad requests */
        txn->req.msg_state = HTTP_MSG_ERROR;
        txn->status = 400;
-       stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));
+       stream_int_retnclose(req->prod, http_error_message(s, HTTP_ERR_400));
 
        if (!(s->flags & SN_ERR_MASK))
                s->flags |= SN_ERR_PRXCOND;
@@ -4417,7 +4417,7 @@ int http_request_forward_body(struct session *s, struct 
channel *req, int an_bit
                stream_int_retnclose(req->prod, NULL);
        } else {
                txn->status = 400;
-               stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_400));
+               stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_400));
        }
        req->analysers = 0;
        s->rep->analysers = 0; /* we're in data phase, we want to abort both 
directions */
@@ -4439,7 +4439,7 @@ int http_request_forward_body(struct session *s, struct 
channel *req, int an_bit
                stream_int_retnclose(req->prod, NULL);
        } else {
                txn->status = 502;
-               stream_int_retnclose(req->prod, error_message(s, HTTP_ERR_502));
+               stream_int_retnclose(req->prod, http_error_message(s, 
HTTP_ERR_502));
        }
        req->analysers = 0;
        s->rep->analysers = 0; /* we're in data phase, we want to abort both 
directions */
@@ -4581,7 +4581,7 @@ int http_wait_for_response(struct session *s, struct 
channel *rep, int an_bit)
                        txn->status = 502;
                        rep->prod->flags |= SI_FL_NOLINGER;
                        bi_erase(rep);
-                       stream_int_retnclose(rep->cons, error_message(s, 
HTTP_ERR_502));
+                       stream_int_retnclose(rep->cons, http_error_message(s, 
HTTP_ERR_502));
 
                        if (!(s->flags & SN_ERR_MASK))
                                s->flags |= SN_ERR_PRXCOND;
@@ -4614,7 +4614,7 @@ int http_wait_for_response(struct session *s, struct 
channel *rep, int an_bit)
                        txn->status = 502;
                        rep->prod->flags |= SI_FL_NOLINGER;
                        bi_erase(rep);
-                       stream_int_retnclose(rep->cons, error_message(s, 
HTTP_ERR_502));
+                       stream_int_retnclose(rep->cons, http_error_message(s, 
HTTP_ERR_502));
 
                        if (!(s->flags & SN_ERR_MASK))
                                s->flags |= SN_ERR_SRVCL;
@@ -4639,7 +4639,7 @@ int http_wait_for_response(struct session *s, struct 
channel *rep, int an_bit)
                        txn->status = 504;
                        rep->prod->flags |= SI_FL_NOLINGER;
                        bi_erase(rep);
-                       stream_int_retnclose(rep->cons, error_message(s, 
HTTP_ERR_504));
+                       stream_int_retnclose(rep->cons, http_error_message(s, 
HTTP_ERR_504));
 
                        if (!(s->flags & SN_ERR_MASK))
                                s->flags |= SN_ERR_SRVTO;
@@ -4664,7 +4664,7 @@ int http_wait_for_response(struct session *s, struct 
channel *rep, int an_bit)
                        txn->status = 502;
                        rep->prod->flags |= SI_FL_NOLINGER;
                        bi_erase(rep);
-                       stream_int_retnclose(rep->cons, error_message(s, 
HTTP_ERR_502));
+                       stream_int_retnclose(rep->cons, http_error_message(s, 
HTTP_ERR_502));
 
                        if (!(s->flags & SN_ERR_MASK))
                                s->flags |= SN_ERR_SRVCL;
@@ -5013,7 +5013,7 @@ int http_process_res_common(struct session *t, struct 
channel *rep, int an_bit,
                                        txn->status = 502;
                                        rep->prod->flags |= SI_FL_NOLINGER;
                                        bi_erase(rep);
-                                       stream_int_retnclose(rep->cons, 
error_message(t, HTTP_ERR_502));
+                                       stream_int_retnclose(rep->cons, 
http_error_message(t, HTTP_ERR_502));
                                        if (!(t->flags & SN_ERR_MASK))
                                                t->flags |= SN_ERR_PRXCOND;
                                        if (!(t->flags & SN_FINST_MASK))
diff --git a/src/session.c b/src/session.c
index 3c47937..0f7a9ba 100644
--- a/src/session.c
+++ b/src/session.c
@@ -187,7 +187,7 @@ int session_accept(struct listener *l, int cfd, struct 
sockaddr_storage *addr)
  out_close:
        if (ret < 0 && p->mode == PR_MODE_HTTP) {
                /* critical error, no more memory, try to emit a 500 response */
-               struct chunk *err_msg = error_message(s, HTTP_ERR_500);
+               struct chunk *err_msg = http_error_message(s, HTTP_ERR_500);
                send(cfd, err_msg->str, err_msg->len, 
MSG_DONTWAIT|MSG_NOSIGNAL);
        }
 
-- 
1.7.1

>From 18b2059a75363712075263742e3bd20215787921 Mon Sep 17 00:00:00 2001
From: Willy Tarreau <w...@1wt.eu>
Date: Tue, 4 Sep 2012 12:26:26 +0200
Subject: [PATCH 2/2] BUILD: ssl: fix shctx build on RHEL with futex

On RHEL/CentOS, linux/futex.h uses an u32 type which is never declared
anywhere. Let's set it with a #define in order to fix the issue without
causing conflicts with possible typedefs on other platforms.
---
 src/shctx.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/shctx.c b/src/shctx.c
index 5fe2e7e..c6c6737 100644
--- a/src/shctx.c
+++ b/src/shctx.c
@@ -14,6 +14,9 @@
 #include <sys/mman.h>
 #ifdef USE_SYSCALL_FUTEX
 #include <unistd.h>
+#ifndef u32
+#define u32 unsigned int
+#endif
 #include <linux/futex.h>
 #include <sys/syscall.h>
 #else /* USE_SYSCALL_FUTEX */
-- 
1.7.1

Reply via email to