+bool tcp_session::down_thread_client_send_epoll_wait(DOWN_THREAD_FUNC_TYPE_TAG& func_tag)
+{
+ struct epoll_event event;
+ event.data.fd = !ssl_flag ? client_socket.get_socket().native()
+ : client_ssl_socket.get_socket().lowest_layer().native();
+ // epoll add
+ if (!down_client_epollfd_registered) {
+ if (!ssl_flag && is_epoll_edge_trigger) {
+ event.events = EPOLLOUT | EPOLLHUP | EPOLLET;
+ } else {
+ event.events = EPOLLOUT | EPOLLHUP;
+ }
+ if (epoll_ctl(down_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) {
+ std::stringstream buf;
+ buf << "down_thread_client_send_epoll_wait: epoll_ctl EPOLL_CTL_ADD error: ";
+ buf << strerror(errno);
+ Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__);
+ func_tag = DOWN_FUNC_CLIENT_SEND;
+ return false;
+ }
+ down_client_epollfd_registered = true;
+ }
+ // epoll wait
+ int ret_fds = epoll_wait(down_client_epollfd, down_client_events, EVENT_NUM, epoll_timeout);
+ if (ret_fds <= 0) {
+ if (ret_fds < 0) {
+ std::stringstream buf;
+ buf << "down_thread_client_send_epoll_wait: epoll_wait error: ";
+ buf << strerror(errno);
+ Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__);
+ func_tag = DOWN_FUNC_CLIENT_DISCONNECT;
+ } else {
+ func_tag = DOWN_FUNC_CLIENT_SEND;
+ }
+ return false;
+ }
+ for (int i = 0; i < ret_fds; ++i) {
+ if (down_client_events[i].data.fd == event.data.fd) {
+ if (down_client_events[i].events & EPOLLOUT) {
+ return true;
+ }
+ }
+ }
+ func_tag = DOWN_FUNC_CLIENT_DISCONNECT;
+ return false;
+}