OSDN Git Service

Merge branch 'master' of https://scm.osdn.jp/gitroot/ultramonkey-l7/ultramonkey-l7...
authorMichiro Hibari <l05102@shibaura-it.ac.jp>
Thu, 8 Oct 2015 07:44:09 +0000 (16:44 +0900)
committerMichiro Hibari <l05102@shibaura-it.ac.jp>
Thu, 8 Oct 2015 07:44:09 +0000 (16:44 +0900)
Conflicts:
l7vsd/src/tcp_session.cpp

CHANGES
configure.in
l7vsd/include/tcp_session.h
l7vsd/include/tcp_ssl_socket.h
l7vsd/module/protocol/protocol_module_ip.cpp
l7vsd/src/tcp_session.cpp
ultramonkeyl7.spec

diff --git a/CHANGES b/CHANGES
index 29fe63c..f9dc75d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+[Sep. 11 2014] 3.1.2-1 HIBARI Michiro, Hiroaki Nakano
+  - Fixed degraded bug: re-patch for fixed #30300.
+
 [Mar. 9 2014] 3.1.1-1 HIBARI Michiro, Hiroaki Nakano
   - #33102 fix memory leak.
   - #33255 fix accessing endpoint at deleted realserver.
index 71f4da6..f87acc8 100644 (file)
@@ -1,7 +1,7 @@
 AC_PREREQ(2.59)
 AC_INIT(l7vsd, 3.1.1, ultramonkey-l7-develop@lists.sourceforge.jp)
 PACKAGENAME=l7vsd
-VERSION=3.1.1
+VERSION=3.1.2
 
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([config.h.in])
index 9784024..4947def 100644 (file)
@@ -546,6 +546,7 @@ protected:
         virtual void down_thread_sorryserver_async_read_some_handler(const boost::system::error_code &error_code, std::size_t len);
         virtual void down_thread_sorryserver_handle_async_read_some(const TCP_PROCESS_TYPE_TAG);
        virtual void up_thread_client_ssl_socket_clear_socket_handler();
+        virtual void up_thread_client_disconnect_handler(const boost::system::error_code &error_code);
 
         //! down thread receive from realserver and raise module event of handle_realserver_recv
         //! @param[in]        process_type is process type
index be91894..64de5a4 100644 (file)
@@ -38,6 +38,7 @@ class   tcp_ssl_socket : public basic_tcp_socket< ssl_socket >
 public:
         // typedef
         typedef boost::function< void (const boost::system::error_code &) > async_handshake_handler_t;
+        typedef boost::function< void (const boost::system::error_code &) > async_shutdown_handler_t;
 
         // constructor
         tcp_ssl_socket(
@@ -124,6 +125,14 @@ public:
                 return error_code ? false : true;
         }
 
