00001 #ifndef LUX_DIST_HANDLER_H
00002 #define LUX_DIST_HANDLER_H
00003
00004 #include "common.h"
00005 #include "protocol.h"
00006
00007 namespace Lux {
00008 namespace Dist {
00009
00010 class Handler {
00011 public:
00012 Handler(void *p);
00013 virtual ~Handler(void) = 0;
00014 virtual void process(void);
00015
00016 protected:
00017 sock_t con_;
00018 thread_inf_t *inf_;
00019 global_thread_stats_t *stats_;
00020 bool is_terminating_;
00021 bool is_persistent_;
00022
00023 int recv_packets(request_header_t &header,
00024 char **body, uint32_t *len);
00025 bool send_packets(char *data, uint32_t size, resp_status_t status);
00026 bool send_ok(void);
00027 bool send_error(err_code_t err_code);
00028 virtual bool exec(request_header_t &header,
00029 char *body, uint32_t body_len) = 0;
00030 virtual bool exec_quit(void);
00031 void inc_thread_(void);
00032 void dec_thread_(void);
00033 };
00034
00035 }
00036 }
00037
00038 #endif