diff options
author | Matt Strapp <strap012@umn.edu> | 2020-11-03 20:31:48 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-11-03 20:31:48 -0600 |
commit | 6ab33a087efb8ef62a3bb0dd2c99136b68199b72 (patch) | |
tree | d8aff0ba57ef700382ce7d76d9d4929b5fd97b4b /P2 | |
parent | Merge branch 'master' of github.umn.edu:STRAP012/csci4061Projects (diff) | |
download | csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar.gz csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar.bz2 csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar.lz csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar.xz csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.tar.zst csci4061-6ab33a087efb8ef62a3bb0dd2c99136b68199b72.zip |
Revert "error checking"
This reverts commit 2f865378032a459b8b5e80b92cc144c01b692ddb.
Diffstat (limited to '')
-rw-r--r-- | P2/lib/utils.c | 42 |
1 files changed, 11 insertions, 31 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 3ec7526..b8922d4 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -2,8 +2,7 @@ int openQueue() { char cwd [50]; - if(getcwd(cwd, 50) == NULL) - return NULL; + getcwd(cwd, 50); return msgget(ftok(cwd, 4061), 0666 | IPC_CREAT); } int closeQueue(int id) { @@ -22,8 +21,7 @@ char *getChunkData(int mapperID) { struct msgBuffer message = makeMessage(); //Queue ID int mid = openQueue(); - if (msgrcv(mid, &message, MSGSIZE, mapperID, 0) == -1) - exit(-1); + msgrcv(mid, &message, MSGSIZE, mapperID, 0); if (strncmp("END", message.msgText, 3) == 0) return NULL; char* value = malloc(1024); // chunkSize or MSGSIZE? @@ -35,18 +33,11 @@ char *getChunkData(int mapperID) { void sendChunkData(char *inputFile, int nMappers) { struct msgBuffer message = makeMessage(); // open message queue - int msgid; - if (msgid == NULL) - exit(-1); - if (closeQueue(msgid) == -1) - exit(-1); + int msgid = openQueue(); + closeQueue(msgid); msgid = openQueue(); - if (msgid == NULL) - exit(-1); int map = 0; FILE* file = fopen(inputFile, "r"); - if (file == NULL) - exit(-1); // construct chunks of 1024 bytes while(fgets(message.msgText, chunkSize + 1, file) != NULL) { @@ -54,19 +45,15 @@ void sendChunkData(char *inputFile, int nMappers) { while(validChar(message.msgText[i])) { message.msgText[i--] = '\0'; } - if (fseek(file, (i - 1023), SEEK_CUR) == -1) { - break; - } + fseek(file, (i - 1023), SEEK_CUR); message.msgType = (map++ % nMappers) + 1; - if (msgsnd(msgid, &message, MSGSIZE, 0) == -1) - exit(-1); + msgsnd(msgid, &message, MSGSIZE, 0); } for (int i = 1; i <= nMappers; i++) { struct msgBuffer END = {i, "END"}; - if (msgsnd(msgid, &END, MSGSIZE, 0) == -1) - exit(-1); - } + msgsnd(msgid, &END, MSGSIZE, 0); + } fclose(file); } @@ -86,10 +73,7 @@ int getInterData(char *Qkey, int reducerID) { struct msgBuffer message= makeMessage(); //DEBUG! make sure it work. int id = openQueue(); - if (id == NULL) - exit(-1); - if (msgrcv(id, &message, MSGSIZE, reducerID, 0) == -1) - exit(-1); + msgrcv(id, &message, MSGSIZE, reducerID, 0); strcpy(Qkey, message.msgText); return (strncmp("END", message.msgText, 3) != 0); } @@ -103,23 +87,19 @@ void shuffle(int nMappers, int nReducers) { char newpath[100]; sprintf(newpath, "output/MapOut/Map_%d", i); // Removed /, add to current dir DIR *dir = opendir(newpath); - if (dir == NULL) - break; struct dirent* entry; while ((entry = readdir(dir)) != NULL) { if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) continue; sprintf(message.msgText, "%s/%s", newpath, entry -> d_name); message.msgType = (hashFunction(entry -> d_name, nReducers)+1); - if (msgsnd(id, &message, MSGSIZE, 0) == NULL) - exit(-1); + msgsnd(id, &message, MSGSIZE, 0); } closedir(dir); } for (int i = 1; i <= nReducers; i++) { struct msgBuffer END = {i, "END"}; - if (msgsnd(id, &END, MSGSIZE, 0)) - break; + msgsnd(id, &END, MSGSIZE, 0); } } |