Project "Tuxbox-GIT: apps":

The branch, master has been updated
       via  fde68c8aeb7303fdcd7dcd01a6e77dc2a2a4ab08 (commit)
      from  b1c0e5df235155d738d46e3310302be5ba82fc9d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fde68c8aeb7303fdcd7dcd01a6e77dc2a2a4ab08
Author: GetAway <get-a...@t-online.de>
Date:   Fri May 15 17:38:26 2015 +0200

    nhttpd: use thread-safe gmtime_r
    
    Signed-off-by: GetAway <get-a...@t-online.de>

diff --git a/tuxbox/neutrino/daemons/nhttpd/yhttpd_core/yhook.cpp 
b/tuxbox/neutrino/daemons/nhttpd/yhttpd_core/yhook.cpp
index 78ff0e0..9a0b796 100644
--- a/tuxbox/neutrino/daemons/nhttpd/yhttpd_core/yhook.cpp
+++ b/tuxbox/neutrino/daemons/nhttpd/yhttpd_core/yhook.cpp
@@ -262,20 +262,21 @@ std::string CyhookHandler::BuildHeader(bool cache)
                        time_t timer = time(0);
                        char timeStr[80];
                        // cache
+                       struct tm lt;
                        if(!cache && (HookVarList["CacheCategory"]).empty() )
                                result += "Cache-Control: no-cache\r\n";
                        else
                        {
                                time_t x_time = time(NULL);
-                               struct tm *ptm = gmtime(&x_time);
-                               ptm->tm_mday+=1;
-                               x_time = mktime(ptm);
-                               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime(&x_time));
+                               gmtime_r(&x_time, &lt);
+                               lt.tm_mday+=1;
+                               x_time = mktime(&lt);
+                               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime_r(&x_time, &lt));
                                result += string_printf("Expires: %s\r\n", 
timeStr);
                        }
                        result += "Server: " WEBSERVERNAME "\r\n";
                        // actual date
-                       strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime(&timer));
+                       strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime_r(&timer, &lt));
                        result += string_printf("Date: %s\r\n", timeStr);
                        // connection type
 #ifdef Y_CONFIG_FEATURE_KEEP_ALIVE
@@ -296,7 +297,7 @@ std::string CyhookHandler::BuildHeader(bool cache)
                                if(LastModified != (time_t)-1)
                                        mod_time = LastModified;
 
-                               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime(&mod_time));
+                               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime_r(&mod_time, &lt));
                                result += string_printf("Last-Modified: 
%s\r\nContent-Length: %ld\r\n", timeStr, GetContentLength());
                        }
                        result += "\r\n";       // End of Header
diff --git a/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_cache.cpp 
b/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_cache.cpp
index c60a7e1..2d439f7 100644
--- a/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_cache.cpp
+++ b/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_cache.cpp
@@ -51,8 +51,9 @@ THandleStatus CmodCache::Hook_PrepareResponse(CyhookHandler 
*hh)
                }
 
                // normalize obj_last_modified to GMT
-               struct tm *tmp = gmtime(&(CacheList[url].created));
-               time_t obj_last_modified_gmt = mktime(tmp);
+               struct tm lt;
+               gmtime_r(&CacheList[url].created, &lt);
+               time_t obj_last_modified_gmt = mktime(&lt);
                bool modified = (if_modified_since == (time_t)-1) || 
(if_modified_since < obj_last_modified_gmt);
 
                // Send file or not-modified header
@@ -210,7 +211,8 @@ void CmodCache::yshowCacheInfo(CyhookHandler *hh)
        {
                TCache *item = &((*i).second);
                char timeStr[80];
-               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime(&(item->created)) );
+               struct tm lt;
+               strftime(timeStr, sizeof(timeStr), RFC1123FMT, 
gmtime_r(&item->created, &lt) );
                yresult += 
string_printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td>" \
                                        "<td><a 
href=\"/y/cache-clear?url=%s\">url</a>&nbsp;" \
                                        "<a 
href=\"/y/cache-clear?category=%s\">category</a></td></tr>\n", 
diff --git a/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_sendfile.cpp 
b/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_sendfile.cpp
index a98a8bf..f259369 100644
--- a/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_sendfile.cpp
+++ b/tuxbox/neutrino/daemons/nhttpd/yhttpd_mods/mod_sendfile.cpp
@@ -112,8 +112,9 @@ THandleStatus 
CmodSendfile::Hook_PrepareResponse(CyhookHandler *hh)
                        }
 
                        // normalize obj_last_modified to GMT
-                       struct tm *tmp = gmtime(&(hh->LastModified));
-                       time_t LastModifiedGMT = mktime(tmp);
+                       struct tm lt;
+                       gmtime_r(&hh->LastModified, &lt);
+                       time_t LastModifiedGMT = mktime(&lt);
                        bool modified = (if_modified_since == (time_t)-1) || 
(if_modified_since < LastModifiedGMT);
 
                        // Send normal or not-modified header

-----------------------------------------------------------------------

Summary of changes:
 .../neutrino/daemons/nhttpd/yhttpd_core/yhook.cpp  |   13 +++++++------
 .../daemons/nhttpd/yhttpd_mods/mod_cache.cpp       |    8 +++++---
 .../daemons/nhttpd/yhttpd_mods/mod_sendfile.cpp    |    5 +++--
 3 files changed, 15 insertions(+), 11 deletions(-)


-- 
Tuxbox-GIT: apps

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Tuxbox-cvs-commits mailing list
Tuxbox-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tuxbox-cvs-commits

Reply via email to