diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/iobuf.c | 5 | ||||
-rw-r--r-- | common/logging.c | 27 | ||||
-rw-r--r-- | common/logging.h | 2 |
3 files changed, 32 insertions, 2 deletions
diff --git a/common/iobuf.c b/common/iobuf.c index 3ba3582d0..a3058303d 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2311,7 +2311,7 @@ iobuf_seek (iobuf_t a, off_t newpos) } clearerr (fp); } - else + else if (a->use != 3) /* Not a temp stream. */ { for (; a; a = a->chain) { @@ -2338,7 +2338,8 @@ iobuf_seek (iobuf_t a, off_t newpos) } #endif } - a->d.len = 0; /* discard buffer */ + if (a->use != 3) + a->d.len = 0; /* Discard the buffer unless it is a temp stream. */ a->d.start = 0; a->nbytes = 0; a->nlimit = 0; diff --git a/common/logging.c b/common/logging.c index f91671e79..cdfd6597c 100644 --- a/common/logging.c +++ b/common/logging.c @@ -857,6 +857,33 @@ log_printhex (const char *text, const void *buffer, size_t length) } +void +log_clock (const char *string) +{ +#if 0 + static unsigned long long initial; + struct timespec tv; + unsigned long long now; + + if (clock_gettime (CLOCK_REALTIME, &tv)) + { + log_debug ("error getting the realtime clock value\n"); + return; + } + now = tv.tv_sec * 1000000000ull; + now += tv.tv_nsec; + + if (!initial) + initial = now; + + log_debug ("[%6llu] %s", (now - initial)/1000, string); +#else + /* You need to link with -ltr to enable the above code. */ + log_debug ("[not enabled in the source] %s", string); +#endif +} + + #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) void bug_at( const char *file, int line, const char *func ) diff --git a/common/logging.h b/common/logging.h index b0d662b71..89913e6e5 100644 --- a/common/logging.h +++ b/common/logging.h @@ -96,5 +96,7 @@ void log_flush (void); by the hexdump and a final LF. */ void log_printhex (const char *text, const void *buffer, size_t length); +void log_clock (const char *string); + #endif /*LIBJNLIB_LOGGING_H*/ |