How jwf-520/webserver works
This is a lightweight Linux C++ HTTP/1.1 web server. A client connects to the epoll-based server, which dispatches socket work through the configured Reactor or Proactor model; worker threads process requests and return static-file or registration/login responses. The server also expires inactive connections and records logs, while request workers borrow database connections as needed. The README documents these capabilities; sampled source confirms the dispatch, worker, timer, and connection-pool mechanisms. HTTP and server excerpts are partial, so uncertain internal call details are not expanded.
Main entry points: webserver.cpp Event Server · http_conn.cpp HTTP Connection · threadpool.h Worker Pool · log.cpp Logging
Components 19
Server Runtime
- Startup Entry
main.cpp - Runtime Options
config/config.cpp - Event Server
webfile/webserver.cpp - Epoll Dispatch
webfile/webserver.cpp - Worker Pool
threadpool/threadpool.h
HTTP Handling
- HTTP Connection
http/http_conn.cpp - Request Parser
http/http_conn.cpp - Login And Registration
http/http_conn.cpp - Response Builder
http/http_conn.cpp - Static Web Content
root
Data Services
- SQL Connection Pool
CGImysql/sql_connection_pool.cpp - MySQL Database
Runtime Support
- Locks And Signals
lock/locker.h - Idle Connection Timers
timer/lst_timer.cpp - Signal Pipe
webfile/webserver.cpp - Logging
log/log.cpp - Async Log Queue
log/block_queue.h - Log Files
log/log.cpp
Other components
- Browser Client
Connections 24
- Browser Client → Event Server: connects
- Startup Entry → Runtime Options: parses options
- Startup Entry → Event Server: initializes and runs
- Event Server → Epoll Dispatch: registers and waits
- Epoll Dispatch → Event Server: delivers events
- Event Server → Worker Pool: queues socket work
- Worker Pool → Locks And Signals: coordinates workers
- Worker Pool → HTTP Connection: runs request processing
- HTTP Connection → Request Parser: parses request
- HTTP Connection → Login And Registration: handles POST credentials
- HTTP Connection → Response Builder: builds response
- Response Builder → Static Web Content: reads requested resource
- HTTP Connection → Browser Client: sends HTTP response
- Worker Pool → SQL Connection Pool: borrows connection
- SQL Connection Pool → MySQL Database: opens and reuses connections
- Login And Registration → MySQL Database: checks or stores credentials
- Event Server → Idle Connection Timers: adds and adjusts timers
- Event Server → Signal Pipe: registers signal events
- Signal Pipe → Event Server: notifies event loop
- Idle Connection Timers → Epoll Dispatch: removes expired sockets
- Event Server → Logging: initializes logging
- HTTP Connection → Logging: records request events
- Logging → Async Log Queue: queues log entries
- Logging → Log Files: writes log entries