e_uuid_store: Handle cases where the store is already present as well as not

This commit is contained in:
Stefan Schmidt 2014-04-11 16:32:48 +02:00
parent 9523d7a93c
commit 19436fe61d
1 changed files with 16 additions and 4 deletions

View File

@ -51,10 +51,16 @@ e_uuid_store_init(void)
store = calloc(1, sizeof(struct uuid_store));
if (store == NULL) return 0;
store->shmfd = shm_open(OBJECT_NAME, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG);
if (store->shmfd < 0)
/* Try to open existing SHM object */
store->shmfd = shm_open(OBJECT_NAME, O_RDWR, S_IRWXU | S_IRWXG);
if (store->shmfd < 0 && errno == ENOENT)
{
ERR("shm_open failed");
INF("shm_open failed to open an existing file %s", OBJECT_NAME);
if (!e_uuid_store_reload()) return 0;
}
else if (store->shmfd < 0)
{
INF("shm_open failed");
return 0;
}
@ -101,7 +107,13 @@ Eina_Bool
e_uuid_store_reload(void)
{
/* After crash reload the table with its POSIX object name from memory */
return EINA_FALSE;
store->shmfd = shm_open(OBJECT_NAME, O_CREAT | O_RDWR, S_IRWXU | S_IRWXG);
if (store->shmfd < 0)
{
INF("shm_open failed");
return EINA_FALSE;
}
return EINA_TRUE;
}
Eina_Bool