[gegl/soc-2013-opecl-ops] gegl: close the swap writer thread and file handles when exiting



commit 1d739c1500c5ca92dbb6d4c781d0a2f2e618eb00
Author: Ville Sokk <ville sokk gmail com>
Date:   Thu Aug 15 16:00:39 2013 +0300

    gegl: close the swap writer thread and file handles when exiting

 gegl/buffer/gegl-buffer-private.h    |    2 ++
 gegl/buffer/gegl-tile-backend-swap.c |    4 ++++
 gegl/gegl-init.c                     |    1 +
 3 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 4d8ffad..546f4b0 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -98,6 +98,8 @@ void              gegl_tile_cache_init    (void);
 
 void              gegl_tile_cache_destroy (void);
 
+void              gegl_tile_backend_swap_cleanup (void);
+
 GeglTileBackend * gegl_buffer_backend     (GeglBuffer *buffer);
 GeglTileBackend * gegl_buffer_backend2    (GeglBuffer *buffer); /* non-cached */
 
diff --git a/gegl/buffer/gegl-tile-backend-swap.c b/gegl/buffer/gegl-tile-backend-swap.c
index 964edac..bbb863c 100644
--- a/gegl/buffer/gegl-tile-backend-swap.c
+++ b/gegl/buffer/gegl-tile-backend-swap.c
@@ -868,15 +868,19 @@ gegl_tile_backend_swap_cleanup (void)
 
       if (g_queue_get_length (queue) != 0)
         g_warning ("tile-backend-swap writer queue wasn't empty before freeing\n");
+
       g_queue_free (queue);
 
       if (g_list_length (gap_list) > 1)
         g_warning ("tile-backend-swap gap list had more than one element\n");
+
       g_slice_free (SwapGap, gap_list->data);
       g_list_free (gap_list);
 
       close (in_fd);
       close (out_fd);
+
+      in_fd = out_fd = -1;
     }
 }
 
diff --git a/gegl/gegl-init.c b/gegl/gegl-init.c
index e0bd90b..60a1b20 100644
--- a/gegl/gegl-init.c
+++ b/gegl/gegl-init.c
@@ -393,6 +393,7 @@ gegl_exit (void)
 
   GEGL_INSTRUMENT_START()
 
+  gegl_tile_backend_swap_cleanup ();
   gegl_tile_cache_destroy ();
   gegl_operation_gtype_cleanup ();
   gegl_extension_handler_cleanup ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]