summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrediano Ziglio <fziglio@redhat.com>2015-07-15 14:15:52 +0100
committerChristophe Fergeau <cfergeau@redhat.com>2015-07-20 11:19:28 +0200
commit40537f6a3e3389b8377b0ae790c62ea0da8aa6d8 (patch)
tree9cd749e49348db8d02bece0bbf080596f202b57d
parent660bee0e93598b322b219dd67b3bb35442b25c92 (diff)
reds: Assure we don't have stale statistic files before trying to create a new one
If a previous Qemu executable is not able to delete the statistic file on the next creation with same name (statitics file are based on pid numbers so if pid get reused for another Qemu process you get the same name) it fails as you can't open a file with 0444 permissions (these are the permission used to create these files). This patch assure there are no stale file trying to remove it before the creation of the new one. As file is based on pid and name used for spice you are not deleting another file. Fixes: rhbz#1177326 Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--server/reds.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/server/reds.c b/server/reds.c
index 57ef07aa..c74894a0 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3291,6 +3291,7 @@ static int do_spice_init(SpiceCoreInterface *core_interface)
shm_name_len = strlen(SPICE_STAT_SHM_NAME) + 20;
reds->stat_shm_name = (char *)spice_malloc(shm_name_len);
snprintf(reds->stat_shm_name, shm_name_len, SPICE_STAT_SHM_NAME, getpid());
+ shm_unlink(reds->stat_shm_name);
if ((fd = shm_open(reds->stat_shm_name, O_CREAT | O_RDWR, 0444)) == -1) {
spice_error("statistics shm_open failed, %s", strerror(errno));
}