:
io(session_io),
parent_service(vs),
- exit_flag(false),
+ exit_flag(0),
upthread_status(UPTHREAD_SLEEP),
downthread_status(DOWNTHREAD_SLEEP),
realserver_connect_status(false),
session_result_message msg;
msg.flag = false;
msg.message = "";
- exit_flag = false;
+ exit_flag = 0;
up_thread_id = boost::thread::id();
down_thread_id = boost::thread::id();
ssl_handshake_timer_flag = false;
Logger::putLogError(LOG_CAT_L7VSD_SESSION, 9, buf.str(), __FILE__, __LINE__);
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
}
}
}
Logger::putLogError(LOG_CAT_L7VSD_SESSION, 10, buf.str(), __FILE__, __LINE__);
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
}
}
}
Logger::putLogError(LOG_CAT_L7VSD_SESSION, 11, buf.str(), __FILE__, __LINE__);
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
}
}
}
Logger::putLogError(LOG_CAT_L7VSD_SESSION, 12, buf.str(), __FILE__, __LINE__);
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
}
}
}
Logger::putLogError(LOG_CAT_L7VSD_SESSION, 13, buf.str(), __FILE__, __LINE__);
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
}
}
}
}
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- if( !__sync_bool_compare_and_swap( &exit_flag, true, 2 ) ){
+ if( !__sync_bool_compare_and_swap( &exit_flag, 1, 2 ) ){
parent_service.release_session(this);
}
}
{
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
- if( !__sync_bool_compare_and_swap( &exit_flag, true, 2 ) ){
+ if( !__sync_bool_compare_and_swap( &exit_flag, 1, 2 ) ){
parent_service.release_session(this);
}
}
event.data.fd = !ssl_flag ? client_socket.get_socket().native()
: client_ssl_socket.get_socket().lowest_layer().native();
+ if (event.data.fd == -1) {
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT];
+ return;
+ }
+
// epoll wait codes
if (is_epoll_edge_trigger) {
event.events = EPOLLIN | EPOLLHUP | EPOLLET;
return;
}
}
+
int ret_fds = epoll_wait(up_client_epollfd, up_client_events, EVENT_NUM, epoll_timeout);
if (ret_fds == 0) {
//----Debug log----------------------------------------------------------------------
}
func_tag = func_type->second;
} else {
- boost::format formatter("Thread ID[%d] client read error. recv_size: %d");
- formatter % boost::this_thread::get_id() % recv_size;
- Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__);
- func_tag = UP_FUNC_CLIENT_RECEIVE;
+ func_tag = UP_FUNC_CLIENT_DISCONNECT;
}
} else {
if (ec == boost::asio::error::eof) {
upthread_status_cond.notify_one();
realserver_connect_cond.notify_one();
realserver_connect_status = true;
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
boost::format formatter("Thread ID[%d] FUNC OUT func up_thread_client_disconnect");
std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
func_tag = func_type->second;
} else {
- func_tag = DOWN_FUNC_REALSERVER_RECEIVE;
- //boost::this_thread::yield();
+ func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
}
} else {
if (ec == boost::asio::error::try_again) {
func_tag = DOWN_FUNC_REALSERVER_RECEIVE;
- //boost::this_thread::yield();
} else {
func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
}
//----Debug log----------------------------------------------------------------------
if (data_size > send_data_size) {
func_tag = DOWN_FUNC_CLIENT_SEND;
- //down_send_wait.reset();
} else {
protocol_module_base::EVENT_TAG module_event = protocol_module->handle_client_send(down_thread_id);
std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
func_tag = func_type->second;
} else {
- func_tag = DOWN_FUNC_SORRYSERVER_RECEIVE;
+ func_tag = DOWN_FUNC_SORRYSERVER_DISCONNECT;
}
} else {
if (ec == boost::asio::error::try_again) {
rw_scoped_lock scoped_lock(exit_flag_update_mutex);
boost::mutex::scoped_lock status_scoped_lock(downthread_status_mutex);
downthread_status_cond.notify_one();
- exit_flag = true;
+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
boost::format formatter("Thread ID[%d] FUNC OUT down_thread_exit");