commit 97bd389935b6a17768dfdba9945850b5ee6a133c
parent e5f6d37cd22d9b06ff29a47a2d39de782da9fb5a
Author: Joris Vink <joris@coders.se>
Date: Tue, 28 Apr 2015 10:20:36 +0200
Use IPC_PRIVATE when creating our shm.
Instead of a homegrown mechanism of finding empty SHM
keys that may or may not be available.
Should fix #44
Diffstat:
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/src/worker.c b/src/worker.c
@@ -78,7 +78,6 @@ void
kore_worker_init(void)
{
size_t len;
- key_t key;
u_int16_t i, cpu;
if (worker_count == 0)
@@ -87,13 +86,9 @@ kore_worker_init(void)
len = sizeof(*accept_lock) +
(sizeof(struct kore_worker) * worker_count);
- shm_accept_key = -1;
- for (key = KORE_SHM_KEY; shm_accept_key == -1; key++) {
- shm_accept_key = shmget(key, len, IPC_CREAT | IPC_EXCL | 0700);
- if (shm_accept_key == -1 && errno != EEXIST)
- fatal("kore_worker_init(): shmget() %s", errno_s);
- }
-
+ shm_accept_key = shmget(IPC_PRIVATE, len, IPC_CREAT | IPC_EXCL | 0700);
+ if (shm_accept_key == -1)
+ fatal("kore_worker_init(): shmget() %s", errno_s);
if ((accept_lock = shmat(shm_accept_key, NULL, 0)) == (void *)-1)
fatal("kore_worker_init(): shmat() %s", errno_s);