[dconf] service: avoid making invalid syscalls



commit 4f8a137821db0209f1cf1dc1573ebec0cf513292
Author: Ryan Lortie <desrt desrt ca>
Date:   Sun Dec 19 02:59:50 2010 -0500

    service: avoid making invalid syscalls
    
    If we can't open the shm file then don't bother trying to
    write/close/unlink it.

 service/dconf-writer.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/service/dconf-writer.c b/service/dconf-writer.c
index 71d694c..3cf58f5 100644
--- a/service/dconf-writer.c
+++ b/service/dconf-writer.c
@@ -81,10 +81,17 @@ dconf_writer_touch_shm (DConfWriter *writer)
   gint fd;
 
   fd = open (writer->shm, O_WRONLY);
-  write (fd, &one, sizeof one);
-  close (fd);
 
-  unlink (writer->shm);
+  if (fd >= 0)
+    {
+      write (fd, &one, sizeof one);
+      close (fd);
+
+      unlink (writer->shm);
+    }
+
+  else if (errno != ENOENT)
+    unlink (writer->shm);
 }
 
 gboolean



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