Ack, Mathi.
----- lennart.l...@ericsson.com wrote: > osaf/services/saf/logsv/lgs/lgs_evt.c | 32 > ++++++++++++++++++++------------ > osaf/services/saf/logsv/lgs/lgs_file.c | 24 > +++++++----------------- > osaf/services/saf/logsv/lgs/lgs_mds.c | 5 +++-- > 3 files changed, 30 insertions(+), 31 deletions(-) > > > Use opensaf time calculation help functions > > diff --git a/osaf/services/saf/logsv/lgs/lgs_evt.c > b/osaf/services/saf/logsv/lgs/lgs_evt.c > --- a/osaf/services/saf/logsv/lgs/lgs_evt.c > +++ b/osaf/services/saf/logsv/lgs/lgs_evt.c > @@ -20,6 +20,7 @@ > #include <limits.h> > > #include "immutil.h" > +#include "osaf_time.h" > > #include "lgs.h" > #include "lgs_util.h" > @@ -1251,19 +1252,26 @@ static uint32_t process_api_evt(lgsv_lgs > goto done; > } > > - // Discard too old messages. Don't discard writes as they are > async, > - // no one is waiting on a response > + /* Discard too old messages. Don't discard writes as they are > async, > + * no one is waiting on a response. > + * Using osaf time functions will guarantee that code works on 32 > and 64 bit > + * systems. > + */ > if (api_type < LGSV_WRITE_LOG_ASYNC_REQ) { > - struct timespec ts; > - osafassert(clock_gettime(CLOCK_MONOTONIC, &ts) == 0); > - > - // convert to milliseconds > - uint64_t entered = (evt->entered_at.tv_sec * 1000) + > - (evt->entered_at.tv_nsec / 1000000); > - uint64_t removed = (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000); > - > - // compare with sync send time used in library > - if ((removed - entered) > (LGS_WAIT_TIME * 10)) { > + struct timespec current_ts, diff_ts; > + osaf_clock_gettime(CLOCK_MONOTONIC, ¤t_ts); > + > + /* Calculate time diff current - entered */ > + if (osaf_timespec_compare(¤t_ts, &evt->entered_at) < 1) { > + LOG_ER("%s - Entered message time > current time", > __FUNCTION__); > + osafassert(0); > + } > + osaf_timespec_subtract(¤t_ts, &evt->entered_at, &diff_ts); > + > + /* Convert to millisec and compare with sync send time used in > + * library > + */ > + if (osaf_timespec_to_millis(&diff_ts) > (LGS_WAIT_TIME * 10)) { > LOG_IN("discarded message from %" PRIx64 " type %u", > evt->fr_dest, api_type); > goto done; > diff --git a/osaf/services/saf/logsv/lgs/lgs_file.c > b/osaf/services/saf/logsv/lgs/lgs_file.c > --- a/osaf/services/saf/logsv/lgs/lgs_file.c > +++ b/osaf/services/saf/logsv/lgs/lgs_file.c > @@ -34,15 +34,14 @@ > > #include "lgs.h" > #include "osaf_utility.h" > - > -#define GETTIME(x) osafassert(clock_gettime(CLOCK_REALTIME, &x) == > 0); > +#include "osaf_time.h" > > pthread_mutex_t lgs_ftcom_mutex; /* For locking communication */ > static pthread_cond_t request_cv; /* File thread waiting for request > */ > static pthread_cond_t answer_cv; /* API waiting for answer (timed) > */ > > /* Max time to wait for file thread to finish */ > -static SaUint32T max_waittime_ms = 500; > +static uint32_t max_waittime_ms = 500; > > struct file_communicate { > bool request_f; /* True if pending request */ > @@ -82,22 +81,13 @@ static int start_file_thread(void); > * @param timeout_time[out] > * @param timeout_ms[in] in ms > */ > -static void get_timeout_time(struct timespec *timeout_time, long int > timeout_ms) > +static void get_timeout_time(struct timespec *timeout_time, uint32_t > timeout_ms) > { > - struct timespec start_time; > - uint64_t millisec1,millisec2; > + struct timespec start_time, add_time; > > - GETTIME(start_time); > - > - /* Convert to ms */ > - millisec1 = (start_time.tv_sec * 1000) + (start_time.tv_nsec / > 1000000); > - > - /* Add timeout time */ > - millisec2 = millisec1+timeout_ms; > - > - /* Convert back to timespec */ > - timeout_time->tv_sec = millisec2 / 1000; > - timeout_time->tv_nsec = (millisec2 % 1000) * 1000000; > + osaf_clock_gettime(CLOCK_REALTIME, &start_time); > + osaf_millis_to_timespec((uint64_t) timeout_ms, &add_time); > + osaf_timespec_add(&start_time, &add_time, timeout_time); > } > > > /***************************************************************************** > diff --git a/osaf/services/saf/logsv/lgs/lgs_mds.c > b/osaf/services/saf/logsv/lgs/lgs_mds.c > --- a/osaf/services/saf/logsv/lgs/lgs_mds.c > +++ b/osaf/services/saf/logsv/lgs/lgs_mds.c > @@ -17,6 +17,7 @@ > > #include <ncsencdec_pub.h> > #include "lgs.h" > +#include "osaf_time.h" > > #define LGS_SVC_PVT_SUBPART_VERSION 1 > #define LGS_WRT_LGA_SUBPART_VER_AT_MIN_MSG_FMT 1 > @@ -890,7 +891,7 @@ static uint32_t mds_rcv(struct ncsmds_ca > > // for all msg types but WRITEs, sample curr time and store in msg > if ((type == LGSV_INITIALIZE_REQ) || (type == LGSV_STREAM_OPEN_REQ)) > { > - osafassert(clock_gettime(CLOCK_MONOTONIC, &evt->entered_at) == > 0); > + osaf_clock_gettime(CLOCK_MONOTONIC, &evt->entered_at); > rc = m_NCS_IPC_SEND(&lgs_mbx, evt, LGS_IPC_PRIO_CTRL_MSGS); > osafassert(rc == NCSCC_RC_SUCCESS); > return NCSCC_RC_SUCCESS; > @@ -899,7 +900,7 @@ static uint32_t mds_rcv(struct ncsmds_ca > prio = getmboxprio(api_info); > > if ((type == LGSV_FINALIZE_REQ) || (type == LGSV_STREAM_CLOSE_REQ)) > { > - osafassert(clock_gettime(CLOCK_MONOTONIC, &evt->entered_at) == > 0); > + osaf_clock_gettime(CLOCK_MONOTONIC, &evt->entered_at); > rc = m_NCS_IPC_SEND(&lgs_mbx, evt, prio); > if (rc != NCSCC_RC_SUCCESS) { > /* Bump prio and try again, should succeed! */ ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel