acl/lib_acl_cpp/include/acl_cpp/master/master_proc.hpp

88 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
2017-06-02 14:47:24 +08:00
#include "master_base.hpp"
2014-11-19 00:25:21 +08:00
#ifndef ACL_CLIENT_ONLY
2014-11-19 00:25:21 +08:00
struct ACL_VSTREAM;
struct ACL_EVENT;
struct ACL_VSTRING;
2014-11-19 00:25:21 +08:00
namespace acl {
class socket_stream;
/**
* acl_master <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><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
class ACL_CPP_API master_proc : public master_base
{
public:
/**
* <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> acl_master <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>״̬
* @param argc {int} <EFBFBD><EFBFBD> main <EFBFBD>д<EFBFBD><EFBFBD>ݵĵ<EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param argv {char**} <EFBFBD><EFBFBD> main <EFBFBD>д<EFBFBD><EFBFBD>ݵĵڶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
void run_daemon(int argc, char** argv);
/**
* <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><EFBFBD><EFBFBD>
* @param addrs {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD>б<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD>IP:PORT, IP:PORT...
* @param path {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ȫ·<EFBFBD><EFBFBD>
* @param count {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ > 0 ʱ<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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @return {bool} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD>ɹ<EFBFBD>
2014-11-19 00:25:21 +08:00
*/
bool run_alone(const char* addrs, const char* path = NULL, int count = 1);
2017-07-22 21:32:21 +08:00
/**
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>·<EFBFBD><EFBFBD>
* @return {const char*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵΪ NULL <EFBFBD><EFBFBD>ʾû<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
2017-07-22 21:32:21 +08:00
*/
const char* get_conf_path(void) const;
2014-11-19 00:25:21 +08:00
protected:
master_proc();
virtual ~master_proc();
/**
* <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>
* @param stream {aio_socket_stream*} <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><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>رո<EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
*/
virtual void on_accept(socket_stream* stream) = 0;
private:
// <20><><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ͻ<EFBFBD><CDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ص<EFBFBD><D8B5>˺<EFBFBD><CBBA><EFBFBD>
static void service_main(void*, ACL_VSTREAM *stream);
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַʱ<D6B7>ص<EFBFBD><D8B5>˺<EFBFBD><CBBA><EFBFBD>
static void service_on_listen(void*, ACL_VSTREAM*);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>õĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
static void service_pre_jail(void*);
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݺ<EFBFBD><DDBA><EFBFBD><EFBFBD>õĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
static void service_init(void*);
2014-11-19 00:25:21 +08:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>õĻص<C4BB><D8B5><EFBFBD><EFBFBD><EFBFBD>
static void service_exit(void*);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>յ<EFBFBD> SIGHUP <20>źź<C5BA><C5BA><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static int service_on_sighup(void*, ACL_VSTRING*);
2014-11-19 00:25:21 +08:00
private:
// <20>ڵ<EFBFBD><DAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD>ʽ<EFBFBD>£<EFBFBD><C2A3>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>׽<EFBFBD><D7BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2014-11-19 00:25:21 +08:00
static void listen_callback(int event_type, ACL_EVENT*,
ACL_VSTREAM*, void* context);
private:
bool stop_;
int count_limit_;
int count_;
2014-11-19 00:25:21 +08:00
};
} // namespace acl
#endif // ACL_CLIENT_ONLY