• 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

UltraMonkey-L7 V3(multi-thread implementation)


Commit MetaInfo

Revision460763083dcb848ad381d765d17dd6be279e643f (tree)
Time2012-07-30 16:10:57
AuthorHiroaki Nakano <nakano.hiroaki@nttc...>
CommiterHiroaki Nakano

Log Message

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>

Change Summary

Incremental Difference

--- a/l7vsd/include/tcp_session.h
+++ b/l7vsd/include/tcp_session.h
@@ -542,6 +542,7 @@ protected:
542542 virtual void down_thread_client_handle_async_write_some(const TCP_PROCESS_TYPE_TAG);
543543 virtual void down_thread_sorryserver_async_read_some_handler(const boost::system::error_code &error_code, std::size_t len);
544544 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();
545546
546547 //! down thread receive from realserver and raise module event of handle_realserver_recv
547548 //! @param[in] process_type is process type
--- a/l7vsd/src/tcp_session.cpp
+++ b/l7vsd/src/tcp_session.cpp
@@ -897,7 +897,19 @@ void tcp_session::up_thread_run()
897897
898898 if (ssl_flag) {
899899 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.
901913 }
902914
903915 upthread_status = UPTHREAD_SLEEP;
@@ -1193,7 +1205,7 @@ void tcp_session::up_thread_client_accept_fail_event(const TCP_PROCESS_TYPE_TAG
11931205
11941206 boost::format fmt("Thread ID[%d] tcp_ssl_socket::handshake[%s]");
11951207 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__);
11971209
11981210 }
11991211 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
40294041 downthread_status_cond.notify_one();
40304042 }
40314043
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+
40324068 void tcp_session::down_thread_sorryserver_handle_async_read_some(tcp_session::TCP_PROCESS_TYPE_TAG)
40334069 {
40344070