From 550fd4fc59d7f0ed31801cdd8b5f3dd07eb58235 Mon Sep 17 00:00:00 2001 From: Jan-Piet Mens Date: Tue, 1 Sep 2015 14:02:32 +0200 Subject: [PATCH] init storage with TZ --- http.c | 3 +++ storage.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/http.c b/http.c index f7ad903..5f19687 100644 --- a/http.c +++ b/http.c @@ -128,6 +128,7 @@ int ev_handler(struct mg_connection *conn, enum mg_event ev) return MG_TRUE; case MG_REQUEST: + ctype = mg_get_header(conn, "accept"); if (ctype != NULL) fprintf(stderr, "ACCEPT: %s\n", ctype); @@ -180,6 +181,8 @@ int ev_handler(struct mg_connection *conn, enum mg_event ev) return (MG_FALSE); /* Fail it */ } + storage_init(); + /* GET */ if (!strcmp(conn->uri, "/api/me")) { push_geojson(conn); diff --git a/storage.c b/storage.c index 2f4d94d..015ffb5 100644 --- a/storage.c +++ b/storage.c @@ -26,6 +26,8 @@ void storage_init() { char path[BUFSIZ]; + setenv("TZ", "UTC", 1); + snprintf(path, BUFSIZ, "%s/ghash", STORAGEDIR); gc = gcache_open(path, TRUE); } @@ -223,7 +225,6 @@ int make_times(char *time_from, time_t *s_lo, char *time_to, time_t *s_hi) { time_t now; - setenv("TZ", "UTC", 1); // FIXME: really? time(&now); if (!time_from || !*time_from) {