Fork 0

122 lines
3.4 KiB

#error Please include <lighttpd/base.h> instead of this file
struct statistics_t;
typedef struct statistics_t statistics_t;
struct statistics_t {
guint64 bytes_out; /** bytes transfered, outgoing */
guint64 bytes_in; /** bytes transfered, incoming */
guint64 requests; /** processed requests */
guint64 active_cons_cum; /** cummulative value of active connections, updated once a second */
guint64 actions_executed; /** actions executed */
/* 5 seconds frame avg */
guint64 requests_5s;
guint64 requests_5s_diff;
guint64 bytes_out_5s;
guint64 bytes_out_5s_diff;
guint64 bytes_in_5s;
guint64 bytes_in_5s_diff;
guint active_cons_5s;
ev_tstamp last_avg;
/* updated in timer */
guint64 last_requests;
double requests_per_sec;
ev_tstamp last_update;
#define CUR_TS(wrk) ev_now((wrk)->loop)
/* only locks if there is more than one worker */
#define WORKER_LOCK(srv, lock) \
if ((srv)->worker_count > 1) g_static_rec_mutex_lock(lock)
#define WORKER_UNLOCK(srv, lock) \
if ((srv)->worker_count > 1) g_static_rec_mutex_unlock(lock)
struct worker_ts {
time_t last_generated;
GString *str;
typedef struct worker_ts worker_ts;
struct worker {
struct server *srv;
GThread *thread; /* managed by server.c */
guint ndx; /* worker index */
struct ev_loop *loop;
ev_prepare loop_prepare;
ev_check loop_check;
ev_async worker_stop_watcher, worker_exit_watcher;
guint connections_active; /** 0..con_act-1: active connections, con_act..used-1: free connections
* use with atomic, read direct from local worker context
GArray *connections; /** array of (connection*), use only from local worker context */
ev_tstamp connections_gc_ts;
GQueue closing_sockets; /** wait for EOF before shutdown(SHUT_RD) and close() */
GString *tmp_str; /**< can be used everywhere for local temporary needed strings */
/* keep alive timeout queue */
ev_timer keep_alive_timer;
GQueue keep_alive_queue;
waitqueue io_timeout_queue;
waitqueue throttle_queue;
guint connection_load; /** incremented by server_accept_cb, decremented by worker_con_put. use atomic access */
GArray *timestamps; /** array of (worker_ts), use only from local worker context and through worker_current_timestamp(wrk, ndx) */
/* incoming queues */
/* - new connections (after accept) */
ev_async new_con_watcher;
GAsyncQueue *new_con_queue;
ev_timer stats_watcher;
statistics_t stats;
/* collect framework */
ev_async collect_watcher;
GAsyncQueue *collect_queue;
GQueue job_queue;
ev_timer job_queue_watcher;
GAsyncQueue *job_async_queue;
ev_async job_async_queue_watcher;
stat_cache *stat_cache;
LI_API worker* worker_new(struct server *srv, struct ev_loop *loop);
LI_API void worker_free(worker *wrk);
LI_API void worker_run(worker *wrk);
LI_API void worker_stop(worker *context, worker *wrk);
LI_API void worker_exit(worker *context, worker *wrk);
LI_API void worker_new_con(worker *ctx, worker *wrk, sockaddr_t remote_addr, int s, server_socket *srv_sock);
LI_API void worker_check_keepalive(worker *wrk);
LI_API GString* worker_current_timestamp(worker *wrk, guint format_ndx);
/* shutdown write and wait for eof before shutdown read and close */
LI_API void worker_add_closing_socket(worker *wrk, int fd);