UltraMonkey-L7 V3(multi-thread implementation)
Revision | 460763083dcb848ad381d765d17dd6be279e643f (tree) |
---|---|
Time | 2012-07-30 16:10:57 |
Author | Hiroaki Nakano <nakano.hiroaki@nttc...> |
Commiter | Hiroaki Nakano |
ticket 29144 SSL clear_socketエラー対処
クライアント数12000のTPCWによるhttps通信負荷を30分かける試験をすると、
50回に1回の割合でcoreを吐く。
対処として、sslのときsocket.clear_socket()をio_serviceの
workerスレッドに登録して処理するようにし、それによって
clear_socket()の処理をシリアライズ化する。
Signed-off-by: Hiroaki Nakano <nakano.hiroaki@nttcom.co.jp>
@@ -542,6 +542,7 @@ protected: | ||
542 | 542 | virtual void down_thread_client_handle_async_write_some(const TCP_PROCESS_TYPE_TAG); |
543 | 543 | virtual void down_thread_sorryserver_async_read_some_handler(const boost::system::error_code &error_code, std::size_t len); |
544 | 544 | virtual void down_thread_sorryserver_handle_async_read_some(const TCP_PROCESS_TYPE_TAG); |
545 | + virtual void up_thread_client_ssl_socket_clear_socket_handler(); | |
545 | 546 | |
546 | 547 | //! down thread receive from realserver and raise module event of handle_realserver_recv |
547 | 548 | //! @param[in] process_type is process type |
@@ -897,7 +897,19 @@ void tcp_session::up_thread_run() | ||
897 | 897 | |
898 | 898 | if (ssl_flag) { |
899 | 899 | client_ssl_socket.wait_async_event_all_end(); |
900 | - client_ssl_socket.clear_socket(); | |
900 | + upthread_status = UPTHREAD_LOCK; | |
901 | + parent_dispatcher.post(boost::bind(&tcp_session::up_thread_client_ssl_socket_clear_socket_handler,this)); | |
902 | + boost::mutex::scoped_lock lock(upthread_status_mutex); | |
903 | + while (unlikely(upthread_status == UPTHREAD_LOCK)) { | |
904 | + to_time(LOCKTIMEOUT, xt); | |
905 | + upthread_status_cond.timed_wait(lock, xt); | |
906 | + tcp_thread_message *msg = up_thread_message_que.pop(); | |
907 | + if (msg) { // message is alive. | |
908 | + up_thread_next_call_function.second(LOCAL_PROC); | |
909 | + delete msg; | |
910 | + msg = NULL; | |
911 | + } | |
912 | + } // lockmode while loop end. | |
901 | 913 | } |
902 | 914 | |
903 | 915 | upthread_status = UPTHREAD_SLEEP; |
@@ -1193,7 +1205,7 @@ void tcp_session::up_thread_client_accept_fail_event(const TCP_PROCESS_TYPE_TAG | ||
1193 | 1205 | |
1194 | 1206 | boost::format fmt("Thread ID[%d] tcp_ssl_socket::handshake[%s]"); |
1195 | 1207 | fmt % boost::this_thread::get_id() % handshake_error_code.message(); |
1196 | - Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 71, fmt.str(), __FILE__, __LINE__); | |
1208 | + Logger::putLogError(LOG_CAT_L7VSD_SESSION, 71, fmt.str(), __FILE__, __LINE__); | |
1197 | 1209 | |
1198 | 1210 | } |
1199 | 1211 | up_thread_next_call_function = up_thread_function_array[func_tag]; |
@@ -4029,6 +4041,30 @@ void tcp_session::down_thread_sorryserver_async_read_some_handler(const boost::s | ||
4029 | 4041 | downthread_status_cond.notify_one(); |
4030 | 4042 | } |
4031 | 4043 | |
4044 | +void tcp_session::up_thread_client_ssl_socket_clear_socket_handler() | |
4045 | +{ | |
4046 | + if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
4047 | + boost::format formatter("Thread ID[%d] FUNC IN up_thread_client_ssl_socket_clear_socket_handler"); | |
4048 | + formatter % boost::this_thread::get_id(); | |
4049 | + Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
4050 | + } | |
4051 | + | |
4052 | + client_ssl_socket.clear_socket(); | |
4053 | + | |
4054 | + tcp_thread_message *mes = new tcp_thread_message(); | |
4055 | + mes->message = up_que_function_map[UP_FUNC_PAUSE_OFF_EVENT]; | |
4056 | +#ifdef DEBUG | |
4057 | + mes->func_tag_name = func_tag_to_string(UP_FUNC_PAUSE_OFF_EVENT); | |
4058 | + { | |
4059 | + boost::format fmt("Thread ID[%d] up_queue.push : %s"); | |
4060 | + fmt % boost::this_thread::get_id() % func_tag_to_string(UP_FUNC_PAUSE_OFF_EVENT); | |
4061 | + Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__); | |
4062 | + } | |
4063 | +#endif | |
4064 | + while (!up_thread_message_que.push(mes)) {} | |
4065 | + upthread_status_cond.notify_one(); | |
4066 | +} | |
4067 | + | |
4032 | 4068 | void tcp_session::down_thread_sorryserver_handle_async_read_some(tcp_session::TCP_PROCESS_TYPE_TAG) |
4033 | 4069 | { |
4034 | 4070 |