2019-07-28 10:31:56 +08:00
|
|
|
#include "stdafx.h"
|
2019-03-14 15:24:11 +08:00
|
|
|
#include "http_servlet.h"
|
|
|
|
#include "master_service.h"
|
|
|
|
|
|
|
|
static char *var_cfg_str;
|
|
|
|
|
|
|
|
acl::master_str_tbl var_conf_str_tab[] = {
|
|
|
|
{ "str", "test_msg", &var_cfg_str },
|
|
|
|
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int var_cfg_debug_enable;
|
|
|
|
|
|
|
|
acl::master_bool_tbl var_conf_bool_tab[] = {
|
|
|
|
{ "debug_enable", 1, &var_cfg_debug_enable },
|
|
|
|
|
|
|
|
{ 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int var_cfg_io_timeout;
|
|
|
|
|
|
|
|
acl::master_int_tbl var_conf_int_tab[] = {
|
|
|
|
{ "io_timeout", 120, &var_cfg_io_timeout, 0, 0 },
|
|
|
|
|
|
|
|
{ 0, 0 , 0 , 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
acl::master_int64_tbl var_conf_int64_tab[] = {
|
|
|
|
{ 0, 0 , 0 , 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
master_service::master_service(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
master_service::~master_service(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void master_service::on_accept(acl::socket_stream& conn)
|
|
|
|
{
|
2022-03-12 23:59:32 +08:00
|
|
|
logger("connect from %s, fd %d", conn.get_peer(), conn.sock_handle());
|
2019-03-14 15:24:11 +08:00
|
|
|
|
|
|
|
conn.set_rw_timeout(120);
|
|
|
|
|
|
|
|
acl::memcache_session session("127.0.0.1:11211");
|
|
|
|
http_servlet servlet(&conn, &session);
|
|
|
|
|
|
|
|
// charset: big5, gb2312, gb18030, gbk, utf-8
|
|
|
|
servlet.setLocalCharset("utf-8");
|
2022-03-16 18:14:45 +08:00
|
|
|
servlet.setParseBody(false);
|
2019-03-14 15:24:11 +08:00
|
|
|
|
|
|
|
while(servlet.doRun()) {}
|
|
|
|
|
2022-03-12 23:59:32 +08:00
|
|
|
logger("disconnect from %s, fd %d", conn.get_peer(), conn.sock_handle());
|
2019-03-14 15:24:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void master_service::proc_pre_jail(void)
|
|
|
|
{
|
|
|
|
logger(">>>proc_pre_jail<<<");
|
|
|
|
}
|
|
|
|
|
|
|
|
void master_service::proc_on_listen(acl::server_socket& ss)
|
|
|
|
{
|
|
|
|
logger(">>>listen %s ok<<<", ss.get_addr());
|
|
|
|
}
|
|
|
|
|
|
|
|
void master_service::proc_on_init(void)
|
|
|
|
{
|
2022-04-02 16:31:12 +08:00
|
|
|
logger(">>>proc_on_init: shared stack size=%zd<<<",
|
|
|
|
acl::fiber::get_shared_stack_size());
|
2019-03-14 15:24:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void master_service::proc_on_exit(void)
|
|
|
|
{
|
|
|
|
logger(">>>proc_on_exit<<<");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool master_service::proc_on_sighup(acl::string&)
|
|
|
|
{
|
|
|
|
logger(">>>proc_on_sighup<<<");
|
|
|
|
return true;
|
|
|
|
}
|