[gegl] buffer: use gegl_buffer_swap() functions in the swap tile-backend
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: use gegl_buffer_swap() functions in the swap tile-backend
- Date: Tue, 11 Dec 2018 10:29:52 +0000 (UTC)
commit 9bf3fd9c26ee01a862922d6e7aab768578ce5f79
Author: Ell <ell_se yahoo com>
Date: Tue Dec 11 05:20:29 2018 -0500
buffer: use gegl_buffer_swap() functions in the swap tile-backend
Actually use the new gegl_buffer_swap() functions, added in commit
b61f9015bf19611225df9832db3cfd9ee2558fc9, when creating the swap
file in the swap tile-backend, so that the swap file follows the
common naming pattern, and gets properly cleaned up on shutdown.
This should have been part of the aforementioned commit.
gegl/buffer/gegl-tile-backend-swap.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-backend-swap.c b/gegl/buffer/gegl-tile-backend-swap.c
index f62fb3704..f4485d3ba 100644
--- a/gegl/buffer/gegl-tile-backend-swap.c
+++ b/gegl/buffer/gegl-tile-backend-swap.c
@@ -26,11 +26,6 @@
#include <string.h>
#include <errno.h>
-#ifdef G_OS_WIN32
-#include <process.h>
-#define getpid() _getpid()
-#endif
-
#include <glib-object.h>
#include <glib/gprintf.h>
#include <glib/gstdio.h>
@@ -39,6 +34,7 @@
#include "gegl-buffer-types.h"
#include "gegl-buffer-backend.h"
#include "gegl-buffer-private.h"
+#include "gegl-buffer-swap.h"
#include "gegl-tile-backend.h"
#include "gegl-tile-backend-swap.h"
#include "gegl-debug.h"
@@ -1103,9 +1099,14 @@ gegl_tile_backend_swap_ensure_exist (void)
{
if (in_fd == -1 || out_fd == -1)
{
- gchar *filename = g_strdup_printf ("%i-shared.swap", getpid ());
- path = g_build_filename (gegl_buffer_config ()->swap, filename, NULL);
- g_free (filename);
+ path = gegl_buffer_swap_create_file ("shared");
+
+ if (! path)
+ {
+ g_warning ("using swap backend, but swap is disabled");
+
+ return;
+ }
GEGL_NOTE (GEGL_DEBUG_TILE_BACKEND, "creating swapfile %s", path);
@@ -1113,7 +1114,13 @@ gegl_tile_backend_swap_ensure_exist (void)
in_fd = g_open (path, O_RDONLY, 0);
if (out_fd == -1 || in_fd == -1)
- g_warning ("Could not open swap file '%s': %s", path, g_strerror (errno));
+ {
+ g_warning ("could not open swap file '%s': %s",
+ path, g_strerror (errno));
+
+ gegl_buffer_swap_remove_file (path);
+ g_clear_pointer (&path, g_free);
+ }
}
}
@@ -1212,6 +1219,12 @@ gegl_tile_backend_swap_cleanup (void)
close (out_fd);
out_fd = -1;
}
+
+ if (path)
+ {
+ gegl_buffer_swap_remove_file (path);
+ g_clear_pointer (&path, g_free);
+ }
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]