diff options
| author | Michael Stapelberg <michael@stapelberg.de> | 2010-12-13 14:35:08 +0100 |
|---|---|---|
| committer | Michael Stapelberg <michael@stapelberg.de> | 2010-12-13 14:35:08 +0100 |
| commit | 66d0782972410b467bc347c35935e01122f9167b (patch) | |
| tree | c8d974ae26d755d892d0f8cc4a21d1345b0fcf98 /aufgabe4/queue.c | |
| parent | c3b63d651191e765f156d448cdc70b876a4ce3b8 (diff) | |
| download | prozesskommunikation-66d0782972410b467bc347c35935e01122f9167b.tar.gz prozesskommunikation-66d0782972410b467bc347c35935e01122f9167b.tar.bz2 | |
Bugfix: am Anfang jeden Eintrag initialisieren
Diffstat (limited to 'aufgabe4/queue.c')
| -rw-r--r-- | aufgabe4/queue.c | 7 |
1 files changed, 6 insertions, 1 deletions
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) { |
