Navigation


Changeset 22:0b3b46da2c12 in freeDiameter for libfreeDiameter/log.c


Ignore:
Timestamp:
Oct 19, 2009, 6:43:09 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Progress on server code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfreeDiameter/log.c

    r2 r22  
    8787}
    8888
    89 /* Write current time into a buffer */
    90 char * fd_log_time ( char * buf, size_t len )
     89/* Write time into a buffer */
     90char * fd_log_time ( struct timespec * ts, char * buf, size_t len )
    9191{
    9292        int ret;
     
    9696       
    9797        /* Get current time */
    98         ret = clock_gettime(CLOCK_REALTIME, &tp);
    99         if (ret != 0) {
    100                 snprintf(buf, len, "%s", strerror(ret));
    101                 return buf;
     98        if (!ts) {
     99                ret = clock_gettime(CLOCK_REALTIME, &tp);
     100                if (ret != 0) {
     101                        snprintf(buf, len, "%s", strerror(ret));
     102                        return buf;
     103                }
     104                ts = &tp;
    102105        }
    103106       
    104         offset += strftime(buf + offset, len - offset, "%D,%T", localtime_r( &tp.tv_sec , &tm ));
    105         offset += snprintf(buf + offset, len - offset, ".%6.6ld", tp.tv_nsec / 1000);
     107        offset += strftime(buf + offset, len - offset, "%D,%T", localtime_r( &ts->tv_sec , &tm ));
     108        offset += snprintf(buf + offset, len - offset, ".%6.6ld", ts->tv_nsec / 1000);
    106109
    107110        return buf;
Note: See TracChangeset for help on using the changeset viewer.