[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 <string.h> in proxy.c.
diff --git a/include/common/compat.h b/include/common/compat.h
index 1bfe669..774f9b4 100644
--- a/include/common/compat.h
+++ b/include/common/compat.h
@@ -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
@@ -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 <linux/netfilter_ipv4.h>
#endif
diff --git a/include/common/time.h b/include/common/time.h
index ced4b6b..2a4a142 100644
--- a/include/common/time.h
+++ b/include/common/time.h
@@ -485,7 +485,7 @@
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 5566d1a..20f9bb4 100644
--- 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 @@
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 640a2c1..06424c6 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -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>
diff --git a/src/time.c b/src/time.c
index bb98d98..661c7e2 100644
--- a/src/time.c
+++ b/src/time.c
@@ -142,18 +142,18 @@
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);