replace usage of non-threadsafe gmtime() with gmtime_r()
the latter is a standard POSIX function too.
This commit is contained in:
parent
3bb14e0440
commit
732bdd0f56
@ -244,6 +244,7 @@ int add_standard_vars (struct conn_s *connptr)
|
|||||||
char errnobuf[16];
|
char errnobuf[16];
|
||||||
char timebuf[30];
|
char timebuf[30];
|
||||||
time_t global_time;
|
time_t global_time;
|
||||||
|
struct tm tm_buf;
|
||||||
|
|
||||||
snprintf (errnobuf, sizeof errnobuf, "%d", connptr->error_number);
|
snprintf (errnobuf, sizeof errnobuf, "%d", connptr->error_number);
|
||||||
ADD_VAR_RET ("errno", errnobuf);
|
ADD_VAR_RET ("errno", errnobuf);
|
||||||
@ -259,7 +260,7 @@ int add_standard_vars (struct conn_s *connptr)
|
|||||||
|
|
||||||
global_time = time (NULL);
|
global_time = time (NULL);
|
||||||
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
||||||
gmtime (&global_time));
|
gmtime_r (&global_time, &tm_buf));
|
||||||
add_error_variable (connptr, "date", timebuf);
|
add_error_variable (connptr, "date", timebuf);
|
||||||
|
|
||||||
add_error_variable (connptr, "website",
|
add_error_variable (connptr, "website",
|
||||||
|
@ -232,6 +232,7 @@ int http_message_send (http_message_t msg, int fd)
|
|||||||
char timebuf[30];
|
char timebuf[30];
|
||||||
time_t global_time;
|
time_t global_time;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
struct tm tm_buf;
|
||||||
|
|
||||||
assert (is_http_message_valid (msg));
|
assert (is_http_message_valid (msg));
|
||||||
|
|
||||||
@ -254,7 +255,7 @@ int http_message_send (http_message_t msg, int fd)
|
|||||||
/* Output the date */
|
/* Output the date */
|
||||||
global_time = time (NULL);
|
global_time = time (NULL);
|
||||||
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
strftime (timebuf, sizeof (timebuf), "%a, %d %b %Y %H:%M:%S GMT",
|
||||||
gmtime (&global_time));
|
gmtime_r (&global_time, &tm_buf));
|
||||||
write_message (fd, "Date: %s\r\n", timebuf);
|
write_message (fd, "Date: %s\r\n", timebuf);
|
||||||
|
|
||||||
/* Output the content-length */
|
/* Output the content-length */
|
||||||
|
Loading…
Reference in New Issue
Block a user