|
3 | 3 |  |
4 | 4 |  |
5 | 5 |
|
6 | | -A lightweight, POSIX-threaded HTTP/1.1 server supporting concurrent GET and PUT requests. |
7 | | -Built with a thread pool, a custom writer-priority reader–writer lock, and robust file I/O helpers. |
| 6 | +A multithreaded HTTP/1.1 server implemented in C, demonstrating systems programming, concurrency primitives, and low-level networking. |
8 | 7 |
|
9 | 8 | ## 🚀 Features ## |
10 | 9 | ### HTTP/1.1 GET ### |
@@ -110,41 +109,17 @@ Each file name is associated with: |
110 | 109 | Worker behavior: |
111 | 110 | - GET → reader_lock(), read file, reader_unlock() |
112 | 111 | - PUT → writer_lock(), write/overwrite, writer_unlock() |
113 | | -### Writer-Priority Read–Write Lock ### |
114 | | -Tracks: |
115 | | -- active_readers |
116 | | -- active_writers |
117 | | -- waiting_readers |
118 | | -- waiting_writers |
119 | | -Rules: |
120 | | -- A writer must wait until no readers or writers are active |
121 | | -- If any writer is waiting, new readers must wait |
122 | | -- Writer gets exclusive access |
123 | | -- Readers may run concurrently when no writer is waiting |
124 | | - |
125 | | -## 🧪 Manual Testing Examples ## |
126 | | -### GET existing file ### |
127 | | -```bash |
128 | | -echo "hello" > a.txt |
129 | | -curl http://127.0.0.1:8080/a.txt |
130 | | -``` |
131 | | -PUT new file |
132 | | -```bash |
133 | | -curl -X PUT -H "Content-Length: 11" \ |
134 | | - --data-binary "new content" \ |
135 | | - http://127.0.0.1:8080/b.txt |
136 | | -``` |
137 | | -Overwrite existing file |
138 | | -```bash |
139 | | -curl -X PUT -H "Content-Length: 3" \ |
140 | | - --data-binary "xyz" \ |
141 | | - http://127.0.0.1:8080/a.txt |
142 | | -``` |
| 112 | +### Writer-Priority Read–Write Lock |
| 113 | +- Ensures PUT operations get exclusive access. |
| 114 | +- Allows multiple concurrent GET requests when no writer is waiting. |
| 115 | +- Prevents writer starvation through explicit writer-priority logic. |
143 | 116 |
|
144 | 117 | ## 🧭 Future Improvements ## |
145 | 118 | - Add DELETE support |
146 | 119 | - Improve modularity and reduce duplication |
147 | 120 | - Expand test coverage for concurrency and edge cases |
148 | 121 | - Add graceful shutdown for worker threads |
149 | 122 |
|
| 123 | +## 📄 License |
| 124 | +This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details. |
150 | 125 |
|
0 commit comments