From 66d0782972410b467bc347c35935e01122f9167b Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Mon, 13 Dec 2010 14:35:08 +0100 Subject: Bugfix: am Anfang jeden Eintrag initialisieren --- aufgabe4/queue.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aufgabe4/queue.c b/aufgabe4/queue.c index 9bf2725..373bcd3 100644 --- a/aufgabe4/queue.c +++ b/aufgabe4/queue.c @@ -54,6 +54,7 @@ static void unlock() { * */ void queue_init() { + int c; int fd; int flags = O_RDWR | O_CREAT | O_TRUNC; if ((fd = shm_open("/bts-sem", flags, S_IREAD | S_IWRITE)) == -1) { @@ -76,7 +77,11 @@ void queue_init() { /* Speicher mit 0 initialisieren */ memset(shmheader, 0, sizeof(struct queueheader)); - shmdata->dir = D_INVALID; + struct msg *curmsg = shmdata; + for (c = 0; c < 255; c++) { + curmsg->dir = D_INVALID; + curmsg++; + } /* Semaphor initialisieren */ if (sem_init(&(shmheader->sem), 1, 1) != 0) { -- cgit v1.2.3-70-g09d2