• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

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

Révision9a42cba8f6a3ef11e1315fb54cbd822c2cae9d00 (tree)
l'heure2012-07-30 15:55:41
AuteurHiroaki Nakano <nakano.hiroaki@nttc...>
CommiterHiroaki Nakano

Message de Log

ticket 29142 リアルサーバ切り離し時クラッシュ対処

SSL+sessionless+リアルサーバ切り離しで、まれに以下の現象が出る。
- l7vsdがクラッシュ(コアダンプ)する
- l7vsdプロセスのCPU使用率が100%に張り付く

原因は、非同期処理の待ち合わせを行うactive_sessions.do_all()を
l7vsadm -d実行時の通信スレッド停止・再開でも流用していたため。
そのために、非同期で待ち合わせていたスレッドが、l7vsadm -dで
再開させられていた。

対処として、active_sessions.do_all()を廃止し、l7vsadm -d時は
各スレッドに終了処理に入るようメッセージを飛ばす方式とした。
また、新規接続処理に、l7vsadmコマンドの待ち合わせ処理を追加。

Change Summary

Modification

--- a/l7vsd/include/tcp_session.h
+++ b/l7vsd/include/tcp_session.h
@@ -129,7 +129,7 @@ public:
129129 void down_thread_run();
130130 //! realserver remove
131131 //! @param[in] target endpoint
132- void realserver_remove(boost::asio::ip::tcp::endpoint &);
132+ void realserver_remove(const boost::asio::ip::tcp::endpoint &);
133133 protected:
134134 typedef data_buff_base<boost::asio::ip::tcp> tcp_data;
135135 typedef boost::asio::ip::tcp::endpoint endpoint;
--- a/l7vsd/include/virtualservice.h
+++ b/l7vsd/include/virtualservice.h
@@ -268,6 +268,10 @@ protected:
268268 bool downqos_alert_flag; //! downstream QoS alert flag
269269 bool sessionpool_alert_flag; //! sessionpool alert flag
270270
271+ bool adm_cmd_wait_flag; //! wait for l7vsadm done
272+ boost::mutex adm_cmd_wait_flag_mutex;
273+ boost::condition adm_cmd_wait_flag_cond;
274+
271275 void load_parameter(l7vs::error_code &);
272276
273277 virtual void handle_replication_interrupt(
--- a/l7vsd/src/tcp_session.cpp
+++ b/l7vsd/src/tcp_session.cpp
@@ -595,7 +595,9 @@ void tcp_session::set_virtual_service_message(const TCP_VIRTUAL_SERVICE_MESSAGE_
595595 fmt % boost::this_thread::get_id();
596596 Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
597597 }
598- break;
598+ //break;
599+ realserver_remove(endpoint_);
600+ return;
599601 case SORRY_STATE_ENABLE:
600602 //----Debug log----------------------------------------------------------------------
601603 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
@@ -1199,22 +1201,40 @@ void tcp_session::up_thread_client_accept_fail_event(const TCP_PROCESS_TYPE_TAG
11991201
12001202 //! real server remove
12011203 //! @param[in] target endpoint
1202-void tcp_session::realserver_remove(endpoint &target_endpoint)
1204+void tcp_session::realserver_remove(const endpoint &target_endpoint)
12031205 {
1206+
1207+ if (target_endpoint != realserver_endpoint && target_endpoint != connecting_endpoint) return;
1208+
12041209 tcp_thread_message *up_msg = new tcp_thread_message;
1205- up_thread_function_pair up_func = up_thread_function_array[UP_FUNC_REALSERVER_CHECK];
1210+ up_thread_function_pair up_func = up_thread_function_array[UP_FUNC_EXIT];
12061211 up_msg->message = up_func.second;
12071212 up_msg->endpoint_info = target_endpoint;
12081213 #ifdef DEBUG
1209- up_msg->func_tag_name = func_tag_to_string(UP_FUNC_REALSERVER_CHECK);
1214+ up_msg->func_tag_name = func_tag_to_string(UP_FUNC_EXIT);
12101215 {
12111216 boost::format fmt("Thread ID[%d] up_queue.push : %s");
1212- fmt % boost::this_thread::get_id() % func_tag_to_string(UP_FUNC_REALSERVER_CHECK);
1217+ fmt % boost::this_thread::get_id() % func_tag_to_string(UP_FUNC_EXIT);
12131218 Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
12141219 }
12151220 #endif
12161221 while (!up_thread_message_que.push(up_msg)) {}
12171222 upthread_status_cond.notify_one();
1223+
1224+ tcp_thread_message *down_msg = new tcp_thread_message;
1225+ down_thread_function_pair down_func = down_thread_function_array[DOWN_FUNC_EXIT];
1226+ down_msg->message = down_func.second;
1227+ down_msg->endpoint_info = target_endpoint;
1228+#ifdef DEBUG
1229+ down_msg->func_tag_name = func_tag_to_string(DOWN_FUNC_EXIT);
1230+ {
1231+ boost::format fmt("Thread ID[%d] down_queue.push : %s");
1232+ fmt % boost::this_thread::get_id() % func_tag_to_string(DOWN_FUNC_EXIT);
1233+ Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
1234+ }
1235+#endif
1236+ while (!down_thread_message_que.push(down_msg)) {}
1237+ downthread_status_cond.notify_one();
12181238 }
12191239
12201240
--- a/l7vsd/src/virtualservice_base.cpp
+++ b/l7vsd/src/virtualservice_base.cpp
@@ -69,6 +69,7 @@ l7vs::virtualservice_base::virtualservice_base(const l7vs::l7vsd &invsd,
6969 upqos_alert_flag = false;
7070 downqos_alert_flag = false;
7171 sessionpool_alert_flag = false;
72+ adm_cmd_wait_flag = false;
7273
7374 rs_list.clear();
7475 protomod = NULL;
--- a/l7vsd/src/virtualservice_tcp.cpp
+++ b/l7vsd/src/virtualservice_tcp.cpp
@@ -352,6 +352,13 @@ void l7vs::virtualservice_tcp::handle_accept(const l7vs::session_thread_control
352352 return;
353353 }
354354
355+ {
356+ boost::mutex::scoped_lock lock(adm_cmd_wait_flag_mutex);
357+ if (unlikely(adm_cmd_wait_flag)){
358+ adm_cmd_wait_flag_cond.wait(lock);
359+ }
360+ }
361+
355362 session_thread_control *stc_ptr_noconst = const_cast<session_thread_control *>(stc_ptr);
356363
357364 if (unlikely(err == boost::asio::error::operation_aborted)) { // nomal exit case
@@ -1290,9 +1297,6 @@ void l7vs::virtualservice_tcp::add_realserver(const l7vs::virtualservice_element
12901297 }
12911298 }
12921299
1293- //pause active sessions
1294- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_on, _1));
1295-
12961300 //add realserver
12971301 for (std::vector<realserver_element>::iterator itr = in_element.realserver_vector.begin();
12981302 itr != in_element.realserver_vector.end();
@@ -1305,9 +1309,6 @@ void l7vs::virtualservice_tcp::add_realserver(const l7vs::virtualservice_element
13051309 rs_list.push_back(rs);
13061310 }
13071311
1308- //run active sessions
1309- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_off, _1));
1310-
13111312 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) {
13121313 boost::format formatter("out_function: void virtualservice_tcp::add_realserver( "
13131314 "const l7vs::virtualservice_element& in,"
@@ -1384,8 +1385,11 @@ void l7vs::virtualservice_tcp::edit_realserver(const l7vs::virtualservice_elemen
13841385 }
13851386 }
13861387
1387- //pause active sessions
1388- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_on, _1));
1388+ //lock adm_cmd_wait_flag on
1389+ adm_cmd_wait_flag_mutex.lock();
1390+ adm_cmd_wait_flag = true;
1391+ adm_cmd_wait_flag_cond.notify_one();
1392+ adm_cmd_wait_flag_mutex.unlock();
13891393
13901394 //edit realserver
13911395 for (std::vector<realserver_element>::iterator itr = in_element.realserver_vector.begin();
@@ -1406,8 +1410,11 @@ void l7vs::virtualservice_tcp::edit_realserver(const l7vs::virtualservice_elemen
14061410 }
14071411 }
14081412
1409- //run active sessions
1410- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_off, _1));
1413+ //lock adm_cmd_wait_flag off
1414+ adm_cmd_wait_flag_mutex.lock();
1415+ adm_cmd_wait_flag = false;
1416+ adm_cmd_wait_flag_cond.notify_one();
1417+ adm_cmd_wait_flag_mutex.unlock();
14111418
14121419 err.setter(false, "");
14131420 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) {
@@ -1486,8 +1493,11 @@ void l7vs::virtualservice_tcp::del_realserver(const l7vs::virtualservice_element
14861493 }
14871494 }
14881495
1489- //pause active sessions
1490- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_on, _1));
1496+ //lock adm_cmd_wait_flag on
1497+ adm_cmd_wait_flag_mutex.lock();
1498+ adm_cmd_wait_flag = true;
1499+ adm_cmd_wait_flag_cond.notify_one();
1500+ adm_cmd_wait_flag_mutex.unlock();
14911501
14921502 //del realserver
14931503 for (std::vector<realserver_element>::iterator itr = in_element.realserver_vector.begin();
@@ -1503,8 +1513,11 @@ void l7vs::virtualservice_tcp::del_realserver(const l7vs::virtualservice_element
15031513 }
15041514 }
15051515
1506- //run active sessions
1507- active_sessions.do_all(boost::bind(&session_thread_control::session_pause_off, _1));
1516+ //lock adm_cmd_wait_flag off
1517+ adm_cmd_wait_flag_mutex.lock();
1518+ adm_cmd_wait_flag = false;
1519+ adm_cmd_wait_flag_cond.notify_one();
1520+ adm_cmd_wait_flag_mutex.unlock();
15081521
15091522 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) {
15101523 boost::format formatter("out_function: void virtualservice_tcp::del_realserver( "