-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebserver.h
More file actions
79 lines (71 loc) · 1.92 KB
/
Copy pathwebserver.h
File metadata and controls
79 lines (71 loc) · 1.92 KB
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
//
// Created by elysia on 3/11/24.
//
#ifndef WEBSERVER_H
#define WEBSERVER_H
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <string>
#include <arpa/inet.h>
#include "timer/time_heap.h"
#include "CGImysql/connection_pool.h"
#include "threadpool/pthreadpool.hpp"
#include "http_conn/http_conn.h"
#include "log/log.h"
#include <time.h>
#include <sys/time.h>
#include <cstring>
constexpr int MAX_FD{65536};
constexpr int MAX_EVENT_NUMBER{10000};
constexpr int TIMESLOT{5};
class WebServer
{
public:
WebServer(int cap);
~WebServer();
public:
void init(int port,std::string user,std::string PassWord,std::string DataBaseName,int log_wirte,int opt_linger,int trimode,int sql_num,int thread_num,int close_log,int actor_model);
void thread_pool();
void sql_pool();
void log_write();
void trig_mode();
void eventListen();
void eventLoop();
void timer(int connfd, struct sockaddr_in client_address);
void adjust_timer(heap_timer *timer);
void deal_timer(heap_timer *timer, int sockfd);
bool dealclientdata();
bool dealwithsignal(bool& timeout, bool& stop_server);
void dealwithread(int sockfd);
void dealwithwrite(int sockfd);
private:
int m_port;
char *m_root;
int m_log_write;
int m_close_log;
int m_actormodel;
int m_pipefd[2];
int m_epollfd;
http_conn *users;
//数据库相关
connection_pool *m_connPool;
std::string m_user; //登陆数据库用户名
std::string m_passWord; //登陆数据库密码
std::string m_databaseName; //使用数据库名
int m_sql_num;
//线程池相关
pthreadpool<http_conn> *m_pool;
int m_thread_num;
//epoll_event相关
epoll_event events[MAX_EVENT_NUMBER];
int m_listenfd;
int m_OPT_LINGER;
int m_TRIGMode;
int m_LISTENTrigmode;
int m_CONNTrigmode;
//定时器相关
client_data *users_timer;
Utils utils;
};
#endif