aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-11-15 19:35:11 -0600
committerMatt Strapp <strap012@umn.edu>2020-11-15 19:35:11 -0600
commit371b12149a61322c9f4b2e1454426f0d0e48c36d (patch)
tree15bcf55868ffc6baed0c5005afbc2241da94ed89
parentwork on many things (diff)
downloadcsci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar.gz
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar.bz2
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar.lz
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar.xz
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.tar.zst
csci4061-371b12149a61322c9f4b2e1454426f0d0e48c36d.zip
Change + among many, many other things
-rw-r--r--P3/server.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/P3/server.c b/P3/server.c
index 21b47c3..a285392 100644
--- a/P3/server.c
+++ b/P3/server.c
@@ -180,7 +180,7 @@ int main(int argc, char **argv) {
//Max cache size
int cSiz = atoi(argv[9]);
- // Perform error checks on the input arguments
+ /* -- ERROR CHECKING -- */
if (port < 1025 || port > 65535) {
printf("Invalid port. Port must be greater than 1024 or less than 65536.\n");
return -1;
@@ -197,9 +197,10 @@ int main(int argc, char **argv) {
printf("Queue length is invalid.\n");
return -1;
}
+ /* -- END ERROR CHECKING -- */
+
// Change SIGINT action for grace termination
struct sigaction act;
- sigset_t sigset;
act.sa_handler = eggs;
act.sa_flags = 0;
if (sigemptyset(&act.sa_mask) == -1 ||
@@ -208,13 +209,19 @@ int main(int argc, char **argv) {
return -1;
}
// Open log file
- FILE* logfile = fopen("webserver_log", "a+");
+ FILE* logfile = fopen("webserver_log", "a");
+
// Change the current working directory to server root directory
if (chdir(path) == -1) {
perror("Directory Change error");
return -1;
}
// Initialize cache (extra credit B)
+ cache_entry_t *dynQ;
+ if (cSiz != 0) {
+ dynQ = (cache_entry_t*) malloc(cSiz * sizeof(cache_entry_t));
+ }
+
// Start the server
init(port);
// Create dispatcher threads (make detachable????)
@@ -263,7 +270,8 @@ int main(int argc, char **argv) {
return -6;
}
// Remove cache (extra credit B)
-
+ if (cSiz != 0)
+ free(dynQ);
printf("All threads have been successfully killed and cache has successfully been cleared.\nExiting now.\n");
return 0;
}