Browse Source

Poison non-thread-safe functions and fix errors

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
f4f2bd1f38
  1. 10
      include/lighttpd/settings.h
  2. 6
      src/angel/angel_log.c
  3. 6
      src/main/log.c
  4. 6
      src/main/server.c

10
include/lighttpd/settings.h

@ -208,4 +208,14 @@
#include <lighttpd/sys-process.h>
#include <lighttpd/sys-socket.h>
#if( 2 < __GNUC__ )
#pragma GCC poison strtok asctime ctime tmpnam strerror
#ifdef HAVE_LOCALTIME_R
#pragma GCC poison localtime
#endif
#ifdef HAVE_GMTIME_R
#pragma GCC poison gmtime
#endif
#endif
#endif

6
src/angel/angel_log.c

@ -48,8 +48,14 @@ void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar
if (cur_ts != srv->log.last_ts) {
gsize s;
struct tm tm;
g_string_set_size(log_ts, 255);
#ifdef HAVE_LOCALTIME_R
s = strftime(log_ts->str, log_ts->allocated_len, "%Y-%m-%d %H:%M:%S %Z: ", localtime_r(&cur_ts, &tm));
#else
s = strftime(log_ts->str, log_ts->allocated_len, "%Y-%m-%d %H:%M:%S %Z: ", localtime(&cur_ts));
#endif
g_string_set_size(log_ts, s);

6
src/main/log.c

@ -106,9 +106,15 @@ gboolean li_log_write_(liServer *srv, liVRequest *vr, liLogLevel log_level, guin
if (cur_ts != ts->last_ts) {
gsize s;
struct tm tm;
g_string_set_size(ts->cached, 255);
#ifdef HAVE_LOCALTIME_R
s = strftime(ts->cached->str, ts->cached->allocated_len,
ts->format->str, localtime_r(&cur_ts, &tm));
#else
s = strftime(ts->cached->str, ts->cached->allocated_len,
ts->format->str, localtime(&cur_ts));
#endif
g_string_set_size(ts->cached, s);

6
src/main/server.c

@ -414,10 +414,16 @@ GString *li_server_current_timestamp() {
if (cur_ts != *last_ts) {
gsize s;
struct tm tm;
g_string_set_size(ts_str, 255);
#ifdef HAVE_GMTIME_R
s = strftime(ts_str->str, ts_str->allocated_len,
"%a, %d %b %Y %H:%M:%S GMT", gmtime_r(&cur_ts, &tm));
#else
s = strftime(ts_str->str, ts_str->allocated_len,
"%a, %d %b %Y %H:%M:%S GMT", gmtime(&cur_ts));
#endif
g_string_set_size(ts_str, s);
*last_ts = cur_ts;
}

Loading…
Cancel
Save