Merge pull request #2852 from alexrp/master
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 8 Apr 2016 04:20:40 +0000 (05:20 +0100)
committermonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 8 Apr 2016 04:20:40 +0000 (05:20 +0100)
[profiler] Fix usage of the lock-free queue API.

* Free nodes hazardously.
* No need to unpoison nodes since we're not reusing them.
* Fix memory leak when emptying coverage queues.

mono/profiler/proflog.c
mono/utils/hazard-pointer.h

index 3d9079f45f73bcea0397a83985bbd5dc445a68de..5f45a01a900d0be060f8f5986070178df41ceb82 100644 (file)
@@ -3516,7 +3516,7 @@ count_queue (MonoLockFreeQueue *queue)
 
        while ((node = mono_lock_free_queue_dequeue (queue))) {
                count++;
-               mono_lock_free_queue_node_free (node);
+               mono_thread_hazardous_try_free (node, free);
        }
 
        return count;
@@ -4352,7 +4352,7 @@ handle_writer_queue_entry (MonoProfiler *prof)
 
                dump_buffer (prof, entry->buffer);
 
-               free (entry);
+               mono_thread_hazardous_try_free (entry, free);
 
                return TRUE;
        }
@@ -4364,7 +4364,6 @@ static void *
 writer_thread (void *arg)
 {
        MonoProfiler *prof = (MonoProfiler *)arg;
-       WriterQueueEntry *entry;
 
        mono_threads_attach_tools_thread ();
        mono_thread_info_set_name (mono_native_thread_id_get (), "Profiler writer");
index 3cb2c0aeba33817f0aad3b33bdb9c906913e6fb9..0102c103f7629785b1eb8c231a88f86269dbc56c 100644 (file)
@@ -10,6 +10,7 @@
 #include <glib.h>
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-membar.h>
+#include <mono/utils/mono-publib.h>
 
 #define HAZARD_POINTER_COUNT 3
 
@@ -29,7 +30,7 @@ typedef enum {
        HAZARD_FREE_ASYNC_CTX,
 } HazardFreeContext;
 
-gboolean mono_thread_hazardous_try_free (gpointer p, MonoHazardousFreeFunc free_func);
+MONO_API gboolean mono_thread_hazardous_try_free (gpointer p, MonoHazardousFreeFunc free_func);
 void mono_thread_hazardous_queue_free (gpointer p, MonoHazardousFreeFunc free_func);
 
 void mono_thread_hazardous_try_free_all (void);