• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisão90b6f924a1bee5202b076d0dcddb6b7d04aca26c (tree)
Hora2010-11-08 21:25:41
Autor0809216 <0809216@1ed6...>
Commiter0809216

Mensagem de Log

change tcp_session

git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-ramiel-epoll-cond@10426 1ed66053-1c2d-0410-8867-f7571e6e31d3

Mudança Sumário

Diff

--- a/l7vsd/src/tcp_session.cpp
+++ b/l7vsd/src/tcp_session.cpp
@@ -57,7 +57,7 @@ tcp_session::tcp_session(
5757 :
5858 io(session_io),
5959 parent_service(vs),
60- exit_flag(false),
60+ exit_flag(0),
6161 upthread_status(UPTHREAD_SLEEP),
6262 downthread_status(DOWNTHREAD_SLEEP),
6363 realserver_connect_status(false),
@@ -342,7 +342,7 @@ session_result_message tcp_session::initialize()
342342 session_result_message msg;
343343 msg.flag = false;
344344 msg.message = "";
345- exit_flag = false;
345+ exit_flag = 0;
346346 up_thread_id = boost::thread::id();
347347 down_thread_id = boost::thread::id();
348348 ssl_handshake_timer_flag = false;
@@ -843,7 +843,7 @@ void tcp_session::up_thread_run()
843843 Logger::putLogError(LOG_CAT_L7VSD_SESSION, 9, buf.str(), __FILE__, __LINE__);
844844 {
845845 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
846- exit_flag = true;
846+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
847847 }
848848 }
849849 }
@@ -865,7 +865,7 @@ void tcp_session::up_thread_run()
865865 Logger::putLogError(LOG_CAT_L7VSD_SESSION, 10, buf.str(), __FILE__, __LINE__);
866866 {
867867 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
868- exit_flag = true;
868+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
869869 }
870870 }
871871 }
@@ -881,7 +881,7 @@ void tcp_session::up_thread_run()
881881 Logger::putLogError(LOG_CAT_L7VSD_SESSION, 11, buf.str(), __FILE__, __LINE__);
882882 {
883883 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
884- exit_flag = true;
884+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
885885 }
886886 }
887887 }
@@ -904,7 +904,7 @@ void tcp_session::up_thread_run()
904904 Logger::putLogError(LOG_CAT_L7VSD_SESSION, 12, buf.str(), __FILE__, __LINE__);
905905 {
906906 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
907- exit_flag = true;
907+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
908908 }
909909 }
910910 }
@@ -928,7 +928,7 @@ void tcp_session::up_thread_run()
928928 Logger::putLogError(LOG_CAT_L7VSD_SESSION, 13, buf.str(), __FILE__, __LINE__);
929929 {
930930 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
931- exit_flag = true;
931+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
932932 }
933933 }
934934 }
@@ -1044,7 +1044,7 @@ void tcp_session::up_thread_run()
10441044 }
10451045 {
10461046 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
1047- if( !__sync_bool_compare_and_swap( &exit_flag, true, 2 ) ){
1047+ if( !__sync_bool_compare_and_swap( &exit_flag, 1, 2 ) ){
10481048 parent_service.release_session(this);
10491049 }
10501050 }
@@ -1175,7 +1175,7 @@ void tcp_session::down_thread_run()
11751175
11761176 {
11771177 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
1178- if( !__sync_bool_compare_and_swap( &exit_flag, true, 2 ) ){
1178+ if( !__sync_bool_compare_and_swap( &exit_flag, 1, 2 ) ){
11791179 parent_service.release_session(this);
11801180 }
11811181 }
@@ -1399,6 +1399,11 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty
13991399 event.data.fd = !ssl_flag ? client_socket.get_socket().native()
14001400 : client_ssl_socket.get_socket().lowest_layer().native();
14011401
1402+ if (event.data.fd == -1) {
1403+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT];
1404+ return;
1405+ }
1406+
14021407 // epoll wait codes
14031408 if (is_epoll_edge_trigger) {
14041409 event.events = EPOLLIN | EPOLLHUP | EPOLLET;
@@ -1429,6 +1434,7 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty
14291434 return;
14301435 }
14311436 }
1437+
14321438 int ret_fds = epoll_wait(up_client_epollfd, up_client_events, EVENT_NUM, epoll_timeout);
14331439 if (ret_fds == 0) {
14341440 //----Debug log----------------------------------------------------------------------
@@ -1500,10 +1506,7 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty
15001506 }
15011507 func_tag = func_type->second;
15021508 } else {
1503- boost::format formatter("Thread ID[%d] client read error. recv_size: %d");
1504- formatter % boost::this_thread::get_id() % recv_size;
1505- Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__);
1506- func_tag = UP_FUNC_CLIENT_RECEIVE;
1509+ func_tag = UP_FUNC_CLIENT_DISCONNECT;
15071510 }
15081511 } else {
15091512 if (ec == boost::asio::error::eof) {
@@ -2606,7 +2609,7 @@ void tcp_session::up_thread_exit(const TCP_PROCESS_TYPE_TAG process_type)
26062609 upthread_status_cond.notify_one();
26072610 realserver_connect_cond.notify_one();
26082611 realserver_connect_status = true;
2609- exit_flag = true;
2612+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
26102613
26112614 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
26122615 boost::format formatter("Thread ID[%d] FUNC OUT func up_thread_client_disconnect");
@@ -2780,13 +2783,11 @@ void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG proc
27802783 std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
27812784 func_tag = func_type->second;
27822785 } else {
2783- func_tag = DOWN_FUNC_REALSERVER_RECEIVE;
2784- //boost::this_thread::yield();
2786+ func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
27852787 }
27862788 } else {
27872789 if (ec == boost::asio::error::try_again) {
27882790 func_tag = DOWN_FUNC_REALSERVER_RECEIVE;
2789- //boost::this_thread::yield();
27902791 } else {
27912792 func_tag = DOWN_FUNC_REALSERVER_DISCONNECT;
27922793 }
@@ -3104,7 +3105,6 @@ void tcp_session::down_thread_client_send(const TCP_PROCESS_TYPE_TAG process_typ
31043105 //----Debug log----------------------------------------------------------------------
31053106 if (data_size > send_data_size) {
31063107 func_tag = DOWN_FUNC_CLIENT_SEND;
3107- //down_send_wait.reset();
31083108 } else {
31093109 protocol_module_base::EVENT_TAG module_event = protocol_module->handle_client_send(down_thread_id);
31103110 std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
@@ -3304,7 +3304,7 @@ void tcp_session::down_thread_sorryserver_receive(const TCP_PROCESS_TYPE_TAG pro
33043304 std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event);
33053305 func_tag = func_type->second;
33063306 } else {
3307- func_tag = DOWN_FUNC_SORRYSERVER_RECEIVE;
3307+ func_tag = DOWN_FUNC_SORRYSERVER_DISCONNECT;
33083308 }
33093309 } else {
33103310 if (ec == boost::asio::error::try_again) {
@@ -3492,7 +3492,7 @@ void tcp_session::down_thread_exit(const TCP_PROCESS_TYPE_TAG process_type)
34923492 rw_scoped_lock scoped_lock(exit_flag_update_mutex);
34933493 boost::mutex::scoped_lock status_scoped_lock(downthread_status_mutex);
34943494 downthread_status_cond.notify_one();
3495- exit_flag = true;
3495+ __sync_bool_compare_and_swap(&exit_flag, 0, 1);
34963496
34973497 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
34983498 boost::format formatter("Thread ID[%d] FUNC OUT down_thread_exit");
--- a/l7vsd/src/virtualservice_tcp.cpp
+++ b/l7vsd/src/virtualservice_tcp.cpp
@@ -1721,11 +1721,11 @@ void l7vs::virtualservice_tcp::release_session(const tcp_session *session_ptr)
17211721
17221722 session_thread_control *stc_ptr = active_sessions.find(session_ptr);
17231723 if (unlikely(NULL == stc_ptr)) {
1724+ boost::format fmt("session release fail: "
1725+ "active_sessions.find( const tcp_session* session_ptr = %d )");
1726+ fmt % session_ptr;
1727+ Logger::putLogError(LOG_CAT_L7VSD_VIRTUALSERVICE, /*XXX*/999, fmt.str(), __FILE__, __LINE__);
17241728 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) {
1725- boost::format fmt("session release fail: "
1726- "active_sessions.find( const tcp_session* session_ptr = %d )");
1727- fmt % session_ptr;
1728- Logger::putLogDebug(LOG_CAT_L7VSD_VIRTUALSERVICE, 87, fmt.str(), __FILE__, __LINE__);
17291729 Logger::putLogDebug(LOG_CAT_L7VSD_VIRTUALSERVICE, 88, "out_function: "
17301730 "void virtualservice_tcp::release_session( "
17311731 "const boost::thread::id thread_id )", __FILE__, __LINE__);