2019-07-27 22:44:32 +08:00
|
|
|
|
#include "stdafx.h"
|
2016-06-23 13:34:54 +08:00
|
|
|
|
#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)
|
|
|
|
|
{
|
2016-06-24 10:39:05 +08:00
|
|
|
|
logger(">>>accept connection: %d", conn.sock_handle());
|
2016-06-23 13:34:54 +08:00
|
|
|
|
conn.set_rw_timeout(0);
|
2016-06-24 10:39:05 +08:00
|
|
|
|
|
|
|
|
|
acl::string buf;
|
|
|
|
|
|
2019-07-20 16:41:23 +08:00
|
|
|
|
while (true) {
|
|
|
|
|
if (!conn.gets(buf, false)) {
|
2016-06-24 10:39:05 +08:00
|
|
|
|
break;
|
2019-07-20 16:41:23 +08:00
|
|
|
|
}
|
2016-06-24 10:39:05 +08:00
|
|
|
|
|
2019-07-20 16:41:23 +08:00
|
|
|
|
if (conn.write(buf) == -1) {
|
2016-06-24 10:39:05 +08:00
|
|
|
|
logger_error("write error!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-23 13:34:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void master_service::proc_pre_jail(void)
|
|
|
|
|
{
|
2016-06-24 10:39:05 +08:00
|
|
|
|
logger(">>>proc_pre_jail<<<");
|
2016-06-23 13:34:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-03 20:09:21 +08:00
|
|
|
|
void master_service::proc_on_listen(acl::server_socket& ss)
|
|
|
|
|
{
|
|
|
|
|
logger(">>>listen %s ok<<<", ss.get_addr());
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-23 13:34:54 +08:00
|
|
|
|
void master_service::proc_on_init(void)
|
|
|
|
|
{
|
2016-06-24 10:39:05 +08:00
|
|
|
|
logger(">>>proc_on_init<<<");
|
2016-06-23 13:34:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void master_service::proc_on_exit(void)
|
|
|
|
|
{
|
2016-06-24 10:39:05 +08:00
|
|
|
|
logger(">>>proc_on_exit<<<");
|
2016-06-23 13:34:54 +08:00
|
|
|
|
}
|
2017-07-05 10:27:33 +08:00
|
|
|
|
|
2017-09-09 00:30:39 +08:00
|
|
|
|
bool master_service::proc_on_sighup(acl::string&)
|
2017-07-05 10:27:33 +08:00
|
|
|
|
{
|
|
|
|
|
logger(">>>proc_on_sighup<<<");
|
2017-09-09 00:30:39 +08:00
|
|
|
|
return true;
|
2017-07-05 10:27:33 +08:00
|
|
|
|
}
|