Compare commits
13 Commits
main
..
cb07e3a8a3
| Author | SHA1 | Date | |
|---|---|---|---|
|
cb07e3a8a3
|
|||
|
2ca8281f85
|
|||
|
56c8cb0add
|
|||
|
d6322207a5
|
|||
|
b7dd087386
|
|||
|
1527c805ef
|
|||
|
783124608e
|
|||
|
8ee22e431f
|
|||
|
ed7f60ec70
|
|||
|
58b80a10d1
|
|||
|
0a534ac0c0
|
|||
|
6ba105a14b
|
|||
|
68bc009fe9
|
@@ -2,4 +2,3 @@ httpserver
|
|||||||
compile_commands.json
|
compile_commands.json
|
||||||
bin/
|
bin/
|
||||||
config.json
|
config.json
|
||||||
.cache/
|
|
||||||
|
|||||||
@@ -3,6 +3,3 @@
|
|||||||
Final extra credit assignment for UCSC CSE130 Spring 2026.
|
Final extra credit assignment for UCSC CSE130 Spring 2026.
|
||||||
|
|
||||||
Build with `make` and run with `./httpserver <port>`.
|
Build with `make` and run with `./httpserver <port>`.
|
||||||
|
|
||||||
While I don't think it will come up, note that `assignment.pdf` is not mine and
|
|
||||||
is *NOT* AGPL'ed. It is just here for easy access.
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"course": "CSE130-W26-BRANDT",
|
||||||
|
"assignment": "extra_credit",
|
||||||
|
"server": "http://lighthouse.soe.ucsc.edu",
|
||||||
|
"user": "arosenb1@ucsc.edu",
|
||||||
|
"pass": "05beb4aef80d919bdf992f1e3ec0c33e"
|
||||||
|
}
|
||||||
@@ -1,48 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* ##############
|
* Design Doc:
|
||||||
* # Design Doc #
|
|
||||||
* ##############
|
|
||||||
* The server is broken into the following files:
|
* The server is broken into the following files:
|
||||||
* - main.c: Argument parsing and high-level control
|
* - main.c: Argument parsing and high-level control
|
||||||
* - http.c: HTTP request parsing and response formatting
|
* - http.c: HTTP request parsing and response formatting
|
||||||
* - server.c: Abstraction over sockets
|
* - server.c: Abstraction over sockets
|
||||||
* - threadpool.c: Thread pool and woker queue implementation
|
* - threadpool.c: Thread pool and woker queue implementation
|
||||||
* - util.c: Misc. utility functions
|
* - util.c: Misc. utility functions
|
||||||
*
|
|
||||||
* Parallelization:
|
|
||||||
* I use a thread pool (implemented in threadpool.{h,c}) for parallelization. It
|
|
||||||
* uses a job queue that allows threads to push tasks (functions and a datum) to
|
|
||||||
* the queue and then distributes these tasks out to threads. It also makes sure
|
|
||||||
* to take a cleanup function in case the queue is destroyed before a given task
|
|
||||||
* is executed. Also, all the worker threads have a signal mask installed that
|
|
||||||
* prevents them frow receiving any signals (except KILL, CONT, and STOP, of
|
|
||||||
* course), so none of the tasks need to worry about such things.
|
|
||||||
*
|
|
||||||
* Abstraction:
|
|
||||||
* All multithreading stuff is contained in threadpool.{h,c}. Other files don't
|
|
||||||
* need to worry about what thread they are running on, they just need to ensure
|
|
||||||
* their functions are multithread safe.
|
|
||||||
*
|
|
||||||
* All HTTP stuff is handled in http.{h,c}. This includes both parsing requests
|
|
||||||
* and formatting responses. None of the other files do any major parsing, they
|
|
||||||
* just call into http.c and its `HTTPRequest` and `HTTPResponse` objects for
|
|
||||||
* that.
|
|
||||||
*
|
|
||||||
* Socket stuff is handled in server.{h,c}. The `Server` object contained in
|
|
||||||
* this file is a thin wrapper around the POSIX sockets API.
|
|
||||||
*
|
|
||||||
* util.{h,c} has some wrappers around the `malloc` family of functions that
|
|
||||||
* ensure that the application crashes "cleanly" if it is out of memory. As some
|
|
||||||
* functions want to catch these kinds of errors, they aren't used everywhere.
|
|
||||||
*
|
|
||||||
* Argument parsing and the request-to-task flow is handled in main.c. This is
|
|
||||||
* also where signal handling stuff is set up to ensure clean shutdown.
|
|
||||||
*
|
|
||||||
* Testing:
|
|
||||||
* I tested the server using cURL and netcat. I used cURL to create various
|
|
||||||
* kinds of syntactically valid requests. I used netcat (along with a text
|
|
||||||
* editor) to create and send syntactically invalid requests (e.g. `nc
|
|
||||||
* 127.0.0.1:8080 <test`).
|
|
||||||
*/
|
*/
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user