osaf/services/saf/amf/amfwdog/amf_wdog.c |  6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)


localtime is not thread safe and it can(has) cause crashes in services
that are multi threaded.

diff --git a/osaf/services/saf/amf/amfwdog/amf_wdog.c 
b/osaf/services/saf/amf/amfwdog/amf_wdog.c
--- a/osaf/services/saf/amf/amfwdog/amf_wdog.c
+++ b/osaf/services/saf/amf/amfwdog/amf_wdog.c
@@ -86,14 +86,18 @@ static void amf_healthcheck_callback(SaI
        SaAisErrorT rc;
        time_t local_time;
        static int healthcheck_count;
+       struct tm *tstamp_data, tm_info;
 
        healthcheck_count++;
 
        /* Store latest health check trace */
        local_time = time(NULL);
+       tstamp_data = localtime_r(&local_time, &tm_info);
+       osafassert(tstamp_data);
+
        snprintf(latest_healthcheck_trace, sizeof(latest_healthcheck_trace),
                         "Last received healthcheck cnt=%u at %s",
-                        healthcheck_count, asctime(localtime(&local_time)));
+                        healthcheck_count, asctime(tstamp_data));
 
        rc = saAmfResponse(amf_hdl, inv, SA_AIS_OK);
        if (SA_AIS_OK != rc) {

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to