commit ced1279f8896f5f8eba07cca7de3e10d2ca4b621
parent 1f938eb81827ab4c3b80ee6d8207797078bbe8bc
Author: Joris Vink <joris@coders.se>
Date: Mon, 15 Jul 2013 11:24:49 +0200
Properly calculate worker offset, otherwise we'll eventually run into trouble.
Diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/worker.c b/src/worker.c
@@ -34,8 +34,9 @@
#endif
#define KORE_SHM_KEY 15000
-#define WORKER(id) \
- (struct kore_worker *)(kore_workers + (sizeof(struct kore_worker) * id))
+#define WORKER(id) \
+ (struct kore_worker *)((u_int8_t *)kore_workers + \
+ (sizeof(struct kore_worker) * id))
struct wlock {
pid_t lock;
@@ -83,7 +84,8 @@ kore_worker_init(void)
accept_lock->current = 0;
accept_lock->workerid = 1;
- kore_workers = (struct kore_worker *)accept_lock + sizeof(*accept_lock);
+ kore_workers = (struct kore_worker *)((u_int8_t *)accept_lock +
+ sizeof(*accept_lock));
memset(kore_workers, 0, sizeof(struct kore_worker) * worker_count);
kore_debug("kore_worker_init(): system has %d cpu's", cpu_count);