kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 9426906225cdcd07337f85f4af6cafe38ebccf25
parent d2447a88488c96618e9795b98006c36600dc19f1
Author: Joris Vink <joris@coders.se>
Date:   Mon, 14 Oct 2013 11:26:11 +0200

Long overdue, let Kore pick its own shm key if the default KORE_SHM_KEY is already taken.

Diffstat:
src/worker.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/worker.c b/src/worker.c @@ -65,6 +65,7 @@ void kore_worker_init(void) { size_t len; + key_t key; u_int16_t i, cpu; if (worker_count == 0) @@ -72,9 +73,14 @@ kore_worker_init(void) len = sizeof(*accept_lock) + (sizeof(struct kore_worker) * worker_count); - shm_accept_key = shmget(KORE_SHM_KEY, len, IPC_CREAT | IPC_EXCL | 0700); - if (shm_accept_key == -1) - fatal("kore_worker_init(): shmget() %s", errno_s); + + 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); + } + if ((accept_lock = shmat(shm_accept_key, NULL, 0)) == NULL) fatal("kore_worker_init(): shmat() %s", errno_s);