Browse Source

fix ev_tstamp vs. time_t problems in worker_current_timestamp()

personal/stbuehler/wip
Thomas Porzelt 14 years ago
parent
commit
70a495de6f
  1. 2
      include/lighttpd/worker.h
  2. 6
      src/worker.c

2
include/lighttpd/worker.h

@ -42,7 +42,7 @@ struct statistics_t {
if ((srv)->worker_count > 1) g_static_rec_mutex_unlock(lock)
struct worker_ts {
ev_tstamp last_generated;
time_t last_generated;
GString *str;
};
typedef struct worker_ts worker_ts;

6
src/worker.c

@ -157,14 +157,14 @@ GString *worker_current_timestamp(worker *wrk, guint format_ndx) {
gsize len;
struct tm tm;
worker_ts *wts = &g_array_index(wrk->timestamps, worker_ts, format_ndx);
ev_tstamp now = CUR_TS(wrk);
time_t now = (time_t)CUR_TS(wrk);
/* cache hit */
if ((now - wts->last_generated) < 1.0)
if (now == wts->last_generated)
return wts->str;
g_string_set_size(wts->str, 255);
if (!gmtime_r((time_t*)&now, &tm))
if (!gmtime_r(&now, &tm))
return NULL;
len = strftime(wts->str->str, wts->str->allocated_len, g_array_index(wrk->srv->ts_formats, GString*, format_ndx)->str, &tm);
if (len == 0)

Loading…
Cancel
Save