You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.6 KiB
C
95 lines
2.6 KiB
C
![]()
15 years ago
|
#ifndef _LIGHTTPD_SERVER_H_
|
||
|
#define _LIGHTTPD_SERVER_H_
|
||
![]()
15 years ago
|
|
||
15 years ago
|
#ifndef LIGHTTPD_SERVER_MAGIC
|
||
|
#define LIGHTTPD_SERVER_MAGIC ((guint)0x12AB34CD)
|
||
|
#endif
|
||
|
|
||
|
typedef enum {
|
||
|
SERVER_STARTING, /** start up: don't write log files, don't accept connections */
|
||
|
SERVER_RUNNING, /** running: write logs, accept connections */
|
||
|
SERVER_STOPPING /** stopping: flush logs, don't accept new connections */
|
||
|
} server_state;
|
||
|
|
||
|
struct server_socket;
|
||
|
typedef struct server_socket server_socket;
|
||
|
|
||
|
struct server_socket {
|
||
|
server *srv;
|
||
|
ev_io watcher;
|
||
|
};
|
||
![]()
15 years ago
|
|
||
![]()
15 years ago
|
struct server {
|
||
15 years ago
|
guint32 magic; /** server magic version, check against LIGHTTPD_SERVER_MAGIC in plugins */
|
||
15 years ago
|
server_state state; /** atomic access */
|
||
![]()
15 years ago
|
|
||
15 years ago
|
struct worker *main_worker;
|
||
15 years ago
|
guint worker_count;
|
||
|
GArray *workers;
|
||
15 years ago
|
|
||
![]()
15 years ago
|
guint loop_flags;
|
||
15 years ago
|
ev_signal
|
||
|
sig_w_INT,
|
||
|
sig_w_TERM,
|
||
|
sig_w_PIPE;
|
||
|
ev_prepare srv_prepare;
|
||
|
ev_check srv_check;
|
||
![]()
15 years ago
|
|
||
15 years ago
|
GArray *sockets; /** array of (server_socket*) */
|
||
|
|
||
![]()
15 years ago
|
struct modules *modules;
|
||
|
|
||
15 years ago
|
GHashTable *plugins; /**< const gchar* => (plugin*) */
|
||
![]()
15 years ago
|
struct plugin *core_plugin;
|
||
![]()
15 years ago
|
|
||
15 years ago
|
/* registered by plugins */
|
||
15 years ago
|
GHashTable *options; /**< const gchar* => (server_option*) */
|
||
|
GHashTable *actions; /**< const gchar* => (server_action*) */
|
||
|
GHashTable *setups; /**< const gchar* => (server_setup*) */
|
||
15 years ago
|
|
||
15 years ago
|
GArray *plugins_handle_close; /** list of handle_close callbacks */
|
||
|
|
||
![]()
15 years ago
|
GArray *option_def_values;/** array of option_value */
|
||
15 years ago
|
struct action *mainaction;
|
||
![]()
15 years ago
|
|
||
15 years ago
|
gboolean exiting; /** atomic access */
|
||
![]()
15 years ago
|
|
||
![]()
15 years ago
|
struct {
|
||
|
GMutex *mutex;
|
||
![]()
15 years ago
|
GHashTable *targets; /** const gchar* path => (log_t*) */
|
||
![]()
15 years ago
|
GAsyncQueue *queue;
|
||
|
GThread *thread;
|
||
![]()
15 years ago
|
gboolean thread_finish; /** finish writing logs in the queue, then exit thread; access with atomic functions */
|
||
|
gboolean thread_stop; /** stop thread immediately; access with atomic functions */
|
||
|
gboolean thread_alive; /** access with atomic functions */
|
||
|
GArray *timestamps; /** array of log_timestamp_t */
|
||
![]()
15 years ago
|
struct log_t *stderr;
|
||
|
} logs;
|
||
![]()
15 years ago
|
|
||
|
ev_tstamp started;
|
||
![]()
15 years ago
|
GString *started_str;
|
||
15 years ago
|
|
||
15 years ago
|
/* keep alive timeout */
|
||
15 years ago
|
guint keep_alive_queue_timeout;
|
||
![]()
15 years ago
|
|
||
![]()
15 years ago
|
gdouble io_timeout;
|
||
![]()
15 years ago
|
};
|
||
|
|
||
|
|
||
15 years ago
|
LI_API server* server_new(const gchar *module_dir);
|
||
15 years ago
|
LI_API void server_free(server* srv);
|
||
![]()
15 years ago
|
LI_API gboolean server_loop_init(server *srv);
|
||
15 years ago
|
|
||
|
LI_API void server_listen(server *srv, int fd);
|
||
|
|
||
15 years ago
|
/* Start accepting connection, use log files, no new plugins after that */
|
||
15 years ago
|
LI_API void server_start(server *srv);
|
||
15 years ago
|
/* stop accepting connections, turn keep-alive off, close all shutdown sockets, set exiting = TRUE */
|
||
15 years ago
|
LI_API void server_stop(server *srv);
|
||
15 years ago
|
/* exit asap with cleanup */
|
||
15 years ago
|
LI_API void server_exit(server *srv);
|
||
15 years ago
|
|
||
15 years ago
|
GString *server_current_timestamp();
|
||
![]()
15 years ago
|
|
||
![]()
15 years ago
|
#endif
|