From 62d9558a6e7dc6b98b2ef7fe83113040ffb24093 Mon Sep 17 00:00:00 2001 From: --global Date: Sat, 24 Oct 2020 14:18:54 -0500 Subject: Work on getData --- P2/lib/utils.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'P2') diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 2d15d0f..b4e3b84 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -1,14 +1,23 @@ #include "utils.h" char *getChunkData(int mapperID) { + //Message + struct msgBuffer* message; + //Queue ID int mid; + //Queue Key key_t key = 10; mid = msgget(key, 0666); if (mid < 0) { perror("Cannot open queue.\n"); - exit(0); + return NULL; } - + msgrcv(mid, (void *) &message, MSGSIZE, mapperID, 0); + if (strcmp("END", message -> msgText)) { + msgsnd(mid, (void *) "ACK", 3, 0); + } + char* returnValue = message -> msgText; + return returnValue; } // sends chunks of size 1024 to the mappers in RR fashion -- cgit v1.2.3