X-Git-Url: http://git.squeep.com/?p=lemu;a=blobdiff_plain;f=server.h;fp=server.h;h=e4b07053443d87dbfda669c0020161ffa87e3d3d;hp=0000000000000000000000000000000000000000;hb=3c54afe11e890fc476cc4730226be1c45f8a04cb;hpb=29235d4c1f0b11bd2efcad262eaae70383228293 diff --git a/server.h b/server.h new file mode 100644 index 0000000..e4b0705 --- /dev/null +++ b/server.h @@ -0,0 +1,55 @@ +#ifndef SERVER_H +#define SERVER_H + +#include +#include + +#include + +#include + +#include "common.h" +#include "connections.h" +#include "db.h" +#include "workqueue.h" + +struct server { + struct event_base *base; + struct evdns_base *evdns_base; + + pthread_mutex_t listeners_mutex; + struct evconnlistener **listeners; + size_t listeners_allocated; + size_t listeners_used; + + SSL_CTX *ssl_ctx; + + struct database db; + + /* a collection of all connections */ + struct connections connections; + + /* worker thread wrangler */ + struct workqueue workqueue; + + /* server lua context, currently to load and parse config file */ + lua_State *L; +}; + +/* each worker thread gets a reference to the server and its own lua state */ +struct server_worker_context { + struct server *server; + lua_State *L; +}; + +struct server * server_new(void); + +int server_init(struct server *s, char *conf_file); + +void server_free(struct server *s); + +void server_heartbeat_event(evutil_socket_t, short, void *); + +int server_refresh_ssl_context(lua_State *, struct server *); + +#endif /* SERVER_H */ \ No newline at end of file