/* 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
tv1; \
})
-char *human_time(int t, short hz);
+char *human_time(int t, short hz_div);
#endif /* _COMMON_TIME_H */
*
*/
+#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
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 */
}
#include <fcntl.h>
#include <unistd.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
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);