From: Nick Mathewson Date: Fri, 7 Sep 2007 01:18:53 +0000 (+0000) Subject: Another tweak on the date patch: win32 has no gmtime_r, but its gmtime() function... X-Git-Tag: release-2.0.1-alpha~583 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=23866b765739016f0723fae22b688a82c14a2b5d;p=libevent Another tweak on the date patch: win32 has no gmtime_r, but its gmtime() function uses thread-local storage for safety. Backportable. svn:r414 --- 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); } }