Shared mem bugfix 2
This commit is contained in:
18
src/cache.c
18
src/cache.c
@ -36,15 +36,6 @@ int cache_process() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
struct shmid_ds info;
|
||||
if (shmctl(shm_id, IPC_STAT, &info) < 0) goto shmctl_err;
|
||||
info.shm_perm.mode = 0600;
|
||||
if (shmctl(shm_id, IPC_SET, &info) < 0) {
|
||||
shmctl_err:
|
||||
fprintf(stderr, ERR_STR "Unable to update permissions for shared memory: %s" CLR_STR "\n", strerror(errno));
|
||||
return -3;
|
||||
}
|
||||
|
||||
shmdt(cache);
|
||||
void *shm_rw = shmat(shm_id, NULL, 0);
|
||||
if (shm_rw == (void *) -1) {
|
||||
@ -168,6 +159,15 @@ int cache_init() {
|
||||
return -2;
|
||||
}
|
||||
|
||||
struct shmid_ds info;
|
||||
if (shmctl(shm_id, IPC_STAT, &info) < 0) goto shmctl_err;
|
||||
info.shm_perm.mode = 0600;
|
||||
if (shmctl(shm_id, IPC_SET, &info) < 0) {
|
||||
shmctl_err:
|
||||
fprintf(stderr, ERR_STR "Unable to update permissions for shared memory: %s" CLR_STR "\n", strerror(errno));
|
||||
return -6;
|
||||
}
|
||||
|
||||
void *shm = shmat(shm_id, NULL, SHM_RDONLY);
|
||||
if (shm == (void *) -1) {
|
||||
fprintf(stderr, ERR_STR "Unable to attach shared memory (ro): %s" CLR_STR "\n", strerror(errno));
|
||||
|
Reference in New Issue
Block a user