• R/O
  • HTTP
  • SSH
  • HTTPS

ultramonkey-l7-v3: Commit

UltraMonkey-L7 V3(multi-thread implementation)


Commit MetaInfo

Revisãoc5dfe971ffbb513dfd972bfc6c78c4b8e75f1b2f (tree)
Hora2015-06-05 10:51:29
Autorroot <root@um01...>
Commiterroot

Mensagem de Log

Merge branch 'v3.1.2-devel'

Mudança Sumário

Diff

--- a/l7vsd/include/tcp_session.h
+++ b/l7vsd/include/tcp_session.h
@@ -546,6 +546,7 @@ protected:
546546 virtual void down_thread_sorryserver_async_read_some_handler(const boost::system::error_code &error_code, std::size_t len);
547547 virtual void down_thread_sorryserver_handle_async_read_some(const TCP_PROCESS_TYPE_TAG);
548548 virtual void up_thread_client_ssl_socket_clear_socket_handler();
549+ virtual void up_thread_client_disconnect_handler(const boost::system::error_code &error_code);
549550
550551 //! down thread receive from realserver and raise module event of handle_realserver_recv
551552 //! @param[in] process_type is process type
--- a/l7vsd/include/tcp_ssl_socket.h
+++ b/l7vsd/include/tcp_ssl_socket.h
@@ -38,6 +38,7 @@ class tcp_ssl_socket : public basic_tcp_socket< ssl_socket >
3838 public:
3939 // typedef
4040 typedef boost::function< void (const boost::system::error_code &) > async_handshake_handler_t;
41+ typedef boost::function< void (const boost::system::error_code &) > async_shutdown_handler_t;
4142
4243 // constructor
4344 tcp_ssl_socket(
@@ -124,6 +125,14 @@ public:
124125 return error_code ? false : true;
125126 }
126127
128+ virtual void async_shutdown(async_handshake_handler_t handler) {
129+ boost::mutex::scoped_lock lock(ssl_mutex);
130+ boost::system::error_code error_code;
131+ shutdown_con++;
132+ my_socket->lowest_layer().cancel(error_code);
133+ my_socket->async_shutdown(ssl_strand.wrap(handler));
134+ }
135+
127136 virtual std::size_t read_some(const boost::asio::mutable_buffers_1 &buffers, boost::system::error_code &error_code) {
128137 boost::mutex::scoped_lock lock(ssl_mutex);
129138 if (write_con > 0 || handshake_con > 0) {
@@ -203,9 +212,19 @@ public:
203212 return write_con;
204213 }
205214
215+ void decrement_shutdown_con() {
216+ boost::mutex::scoped_lock lock(ssl_mutex);
217+ shutdown_con--;
218+ ssl_cond.notify_one();
219+ }
220+
221+ int get_shutdown_con() {
222+ return shutdown_con;
223+ }
224+
206225 void wait_async_event_all_end() {
207226 boost::mutex::scoped_lock lock(ssl_mutex);
208- while (handshake_con > 0 || read_con > 0 || write_con > 0) {
227+ while (handshake_con > 0 || read_con > 0 || write_con > 0 || shutdown_con > 0) {
209228 boost::format fmt("handshake_con : %d read_con = %d write_con = %d ");
210229 fmt % handshake_con % read_con % write_con ;
211230 Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
@@ -225,6 +244,7 @@ protected:
225244 int handshake_con;
226245 int read_con;
227246 int write_con;
247+ int shutdown_con;
228248
229249 virtual void set_quickack(boost::system::error_code &error_code) {
230250 int err = ::setsockopt(my_socket->lowest_layer().native(), IPPROTO_TCP, TCP_QUICKACK, &opt_info.quickack_val, sizeof(opt_info.quickack_val));
--- a/l7vsd/src/tcp_session.cpp
+++ b/l7vsd/src/tcp_session.cpp
@@ -1494,7 +1494,12 @@ void tcp_session::up_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process
14941494 fmt % boost::this_thread::get_id() % ec.message();
14951495 Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
14961496 #endif
1497- func_tag = UP_FUNC_CLIENT_DISCONNECT;
1497+ upthread_status = UPTHREAD_LOCK;
1498+ tcp_ssl_socket::async_shutdown_handler_t handler;
1499+ handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
1500+ client_ssl_socket.async_shutdown(handler);
1501+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
1502+ return;
14981503 } else if (ec == boost::asio::error::eof) {
14991504 #ifdef DEBUG
15001505 boost::format fmt("Thread ID[%d] ssl_shutdown fail: %s");
@@ -4121,6 +4126,37 @@ void tcp_session::down_thread_sorryserver_async_read_some_handler(const boost::s
41214126 downthread_status_cond.notify_one();
41224127 }
41234128
4129+void tcp_session::up_thread_client_disconnect_handler(const boost::system::error_code &error_code)
4130+{
4131+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
4132+ boost::format fmt("Thread ID[%d] FUNC IN up_thread_client_disconnect_handler");
4133+ fmt % boost::this_thread::get_id();
4134+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
4135+ }
4136+
4137+ client_ssl_socket.decrement_shutdown_con();
4138+
4139+ tcp_thread_message *up_msg = new tcp_thread_message();
4140+ if (error_code == boost::asio::error::try_again) {
4141+ tcp_ssl_socket::async_shutdown_handler_t handler;
4142+ handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
4143+ client_ssl_socket.async_shutdown(handler);
4144+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
4145+ return;
4146+ } else {
4147+ up_msg->message = up_que_function_map[UP_FUNC_CLIENT_DISCONNECT_EVENT];
4148+ while (!up_thread_message_que.push(up_msg)) {}
4149+ }
4150+
4151+ upthread_status_cond.notify_one();
4152+
4153+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
4154+ boost::format fmt("Thread ID[%d] FUNC OUT up_thread_client_disconnect_handler");
4155+ fmt % boost::this_thread::get_id() ;
4156+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
4157+ }
4158+}
4159+
41244160 void tcp_session::up_thread_client_ssl_socket_clear_socket_handler()
41254161 {
41264162 if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
Show on old repository browser