From 8b970c5581b1ef44bb11887e192d8973dee7beae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 2 Feb 2008 07:13:15 +0000 Subject: [PATCH] Use gmtime_r if available as gmtime is not MT-safe. Original commit message from CVS: * configure.ac: * gst-libs/gst/rtsp/gstrtspconnection.c: (add_date_header): Use gmtime_r if available as gmtime is not MT-safe. Fixes bug #511810. --- ChangeLog | 7 +++++++ common | 2 +- configure.ac | 2 +- gst-libs/gst/rtsp/gstrtspconnection.c | 10 ++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98adc93a92..ae92899bcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-02-02 Sebastian Dröge + + * configure.ac: + * gst-libs/gst/rtsp/gstrtspconnection.c: (add_date_header): + Use gmtime_r if available as gmtime is not MT-safe. + Fixes bug #511810. + 2008-02-02 Sebastian Dröge * gst-libs/gst/rtsp/gstrtspconnection.c: (add_date_header): diff --git a/common b/common index 571dce3335..3c5473161c 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 571dce3335f9be76978009b3842c050dbb900e6f +Subproject commit 3c5473161ce19a3530bad279b842d542895b1500 diff --git a/configure.ac b/configure.ac index 6554c4a644..4188b60fd1 100644 --- a/configure.ac +++ b/configure.ac @@ -239,7 +239,7 @@ dnl also, Windows does not have long long AX_CREATE_STDINT_H dnl *** checks for functions *** -AC_CHECK_FUNCS([localtime_r]) +AC_CHECK_FUNCS([localtime_r gmtime_r]) dnl *** checks for types/defines *** diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 9da13fa31b..5f2200af83 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -370,10 +370,20 @@ add_date_header (GstRTSPMessage * message) gchar date_string[100]; time_t t; +#ifdef HAVE_GMTIME_R + struct tm tm_; +#endif + g_get_current_time (&tv); t = (time_t) tv.tv_sec; + +#ifdef HAVE_GMTIME_R + strftime (date_string, sizeof (date_string), "%a, %d %b %Y %H:%M:%S GMT", + gmtime_r (&t, &tm_)); +#else strftime (date_string, sizeof (date_string), "%a, %d %b %Y %H:%M:%S GMT", gmtime (&t)); +#endif gst_rtsp_message_add_header (message, GST_RTSP_HDR_DATE, date_string); }