parent
8c2e9c3a57
commit
b0bed67434
|
@ -706,8 +706,24 @@ static void keepalive_cb(struct ev_loop *loop, struct ev_timer *w, int revents)
|
||||||
conn_error(&conn->com, HTTP_STATUS_REQUEST_TIMEOUT, NULL);
|
conn_error(&conn->com, HTTP_STATUS_REQUEST_TIMEOUT, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct uh_server *conn_get_server(struct uh_connection *conn)
|
||||||
|
{
|
||||||
|
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
|
||||||
|
|
||||||
|
return &conni->srv->com;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ev_loop *conn_get_loop(struct uh_connection *conn)
|
||||||
|
{
|
||||||
|
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
|
||||||
|
|
||||||
|
return conni->srv->loop;
|
||||||
|
}
|
||||||
|
|
||||||
static void conn_init_cb(struct uh_connection *conn)
|
static void conn_init_cb(struct uh_connection *conn)
|
||||||
{
|
{
|
||||||
|
conn->get_server = conn_get_server;
|
||||||
|
conn->get_loop = conn_get_loop;
|
||||||
conn->done = conn_done;
|
conn->done = conn_done;
|
||||||
conn->send = conn_send;
|
conn->send = conn_send;
|
||||||
conn->send_file = conn_send_file;
|
conn->send_file = conn_send_file;
|
||||||
|
|
|
@ -371,6 +371,13 @@ static int uh_set_index_page(struct uh_server *srv, const char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct ev_loop *uh_get_loop(struct uh_server *srv)
|
||||||
|
{
|
||||||
|
struct uh_server_internal *srvi = (struct uh_server_internal *)srv;
|
||||||
|
|
||||||
|
return srvi->loop;
|
||||||
|
}
|
||||||
|
|
||||||
int uh_server_init(struct uh_server *srv, struct ev_loop *loop, const char *host, int port)
|
int uh_server_init(struct uh_server *srv, struct ev_loop *loop, const char *host, int port)
|
||||||
{
|
{
|
||||||
struct uh_server_internal *srvi = (struct uh_server_internal *)srv;
|
struct uh_server_internal *srvi = (struct uh_server_internal *)srv;
|
||||||
|
@ -446,6 +453,7 @@ int uh_server_init(struct uh_server *srv, struct ev_loop *loop, const char *host
|
||||||
uh_log_debug("Listen on: %s %d\n", addr_str, port);
|
uh_log_debug("Listen on: %s %d\n", addr_str, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
srv->get_loop = uh_get_loop;
|
||||||
srv->free = uh_server_free;
|
srv->free = uh_server_free;
|
||||||
srv->start_worker = uh_start_worker;
|
srv->start_worker = uh_start_worker;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,11 @@ enum {
|
||||||
UH_EV_COMPLETE
|
UH_EV_COMPLETE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct uh_server;
|
||||||
|
|
||||||
struct uh_connection {
|
struct uh_connection {
|
||||||
|
struct uh_server *(*get_server)(struct uh_connection *conn);
|
||||||
|
struct ev_loop *(*get_loop)(struct uh_connection *conn);
|
||||||
/*
|
/*
|
||||||
** Indicates the end of request processing
|
** Indicates the end of request processing
|
||||||
** Must be called at last, if not call 'error', 'redirect' and 'serve_file'
|
** Must be called at last, if not call 'error', 'redirect' and 'serve_file'
|
||||||
|
@ -78,6 +82,7 @@ struct uh_connection {
|
||||||
typedef void (*uh_path_handler_prototype)(struct uh_connection *conn, int event);
|
typedef void (*uh_path_handler_prototype)(struct uh_connection *conn, int event);
|
||||||
|
|
||||||
struct uh_server {
|
struct uh_server {
|
||||||
|
struct ev_loop *(*get_loop)(struct uh_server *srv);
|
||||||
void (*free)(struct uh_server *srv);
|
void (*free)(struct uh_server *srv);
|
||||||
/*
|
/*
|
||||||
** Start n worker processes to process the requests
|
** Start n worker processes to process the requests
|
||||||
|
|
Loading…
Reference in New Issue