1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| class master_threads_test : public acl::master_threads { public: master_threads_test() {}
~master_threads_test() {}
protected: bool thread_on_read(acl::socket_stream* stream) { http_servlet servlet; servlet.setLocalCharset("gb2312"); servlet.doRun(“127.0.0.1:11211”, stream); }
bool thread_on_accept(acl::socket_stream*) { return true; } };
static char *var_cfg_debug_msg;
static acl::master_str_tbl var_conf_str_tab[] = { { "debug_msg", "test_msg", &var_cfg_debug_msg },
{ 0, 0, 0 } };
static int var_cfg_debug_enable; static int var_cfg_keep_alive; static int var_cfg_loop;
static acl::master_bool_tbl var_conf_bool_tab[] = { { "debug_enable", 1, &var_cfg_debug_enable }, { "keep_alive", 1, &var_cfg_keep_alive }, { "loop_read", 1, &var_cfg_loop },
{ 0, 0, 0 } };
static int var_cfg_io_timeout;
static acl::master_int_tbl var_conf_int_tab[] = { { "io_timeout", 120, &var_cfg_io_timeout, 0, 0 },
{ 0, 0 , 0 , 0, 0 } };
int main(int argc, char* argv[]) { master_threads_test mt;
mt.set_cfg_int(var_conf_int_tab); mt.set_cfg_int64(NULL); mt.set_cfg_str(var_conf_str_tab); mt.set_cfg_bool(var_conf_bool_tab);
if (argc >= 2 && strcmp(argv[1], "alone") == 0) { printf("listen: 127.0.0.1:8888\r\n"); mt.run_alone("127.0.0.1:8888", NULL, 2, 10); } else mt.run_daemon(argc, argv); return 0; }
|