Message ID | 1418834747-5598-4-git-send-email-thomas.wood@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Wed, Dec 17, 2014 at 04:45:46PM +0000, Thomas Wood wrote: > Signed-off-by: Thomas Wood <thomas.wood@intel.com> > --- > lib/igt_core.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/lib/igt_core.c b/lib/igt_core.c > index b98cb41..925d78c 100644 > --- a/lib/igt_core.c > +++ b/lib/igt_core.c > @@ -366,6 +366,23 @@ static void low_mem_killer_disable(bool disable) > } > > #define write_log_msg(x) write(STDERR_FILENO, x, strlen(x)) > +static void clear_log(void) > +{ > + uint8_t i; > + > + pthread_mutex_lock(&log_buffer_mutex); > + > + i = 0; > + do { > + free(log_buffer.entries[i]); > + log_buffer.entries[i] = NULL; > + i++; > + } while (i != 0); > + log_buffer.start = 0; > + log_buffer.end = 0; > + > + pthread_mutex_unlock(&log_buffer_mutex); Too much work. Just log_buffer.start = log_buffer.end under the mutex. The freeing of old entries will be done by new writers, or by process termination. -Chris
diff --git a/lib/igt_core.c b/lib/igt_core.c index b98cb41..925d78c 100644 --- a/lib/igt_core.c +++ b/lib/igt_core.c @@ -366,6 +366,23 @@ static void low_mem_killer_disable(bool disable) } #define write_log_msg(x) write(STDERR_FILENO, x, strlen(x)) +static void clear_log(void) +{ + uint8_t i; + + pthread_mutex_lock(&log_buffer_mutex); + + i = 0; + do { + free(log_buffer.entries[i]); + log_buffer.entries[i] = NULL; + i++; + } while (i != 0); + log_buffer.start = 0; + log_buffer.end = 0; + + pthread_mutex_unlock(&log_buffer_mutex); +} /* this function must be safe to be called inside a signal handler */ static void write_log(void) @@ -409,6 +426,8 @@ static void write_log(void) write_log_msg("--- Log End\n"); pthread_mutex_unlock(&log_buffer_mutex); + + clear_log(); } bool igt_exit_called; @@ -761,6 +780,8 @@ bool __igt_run_subtest(const char *subtest_name) return false; } + clear_log(); + kmsg(KERN_INFO "%s: starting subtest %s\n", command_str, subtest_name); gettime(&subtest_time);
Signed-off-by: Thomas Wood <thomas.wood@intel.com> --- lib/igt_core.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)