]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUILD] fix 2 minor issues on AIX
authorWilly Tarreau <w@1wt.eu>
Fri, 30 Nov 2007 17:38:35 +0000 (18:38 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 30 Nov 2007 17:38:35 +0000 (18:38 +0100)
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 <string.h> in proxy.c.

include/common/compat.h
include/common/time.h
src/log.c
src/proxy.c
src/time.c

index 1bfe669ab40533325e8bc3389be62ae59a63fb0f..774f9b44c38257d100ba187b50ccd0b153601467 100644 (file)
@@ -33,6 +33,7 @@
 
 /* This is needed on Linux for Netfilter includes */
 #include <sys/socket.h>
+#include <sys/types.h>
 #include <common/config.h>
 
 /* INTBITS
 #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 <linux/netfilter_ipv4.h>
 #endif
index ced4b6bd95619d461be70f29e9c5d02265be8e97..2a4a14264ea75d84ffd8bafea705faa33cee879e 100644 (file)
@@ -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 */
 
index 5566d1a449dd36f4612c615419e7e0615eb2293e..20f9bb4ff9ac6770c158ce895ae6712a107cd114 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -10,6 +10,7 @@
  *
  */
 
+#include <fcntl.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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 */
        }
     
index 640a2c1d82fb3df265d8e4af38bcf9fb1e8bed73..06424c62c13411dbd9897f16ae1534e2a4e045ee 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <fcntl.h>
 #include <unistd.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
index bb98d98cf1254e2ff977567ec8b5da91136d1f65..661c7e25ad5ffc8dd9c24aabfd1ec357d19811fa 100644 (file)
@@ -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);