[BUG] fix calls to localtime()
authorWilly Tarreau <w@1wt.eu>
Thu, 25 Oct 2007 08:34:16 +0000 (10:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Oct 2007 08:34:16 +0000 (10:34 +0200)
commitfe94460d53439b5425c154c657db698c63de3d62
tree62b9b710ae6f8c46dfb804cc7d9fe6f47ffbe4fd
parent3f0c9761352efc06b498ad43f314b136d92cf05d
[BUG] fix calls to localtime()

localtime() was called with pointers to tv_sec, which is time_t on
some platforms and long on others. A problem was encountered on
Sparc64 under OpenBSD where tv_sec is long (64 bits) and time_t is
32 bits. Since this architecture is big-endian, it exhibited the
bug because localtime() always worked with the high part of the
value which is always zero. This problem was identified and debugged
by Thierry Fournier.

The correct solution is to pass the date by value and not by pointer,
through an intermediate function. The use of localtime_r() instead of
localtime() also made it possible to get rid of the first call to
localtime() since it does not need to allocate memory anymore.
include/common/standard.h
src/haproxy.c
src/log.c
src/proto_http.c
tests/test-log.cfg [new file with mode: 0644]