diff options
author | Matt Strapp <strap012@umn.edu> | 2020-11-22 17:15:26 -0600 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-11-22 17:15:26 -0600 |
commit | 743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0 (patch) | |
tree | e53f0c418a306b53aeb229f19ec433a454d4fa04 /P3 | |
parent | Change spacing and learn how to spell (diff) | |
download | csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar.gz csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar.bz2 csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar.lz csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar.xz csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.tar.zst csci4061-743ced619e4e5a3609f0ecea5c9ed9f85c5fcde0.zip |
changes
Diffstat (limited to 'P3')
-rw-r--r-- | P3/.vscode/launch.json | 2 | ||||
-rw-r--r-- | P3/server.c | 15 |
2 files changed, 10 insertions, 7 deletions
diff --git a/P3/.vscode/launch.json b/P3/.vscode/launch.json index c887944..6c97570 100644 --- a/P3/.vscode/launch.json +++ b/P3/.vscode/launch.json @@ -9,7 +9,7 @@ "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/web_server", - "args": ["9000", "testing", "100", "100", "0", "10", "100"], + "args": ["9000", "testing", "100", "100", "0", "100", "100"], "stopAtEntry": false, "cwd": "${workspaceFolder}", diff --git a/P3/server.c b/P3/server.c index 2b0d931..621b54d 100644 --- a/P3/server.c +++ b/P3/server.c @@ -141,10 +141,10 @@ void addIntoCache(char *mybuf, char *memory, int memory_size) { cache_entry_t *temp = dynQ; dynQ = dynQ->next; free(temp->content); - free(temp->request); free(temp); free(silence); - cacheLength--; + // pthread_mutex_lock(&cacheLock); + // pthread_mutex_unlock(&cacheLock); addIntoCache(mybuf, memory, memory_size); } else { //Cache is not full cache_entry_t *temp = (cache_entry_t *)calloc(1, sizeof(cache_entry_t)); @@ -194,7 +194,7 @@ void deleteCache() void initCache(){ // Allocating memory and initializing the cache array - dynQ = (cache_entry_t *)malloc(sizeof(cache_entry_t)); + dynQ = (cache_entry_t *)calloc(1, sizeof(cache_entry_t)); wIndex = 0; cacheLength = 0; } @@ -387,7 +387,9 @@ void *worker(void *arg) { return_result(request->fd, getContentType(request->request), workerBuf, numbytes); } //Free things no longer needed + // free(request->request); free(request); + tempNodeCounter--; free(workerBuf); end_t = clock(); total_t = (double)(end_t - start_t); @@ -424,9 +426,9 @@ int main(int argc, char **argv) { //Dynamic worker flag dynFlag = atoi(argv[5]); //Queue Length - maxQlen = atoi(argv[6]) - 1; + maxQlen = atoi(argv[6]); //Max cache size - maxCSiz = atoi(argv[7]) - 1; + maxCSiz = atoi(argv[7]); /* -- ERROR CHECKING -- */ if (port < 1025 || port > 65535) { @@ -483,7 +485,8 @@ int main(int argc, char **argv) { } //Create workers (make detachable?????) int *Wargs = (int *)malloc(sizeof(int) * workers); - wID = (pthread_t *)malloc(workers * sizeof(pid_t)); + pthread_t *throwaway = (pthread_t *)calloc(workers, sizeof(pid_t)); + wID = throwaway; for (int i = 0; i < workers; i++) { wIndex++; Wargs[i] = i; |