[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.
This commit is contained in:
Willy Tarreau 2007-11-30 18:38:35 +01:00
parent 4bab24d955
commit c8f24f8ec1
5 changed files with 18 additions and 5 deletions

View 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
@ -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

View 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 */

View File

@ -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 */
}

View 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>

View 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);