+ return; // try again
+ }
+ up_thread_data_client_side.initialize();
+ boost::array<char, MAX_BUFFER_SIZE>& data_buff = up_thread_data_client_side.get_data();
+ boost::system::error_code ec;
+ std::size_t recv_size;
+ UP_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 wait codes
+ if (is_epoll_edge_trigger) {
+ event.events = EPOLLIN | EPOLLHUP | EPOLLET;
+ } else {
+ event.events = EPOLLIN | EPOLLHUP;
+ }
+ bool add_flag = false;
+ if (!up_client_epollfd_registered) {
+ if (epoll_ctl(up_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) {
+ std::stringstream buf;
+ buf << "up_thread_client_receive: epoll_ctl EPOLL_CTL_ADD error: ";
+ buf << strerror(errno);
+ Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__);
+ boost::this_thread::yield();
+ return;
+ }
+ up_client_epollfd_registered = true;
+ add_flag = true;
+ }
+
+ if (is_epoll_edge_trigger && (!add_flag)) {
+ if (epoll_ctl(up_client_epollfd, EPOLL_CTL_MOD, event.data.fd, &event) < 0) {
+ std::stringstream buf;
+ buf << "up_thread_client_receive: epoll_ctl EPOLL_CTL_MOD error: ";
+ buf << strerror(errno);
+ Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__);
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT];
+ return;
+ }
+ }
+ int ret_fds = epoll_wait(up_client_epollfd, up_client_events, EVENT_NUM, epoll_timeout);
+ if (ret_fds == 0) {
+ //----Debug log----------------------------------------------------------------------
+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+ boost::format formatter("up_thread_client_receive: epoll_wait timeout %d msec");
+ formatter % epoll_timeout;
+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__);
+ }
+ //----Debug log----------------------------------------------------------------------
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_RECEIVE];
+ return;
+ } else if (ret_fds < 0) {
+ boost::format formatter("up_thread_client_receive: epoll_wait error: %s");
+ formatter % strerror(errno);
+ Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__);
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT];
+ return;
+ }
+
+ for (int i = 0; i < ret_fds; ++i) {
+ if (up_client_events[i].data.fd == event.data.fd) {
+ if (up_client_events[i].events & EPOLLIN) {
+ break;
+ }
+ if (up_client_events[i].events & EPOLLHUP) {
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT];
+ //----Debug log----------------------------------------------------------------------
+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+ boost::format formatter("Thread ID[%d] FUNC OUT up_thread_client_receive EPOLLHUP: NEXT_FUNC[%s]");
+ formatter % boost::this_thread::get_id() % func_tag_to_string(UP_FUNC_CLIENT_DISCONNECT);
+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__);
+ }
+ //----Debug log----------------------------------------------------------------------
+ return;
+ }
+ }