aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-13 19:16:12 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-13 19:16:12 -0600
commit98563094d78f86ddad16a24fe37c4bd0264d4711 (patch)
tree07c74ba35a440ec86b9aa545da84dfa06e2d4410
parentAdd a tab (diff)
downloadcsci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar.gz
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar.bz2
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar.lz
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar.xz
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.tar.zst
csci4061-98563094d78f86ddad16a24fe37c4bd0264d4711.zip
Add error checking
Diffstat (limited to '')
-rw-r--r--P3/server.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/P3/server.c b/P3/server.c
index 868e0fe..0226e41 100644
--- a/P3/server.c
+++ b/P3/server.c
@@ -131,9 +131,30 @@ int main(int argc, char **argv) {
}
// Get the input args
-
+ int port = argv[3];
+ char* path = argv[4];
+ int dispatchers = argv[5];
+ int workers = argv[6];
+ int dynFlag = argv[7];
+ int qLen = argv[8];
+ int cSiz = argv[9];
// Perform error checks on the input arguments
-
+ if (port < 1025 || port > 65535) {
+ perror("Invalid port. Port must be greater than 1024 or less than 65536.\n");
+ return -1;
+ }
+ if (dispatchers > MAX_THREADS || dispatchers < 1) {
+ perror("Number of dispatchers is invalid. It must be greater than 0 or less than 101.\n");
+ return -1;
+ }
+ if (workers > MAX_THREADS || workers < 1) {
+ perror("Number of dispatchers is invalid. It must be greater than 0 or less than 101.\n");
+ return -1;
+ }
+ if (qLen > MAX_queue_len || qLen <= 0) {
+ perror("Queue length is invalid.\n");
+ return -1;
+ }
// Change SIGINT action for grace termination
// Open log file