From: Willy Tarreau Date: Fri, 30 Nov 2007 17:38:35 +0000 (+0100) Subject: [BUILD] fix 2 minor issues on AIX X-Git-Tag: v1.3.14~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c8f24f8ec15ef0a30cda255809013f99b3c7a96d;p=thirdparty%2Fhaproxy.git [BUILD] fix 2 minor issues on AIX AIX does not know about MSG_DONTWAIT. Fortunately, nearly all sockets are already set to O_NONBLOCK, so it's not even required to change the code. It was only necessary to add this fcntl to the log socket which lacked it. The MSG_DONTWAIT value has been defined to zero when unset in order to make the code cleaner and more portable. Also, on AIX, "hz" is defined, which causes a problem with one function parameter in time.c. It's enough to rename the parameter there. Last, fix a missing #include in proxy.c. --- diff --git a/include/common/compat.h b/include/common/compat.h index 1bfe669ab4..774f9b44c3 100644 --- a/include/common/compat.h +++ b/include/common/compat.h @@ -33,6 +33,7 @@ /* This is needed on Linux for Netfilter includes */ #include +#include #include /* INTBITS @@ -54,6 +55,13 @@ #define SHUT_WR 1 #endif +/* AIX does not define MSG_DONTWAIT. We'll define it to zero, and test it + * wherever appropriate. + */ +#ifndef MSG_DONTWAIT +#define MSG_DONTWAIT 0 +#endif + #if defined(TPROXY) && defined(NETFILTER) #include #endif diff --git a/include/common/time.h b/include/common/time.h index ced4b6bd95..2a4a14264e 100644 --- a/include/common/time.h +++ b/include/common/time.h @@ -485,7 +485,7 @@ REGPRM3 static inline struct timeval *__tv_ms_add(struct timeval *tv, const stru tv1; \ }) -char *human_time(int t, short hz); +char *human_time(int t, short hz_div); #endif /* _COMMON_TIME_H */ diff --git a/src/log.c b/src/log.c index 5566d1a449..20f9bb4ff9 100644 --- a/src/log.c +++ b/src/log.c @@ -10,6 +10,7 @@ * */ +#include #include #include #include @@ -165,6 +166,9 @@ void send_log(struct proxy *p, int level, const char *message, ...) return; /* we don't want to receive anything on this socket */ setsockopt(logfd, SOL_SOCKET, SO_RCVBUF, &zero, sizeof(zero)); + /* need for AIX which does not know about MSG_DONTWAIT */ + if (!MSG_DONTWAIT) + fcntl(logfd, F_SETFL, O_NONBLOCK); shutdown(logfd, SHUT_RD); /* does nothing under Linux, maybe needed for others */ } diff --git a/src/proxy.c b/src/proxy.c index 640a2c1d82..06424c62c1 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -12,6 +12,7 @@ #include #include +#include #include #include #include diff --git a/src/time.c b/src/time.c index bb98d98cf1..661c7e25ad 100644 --- a/src/time.c +++ b/src/time.c @@ -142,18 +142,18 @@ REGPRM2 int _tv_isgt(const struct timeval *tv1, const struct timeval *tv2) return __tv_isgt(tv1, tv2); } -char *human_time(int t, short hz) { +char *human_time(int t, short hz_div) { static char rv[sizeof("24855d23h")+1]; // longest of "23h59m" and "59m59s" char *p = rv; int cnt=2; // print two numbers - if (unlikely(t < 0 || hz <= 0)) { + if (unlikely(t < 0 || hz_div <= 0)) { sprintf(p, "?"); return rv; } - if (unlikely(hz > 1)) - t /= hz; + if (unlikely(hz_div > 1)) + t /= hz_div; if (t >= DAY) { p += sprintf(p, "%dd", t / DAY);