2009-04-17 16:16:50 +00:00
|
|
|
#ifndef _LIGHTTPD_ANGEL_SERVER_H_
|
|
|
|
#define _LIGHTTPD_ANGEL_SERVER_H_
|
|
|
|
|
|
|
|
#ifndef _LIGHTTPD_ANGEL_BASE_H_
|
|
|
|
#error Please include <lighttpd/angel_base.h> instead of this file
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LIGHTTPD_ANGEL_MAGIC
|
|
|
|
#define LIGHTTPD_ANGEL_MAGIC ((guint)0x3e14ac65)
|
|
|
|
#endif
|
|
|
|
|
2009-10-17 21:50:41 +00:00
|
|
|
typedef void (*liInstanceResourceFreeCB) (liServer *srv, liInstance *i, liPlugin *p, liInstanceResource *res);
|
2009-07-08 19:06:07 +00:00
|
|
|
|
|
|
|
struct liInstanceConf {
|
2009-07-07 20:40:44 +00:00
|
|
|
gint refcount;
|
|
|
|
|
|
|
|
gchar **cmd;
|
2009-10-03 19:14:34 +00:00
|
|
|
gchar **env;
|
2009-07-07 20:40:44 +00:00
|
|
|
GString *username;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2009-10-04 12:26:18 +00:00
|
|
|
|
|
|
|
gint64 rlim_core, rlim_nofile; /* < 0: don't change, G_MAXINT64: unlimited */
|
2009-07-07 20:40:44 +00:00
|
|
|
};
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
struct liInstance {
|
2009-07-07 20:40:44 +00:00
|
|
|
gint refcount;
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liServer *srv;
|
|
|
|
liInstanceConf *ic;
|
2009-07-07 20:40:44 +00:00
|
|
|
|
2009-07-25 15:37:45 +00:00
|
|
|
liProc *proc;
|
2009-07-07 20:40:44 +00:00
|
|
|
ev_child child_watcher;
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liInstanceState s_cur, s_dest;
|
2009-06-23 21:40:13 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liInstance *replace, *replace_by;
|
2009-07-07 20:40:44 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liAngelConnection *acon;
|
2009-10-17 21:50:41 +00:00
|
|
|
|
|
|
|
GPtrArray *resources;
|
2009-04-17 16:16:50 +00:00
|
|
|
};
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
struct liServer {
|
2009-04-17 16:16:50 +00:00
|
|
|
guint32 magic; /** server magic version, check against LIGHTTPD_ANGEL_MAGIC in plugins */
|
|
|
|
|
|
|
|
struct ev_loop *loop;
|
|
|
|
ev_signal
|
|
|
|
sig_w_INT,
|
|
|
|
sig_w_TERM,
|
|
|
|
sig_w_PIPE;
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liPlugins plugins;
|
2009-04-17 16:16:50 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liLog log;
|
2009-04-17 16:16:50 +00:00
|
|
|
};
|
|
|
|
|
2009-10-17 21:50:41 +00:00
|
|
|
struct liInstanceResource {
|
|
|
|
liInstanceResourceFreeCB free_cb;
|
|
|
|
liPlugin *plugin; /* may be NULL - we don't care about that */
|
|
|
|
guint ndx; /* internal array index */
|
|
|
|
|
|
|
|
gpointer data;
|
|
|
|
};
|
|
|
|
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liServer* li_server_new(const gchar *module_dir);
|
|
|
|
LI_API void li_server_free(liServer* srv);
|
2009-04-17 16:16:50 +00:00
|
|
|
|
2009-07-26 13:01:08 +00:00
|
|
|
LI_API void li_server_stop(liServer *srv);
|
|
|
|
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liInstance* li_server_new_instance(liServer *srv, liInstanceConf *ic);
|
2009-10-17 21:50:41 +00:00
|
|
|
LI_API gboolean li_instance_replace(liInstance *oldi, liInstance *newi);
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_instance_set_state(liInstance *i, liInstanceState s);
|
2009-08-30 18:43:13 +00:00
|
|
|
LI_API void li_instance_state_reached(liInstance *i, liInstanceState s);
|
2009-07-07 20:40:44 +00:00
|
|
|
|
2009-10-04 12:26:18 +00:00
|
|
|
LI_API liInstanceConf* li_instance_conf_new(gchar **cmd, gchar **env, GString *username, uid_t uid, gid_t gid, gint64 rlim_core, gint64 rlim_nofile);
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_instance_conf_release(liInstanceConf *ic);
|
|
|
|
LI_API void li_instance_conf_acquire(liInstanceConf *ic);
|
2009-07-07 20:40:44 +00:00
|
|
|
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_instance_release(liInstance *i);
|
|
|
|
LI_API void li_instance_acquire(liInstance *i);
|
2009-07-07 20:40:44 +00:00
|
|
|
|
2009-10-17 21:50:41 +00:00
|
|
|
LI_API void li_instance_add_resource(liInstance *i, liInstanceResource *res, liInstanceResourceFreeCB free_cb, liPlugin *p, gpointer data);
|
|
|
|
LI_API void li_instance_rem_resource(liInstance *i, liInstanceResource *res);
|
|
|
|
|
2009-04-17 16:16:50 +00:00
|
|
|
#endif
|