From 23866b765739016f0723fae22b688a82c14a2b5d Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 7 Sep 2007 01:18:53 +0000 Subject: [PATCH] Another tweak on the date patch: win32 has no gmtime_r, but its gmtime() function uses thread-local storage for safety. Backportable. svn:r414 --- http.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/http.c b/http.c index 25a04011..892e7159 100644 --- a/http.c +++ b/http.c @@ -352,11 +352,16 @@ evhttp_make_header_response(struct evhttp_connection *evcon, if (evhttp_find_header(req->output_headers, "Date") == NULL) { char date[50]; - struct tm cur; + struct tm cur, *cur_p; time_t t = time(NULL); +#ifdef WIN32 + cur_p = gmtime(&t); +#else gmtime_r(&t, &cur); + cur_p = &cur; +#endif if (strftime(date, sizeof(date), - "%a, %d %b %Y %H:%M:%S GMT", &cur) != 0) { + "%a, %d %b %Y %H:%M:%S GMT", cur_p) != 0) { evhttp_add_header(req->output_headers, "Date", date); } }