acl/app/wizard/tmpl/master/master_rpc.cpp

260 lines
6.0 KiB
C++
Raw Normal View History

#include "stdafx.h"
2014-11-19 00:25:21 +08:00
#include "rpc_manager.h"
#include "master_service.h"
2015-09-16 21:03:02 +08:00
//////////////////////////////////////////////////////////////////////////////
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
char *var_cfg_str;
acl::master_str_tbl var_conf_str_tab[] = {
{ "str", "test_msg", &var_cfg_str },
{ 0, 0, 0 }
};
int var_cfg_bool;
acl::master_bool_tbl var_conf_bool_tab[] = {
{ "bool", 1, &var_cfg_bool },
{ 0, 0, 0 }
};
int var_cfg_thread_pool_limit;
int var_cfg_read_timeout;
acl::master_int_tbl var_conf_int_tab[] = {
{ "thread_pool_limit", 100, &var_cfg_thread_pool_limit, 0, 0 },
{ "read_timeout", 120, &var_cfg_read_timeout, 0, 0 },
{ 0, 0 , 0 , 0, 0 }
};
long long int var_cfg_int64;
acl::master_int64_tbl var_conf_int64_tab[] = {
{ "int64", 120, &var_cfg_int64, 0, 0 },
{ 0, 0 , 0 , 0, 0 }
};
2015-09-16 21:03:02 +08:00
//////////////////////////////////////////////////////////////////////////////
2014-11-19 00:25:21 +08:00
class request_rpc : public acl::rpc_request
{
public:
request_rpc(acl::aio_socket_stream* client)
: io_error_(false)
, client_(client)
{
}
2019-07-20 16:41:23 +08:00
~request_rpc(void) {}
2014-11-19 00:25:21 +08:00
protected:
2019-07-20 16:41:23 +08:00
// @override
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD>
2019-07-20 16:41:23 +08:00
void rpc_run(void)
2014-11-19 00:25:21 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>תΪ<D7AA><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
acl::socket_stream stream;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> get_vstream() <20><><EFBFBD>õ<EFBFBD> ACL_VSTREAM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> stream <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA> acl_cpp <20><> acl <20>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD><D5B6>ǻ<EFBFBD><C7BB><EFBFBD> ACL_VSTREAM<41><4D><EFBFBD><EFBFBD> ACL_VSTREAM <20><>
// <20>ڲ<EFBFBD>ά<EFBFBD><CEAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڳ<EFBFBD><DAB3><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD>У<EFBFBD>
// <20><><EFBFBD><EFBFBD>ÿ<EFBFBD>ν<EFBFBD> ACL_VSTREAM <20><>Ϊ<EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ<EFBFBD>
2014-11-19 00:25:21 +08:00
ACL_VSTREAM* vstream = client_->get_vstream();
ACL_VSTREAM_SET_RWTIMO(vstream, 10);
// <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>д<EFBFBD><D0B4>Ч<EFBFBD><D0A7>
2014-11-19 00:25:21 +08:00
acl_non_blocking(ACL_VSTREAM_SOCK(vstream), ACL_BLOCKING);
// <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
(void) stream.open(vstream);
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
handle_conn(stream);
// <20><> ACL_VSTREAM <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>󶨣<EFBFBD><F3B6A8A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD>֤<EFBFBD><D6A4><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߵ<EFBFBD><DFB5><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģ<EFBFBD><C4A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD>رշ<D8B1>ʽ<EFBFBD><CABD><EFBFBD>йر<D0B9>
2014-11-19 00:25:21 +08:00
stream.unbind();
}
2019-07-20 16:41:23 +08:00
// @override
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD><D5B5><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD><C9B5><EFBFBD>Ϣ
2019-07-20 16:41:23 +08:00
void rpc_onover(void)
2014-11-19 00:25:21 +08:00
{
// <20>ر<EFBFBD><D8B1><EFBFBD><ECB2BD>
2014-11-19 00:25:21 +08:00
client_->close();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
delete this;
}
/**
2019-07-20 16:41:23 +08:00
* @override
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿڣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̵߳<EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> rpc_signal ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD>л<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD>ӿڣ<EFBFBD>֪ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>δ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ(<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> rpc_onover ǰ)<EFBFBD>յ<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD>м<EFBFBD>״̬<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>Զ<EFBFBD>֧<EFBFBD><EFBFBD><EFBFBD>׽ӿڻ<EFBFBD> WIN32 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>Ӧ<EFBFBD>ó<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HTTP <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD>ã<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><EFBFBD>п<EFBFBD><EFBFBD><EFBFBD>
* һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̷߳<EFBFBD><EFBFBD><EFBFBD>(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> rpc_signal <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)<EFBFBD><EFBFBD><EFBFBD>ؽ<EFBFBD><EFBFBD>̣<EFBFBD>
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻߳<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD>Ĵ˷<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
2014-11-19 00:25:21 +08:00
*/
2019-07-20 16:41:23 +08:00
void rpc_wakeup(void*)
2014-11-19 00:25:21 +08:00
{
}
private:
bool io_error_;
acl::aio_socket_stream* client_;
void handle_conn(acl::socket_stream& stream)
{
acl::string buf;
// <20><><EFBFBD><EFBFBD><ECB2BD>תΪͬ<CEAA><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD>ӳؽ<D3B3><D8BD>ж<EFBFBD>д
2014-11-19 00:25:21 +08:00
2019-07-20 16:41:23 +08:00
if (!stream.gets(buf, false)) {
2014-11-19 00:25:21 +08:00
logger_warn("gets error!");
io_error_ = true;
2019-07-20 16:41:23 +08:00
} else if (stream.write(buf) == -1) {
2014-11-19 00:25:21 +08:00
logger_warn("write error!");
io_error_ = true;
}
}
};
2015-09-16 21:03:02 +08:00
//////////////////////////////////////////////////////////////////////////////
2014-11-19 00:25:21 +08:00
// acl::aio_callback <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0B6A8>
2014-11-19 00:25:21 +08:00
class io_callback : public acl::aio_callback
{
public:
2019-07-20 16:41:23 +08:00
io_callback(acl::aio_socket_stream* client) : client_(client) {}
2014-11-19 00:25:21 +08:00
2019-07-20 16:41:23 +08:00
~io_callback(void) {}
2014-11-19 00:25:21 +08:00
protected:
/**
2019-07-20 16:41:23 +08:00
* @override
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param data {char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>ַ
* @param len {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
2019-07-20 16:41:23 +08:00
bool read_callback(char* data, int len)
2014-11-19 00:25:21 +08:00
{
2019-07-20 16:41:23 +08:00
if (strncmp(data, "quit", len) == 0) {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD>Ĺرչ<D8B1><D5B9>̣<EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD><EFBFBD>ֱ<EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD> false
// ֪ͨ<CDA8><EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6>رո<D8B1><D5B8><EFBFBD><ECB2BD>
2014-11-19 00:25:21 +08:00
// client_->close();
return false;
}
return true;
}
2019-07-20 16:41:23 +08:00
// @override
bool read_wakeup(void)
2014-11-19 00:25:21 +08:00
{
// Ϊ<><CEAA>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӱ<EFBFBD><D3B1>رգ<D8B1>
// <20><><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȥ<EFBFBD><C8A5><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><ECB2BD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD>ӻ<EFBFBD><D3BB><EFBFBD> request_rpc::rpc_onover <20>б<EFBFBD><D0B1>ر<EFBFBD>
2014-11-19 00:25:21 +08:00
client_->disable_read();
// <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
request_rpc* req = new request_rpc(client_);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8> rpc ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̴߳<DFB3><CCB4><EFBFBD>
2014-11-19 00:25:21 +08:00
rpc_manager::get_instance().fork(req);
return true;
}
/**
2019-07-20 16:41:23 +08:00
* @override
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD>ɹ<EFBFBD><EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
2019-07-20 16:41:23 +08:00
bool write_callback(void)
2014-11-19 00:25:21 +08:00
{
return true;
}
/**
2019-07-20 16:41:23 +08:00
* @override
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺرջص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
2019-07-20 16:41:23 +08:00
void close_callback(void)
2014-11-19 00:25:21 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ˴<DAB4>ɾ<EFBFBD><C9BE><EFBFBD>ö<EFBFBD>̬<EFBFBD><CCAC><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Է<EFBFBD>ֹ<EFBFBD>ڴ<EFBFBD>й¶
2014-11-19 00:25:21 +08:00
delete this;
}
/**
2019-07-20 16:41:23 +08:00
* @override
* ʵ<EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʱ<EFBFBD>ص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD> true <EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
2019-07-20 16:41:23 +08:00
bool timeout_callback(void)
2014-11-19 00:25:21 +08:00
{
// <20><><EFBFBD><EFBFBD> false ֪ͨ<CDA8><EFBFBD><ECB2BD><EFBFBD>ܹرո<D8B1><D5B8><EFBFBD><ECB2BD>
2014-11-19 00:25:21 +08:00
return false;
}
private:
acl::aio_socket_stream* client_;
};
2015-09-16 21:03:02 +08:00
//////////////////////////////////////////////////////////////////////////////
2014-11-19 00:25:21 +08:00
2019-07-20 16:41:23 +08:00
master_service::master_service(void)
2014-11-19 00:25:21 +08:00
{
}
2019-07-20 16:41:23 +08:00
master_service::~master_service(void)
2014-11-19 00:25:21 +08:00
{
}
bool master_service::on_accept(acl::aio_socket_stream* client)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><D0B0><EFBFBD>
2014-11-19 00:25:21 +08:00
io_callback* callback = new io_callback(client);
// ע<><D7A2><EFBFBD><EFBFBD><ECB2BD><EFBFBD>Ķ<EFBFBD><C4B6>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
client->add_read_callback(callback);
// ע<><D7A2><EFBFBD><EFBFBD><ECB2BD><EFBFBD><EFBFBD>д<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
client->add_write_callback(callback);
// ע<><D7A2><EFBFBD><EFBFBD><ECB2BD><EFBFBD>Ĺرջص<D5BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
client->add_close_callback(callback);
// ע<><D7A2><EFBFBD><EFBFBD><ECB2BD><EFBFBD>ij<EFBFBD>ʱ<EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
client->add_timeout_callback(callback);
// д<><D0B4>ӭ<EFBFBD><D3AD>Ϣ
2014-11-19 00:25:21 +08:00
// client->format("hello, you're welcome\r\n");
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD>Ķ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݿɶ<DDBF>ʱ<EFBFBD><CAB1><EFBFBD>ص<EFBFBD> acl::aio_callback
// <20>е<EFBFBD> read_wakeup <20><EFBFBD><E9BAAF>
2014-11-19 00:25:21 +08:00
client->read_wait(var_cfg_read_timeout);
return true;
}
2019-07-20 16:41:23 +08:00
void master_service::proc_on_init(void)
2014-11-19 00:25:21 +08:00
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECB2BD><EFBFBD>ܵ<EFBFBD><DCB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2019-07-20 16:41:23 +08:00
acl::aio_handle* handle = this->get_handle();
if (handle == NULL) {
2015-09-16 21:03:02 +08:00
logger_fatal("aio handle null!");
2019-07-20 16:41:23 +08:00
}
2014-11-19 00:25:21 +08:00
// <20><>ʼ<EFBFBD><CABC> rpc <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2015-09-16 21:03:02 +08:00
rpc_manager::get_instance().init(*handle, var_cfg_thread_pool_limit);
2014-11-19 00:25:21 +08:00
}
2019-07-20 16:41:23 +08:00
void master_service::proc_on_exit(void)
2014-11-19 00:25:21 +08:00
{
}