@@ -45,6 +45,29 @@ void WebServer::init(int port, string user, string passWord, string databaseName
45
45
m_actormodel = actor_model;
46
46
}
47
47
48
+ void WebServer::trig_mode (){
49
+ // LT + LT
50
+ if (0 == m_TRIGMode){
51
+ m_LISTENTrigmode = 0 ;
52
+ m_CONNTrigmode = 0 ;
53
+ }
54
+ // LT + ET
55
+ else if (1 == m_TRIGMode){
56
+ m_LISTENTrigmode = 0 ;
57
+ m_CONNTrigmode = 1 ;
58
+ }
59
+ // ET + LT
60
+ else if (2 == m_TRIGMode){
61
+ m_LISTENTrigmode = 1 ;
62
+ m_CONNTrigmode = 0 ;
63
+ }
64
+ // ET + ET
65
+ else if (3 == m_TRIGMode){
66
+ m_LISTENTrigmode = 1 ;
67
+ m_CONNTrigmode = 1 ;
68
+ }
69
+ }
70
+
48
71
void WebServer::log_write ()
49
72
{
50
73
if (0 == m_close_log)
@@ -119,13 +142,13 @@ void WebServer::eventListen()
119
142
m_epollfd = epoll_create (5 );
120
143
assert (m_epollfd != -1 );
121
144
122
- utils.addfd (m_epollfd, m_listenfd, false , m_TRIGMode );
145
+ utils.addfd (m_epollfd, m_listenfd, false , m_LISTENTrigmode );
123
146
http_conn::m_epollfd = m_epollfd;
124
147
125
148
ret = socketpair (PF_UNIX, SOCK_STREAM, 0 , m_pipefd);
126
149
assert (ret != -1 );
127
150
utils.setnonblocking (m_pipefd[1 ]);
128
- utils.addfd (m_epollfd, m_pipefd[0 ], false , m_TRIGMode );
151
+ utils.addfd (m_epollfd, m_pipefd[0 ], false , 0 );
129
152
130
153
utils.addsig (SIGPIPE, SIG_IGN);
131
154
utils.addsig (SIGALRM, utils.sig_handler , false );
@@ -136,7 +159,7 @@ void WebServer::eventListen()
136
159
137
160
void WebServer::timer (int connfd, struct sockaddr_in client_address)
138
161
{
139
- users[connfd].init (connfd, client_address, m_root, m_SQLVerify, m_TRIGMode , m_close_log, m_user, m_passWord, m_databaseName);
162
+ users[connfd].init (connfd, client_address, m_root, m_SQLVerify, m_CONNTrigmode , m_close_log, m_user, m_passWord, m_databaseName);
140
163
141
164
// 初始化client_data数据
142
165
// 创建定时器,设置回调函数和超时时间,绑定用户数据,将定时器添加到链表中
@@ -177,7 +200,7 @@ bool WebServer::dealclinetdata()
177
200
{
178
201
struct sockaddr_in client_address;
179
202
socklen_t client_addrlength = sizeof (client_address);
180
- if (0 == m_TRIGMode )
203
+ if (0 == m_LISTENTrigmode )
181
204
{
182
205
int connfd = accept (m_listenfd, (struct sockaddr *)&client_address, &client_addrlength);
183
206
if (connfd < 0 )
0 commit comments