+        virtual void async_shutdown(async_handshake_handler_t  handler) {
+                boost::mutex::scoped_lock       lock(ssl_mutex);
+                boost::system::error_code       error_code;
+                shutdown_con++;
+                my_socket->lowest_layer().cancel(error_code);
+                my_socket->async_shutdown(ssl_strand.wrap(handler));
+        }
+
         virtual std::size_t     read_some(const boost::asio::mutable_buffers_1 &buffers, boost::system::error_code &error_code) {
                 boost::mutex::scoped_lock       lock(ssl_mutex);
                 if (write_con > 0 || handshake_con > 0) {
@@ -203,9 +212,19 @@ public:
                 return write_con;
         }
 
+        void decrement_shutdown_con() {
+                boost::mutex::scoped_lock       lock(ssl_mutex);
+                shutdown_con--;
+                ssl_cond.notify_one();
+        }
+
+        int get_shutdown_con() {
+                return shutdown_con;
+        }
+
         void wait_async_event_all_end() {
                 boost::mutex::scoped_lock       lock(ssl_mutex);
-                while (handshake_con > 0 || read_con > 0 || write_con > 0) {
+                while (handshake_con > 0 || read_con > 0 || write_con > 0 || shutdown_con > 0) {
                         boost::format   fmt("handshake_con : %d read_con = %d write_con = %d ");
                         fmt % handshake_con % read_con % write_con ;
                         Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
@@ -225,6 +244,7 @@ protected:
         int handshake_con;
         int read_con;
         int write_con;
+        int shutdown_con;
 
         virtual void set_quickack(boost::system::error_code &error_code) {
                 int err = ::setsockopt(my_socket->lowest_layer().native(), IPPROTO_TCP, TCP_QUICKACK, &opt_info.quickack_val, sizeof(opt_info.quickack_val));
index 4cd2205..417505b 100644 (file)
@@ -5657,6 +5657,11 @@ bool protocol_module_ip::put_data_into_sendbuffer(
                         buffer_element.first += sendbuffer_rest_size;
                         buffer_element.second -= sendbuffer_rest_size;
                         sendbuffer_rest_size = 0;
+
+                        //add remain item
+                        data_ptr->buffer_sequence.push_back(buffer_element);
+                        //delete the item
+                        data_ptr->buffer_sequence.pop_front();
                         break;
                 }
         }
index 92ae51a..01c982a 100644 (file)
@@ -1144,9 +1144,9 @@ void tcp_session::up_thread_client_accept(const TCP_PROCESS_TYPE_TAG process_typ
                                                   boost::asio::placeholders::error));
         } else {
 #if BOOST_VERSION >= 105000
-                boost::xtime_get(&start_handshake_time, boost::TIME_UTC_);
+                boost::xtime_get(&client_connected_time, boost::TIME_UTC_);
 #else
-                boost::xtime_get(&start_handshake_time, boost::TIME_UTC);
+                boost::xtime_get(&client_connected_time, boost::TIME_UTC);
 #endif
                 upthread_status = UPTHREAD_ACTIVE;
         }
@@ -1502,7 +1502,12 @@ void tcp_session::up_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process
                         fmt % boost::this_thread::get_id() % ec.message();
                         Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
 #endif
-                        func_tag = UP_FUNC_CLIENT_DISCONNECT;
+                        upthread_status = UPTHREAD_LOCK;
+                        tcp_ssl_socket::async_shutdown_handler_t   handler;
+                        handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
+                        client_ssl_socket.async_shutdown(handler);
+                        up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+                        return;
                 } else if (ec == boost::asio::error::eof) {
 #ifdef  DEBUG
                         boost::format   fmt("Thread ID[%d] ssl_shutdown fail: %s");
@@ -4129,6 +4134,37 @@ void tcp_session::down_thread_sorryserver_async_read_some_handler(const boost::s
         downthread_status_cond.notify_one();
 }
 
+void tcp_session::up_thread_client_disconnect_handler(const boost::system::error_code &error_code)
+{
+        if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+               boost::format   fmt("Thread ID[%d] FUNC IN up_thread_client_disconnect_handler");
+               fmt % boost::this_thread::get_id();
+               Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
+        }
+
+        client_ssl_socket.decrement_shutdown_con();
+
+        tcp_thread_message     *up_msg = new tcp_thread_message();
+        if (error_code == boost::asio::error::try_again) {
+               tcp_ssl_socket::async_shutdown_handler_t   handler;
+               handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
+               client_ssl_socket.async_shutdown(handler);
+                up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+               return;
+        } else {
+               up_msg->message = up_que_function_map[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+               while (!up_thread_message_que.push(up_msg)) {}
+        }
+
+        upthread_status_cond.notify_one();
+
+        if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+               boost::format   fmt("Thread ID[%d] FUNC OUT up_thread_client_disconnect_handler");
+               fmt % boost::this_thread::get_id() ;
+               Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
+        }
+}
+
 void tcp_session::up_thread_client_ssl_socket_clear_socket_handler()
 {
         if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
index 23d68cd..97b0b0e 100644 (file)
@@ -6,7 +6,7 @@
 
 Summary: The Layer-7 Virtual Server
 Name: ultramonkeyl7
-Version: 3.1.1
+Version: 3.1.2
 Release: 1%{?dist}
 License: LGPLv2.1
 Group: System Environment/Daemons
@@ -133,6 +133,11 @@ fi
 %{moduledevel_tempdir}/*
 
 %changelog
+* Wed Sep 11 2014 Hiroaki Nakano <nakano.hiroaki@nttcom.co.jp> 3.1.2-1
+- Update for 3.1.2-1
+- Marge from 3.1.2-devel to master. And modefy version.
+- Fixed degraded bug: re-patch for fixed ticket 30300.
+
 * Fri Mar 7 2014 Hiroaki Nakano <nakano.hiroaki@nttcom.co.jp> 3.1.1-1
 - Update for 3.1.1-1
 - Marge from 3.1.1-devel to master. And modefy version.