From: Alex Rønne Petersen Date: Mon, 12 Sep 2016 08:44:00 +0000 (+0200) Subject: [profiler] Don't flush empty log buffers. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=4533cd91b27686c4e453323ce90fb432db33a790;p=mono.git [profiler] Don't flush empty log buffers. --- diff --git a/mono/profiler/mono-profiler-log.c b/mono/profiler/mono-profiler-log.c index 0785378f04b..87bf160c10a 100644 --- a/mono/profiler/mono-profiler-log.c +++ b/mono/profiler/mono-profiler-log.c @@ -1337,24 +1337,26 @@ dump_buffer (MonoProfiler *profiler, LogBuffer *buf) if (buf->next) dump_buffer (profiler, buf->next); - p = write_int32 (p, BUF_ID); - p = write_int32 (p, buf->cursor - buf->buf); - p = write_int64 (p, buf->time_base); - p = write_int64 (p, buf->ptr_base); - p = write_int64 (p, buf->obj_base); - p = write_int64 (p, buf->thread_id); - p = write_int64 (p, buf->method_base); + if (buf->cursor - buf->buf) { + p = write_int32 (p, BUF_ID); + p = write_int32 (p, buf->cursor - buf->buf); + p = write_int64 (p, buf->time_base); + p = write_int64 (p, buf->ptr_base); + p = write_int64 (p, buf->obj_base); + p = write_int64 (p, buf->thread_id); + p = write_int64 (p, buf->method_base); #if defined (HAVE_SYS_ZLIB) - if (profiler->gzfile) { - gzwrite (profiler->gzfile, hbuf, p - hbuf); - gzwrite (profiler->gzfile, buf->buf, buf->cursor - buf->buf); - } else + if (profiler->gzfile) { + gzwrite (profiler->gzfile, hbuf, p - hbuf); + gzwrite (profiler->gzfile, buf->buf, buf->cursor - buf->buf); + } else #endif - { - fwrite (hbuf, p - hbuf, 1, profiler->file); - fwrite (buf->buf, buf->cursor - buf->buf, 1, profiler->file); - fflush (profiler->file); + { + fwrite (hbuf, p - hbuf, 1, profiler->file); + fwrite (buf->buf, buf->cursor - buf->buf, 1, profiler->file); + fflush (profiler->file); + } } free_buffer (buf, buf->size);