OSDN Git Service

アクセスログ処理追加
authoryamada <yamada@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 17 Dec 2009 00:56:06 +0000 (00:56 +0000)
committeryamada <yamada@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Thu, 17 Dec 2009 00:56:06 +0000 (00:56 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-ramiel@9200 1ed66053-1c2d-0410-8867-f7571e6e31d3

l7vsd/include/tcp_session.h
l7vsd/src/tcp_session.cpp

index 0ae6212..f745e4d 100644 (file)
 
 namespace l7vs{
 
-//!    @class    virtualservice_tcp
-//! @brief    this class is parent virtualservice class.
+    //! @class    virtualservice_tcp
+    //! @brief    this class is parent virtualservice class.
     class virtualservice_tcp;
 
-//!    @class    tcp_thread_message
-//! @brief    tcp_thread_message class name define.
+    //! @class    tcp_thread_message
+    //! @brief    tcp_thread_message class name define.
     class tcp_thread_message;
 
-//!    @class    loger_implement_access
-//! @brief    logger_implement_access class name define.
+    //! @class    loger_implement_access
+    //! @brief    logger_implement_access class name define.
     class logger_implement_access;
 
-//!    @class    tcp_session
-//! @brief    this class is tcp session class.
+    //! @class    tcp_session
+    //! @brief    this class is tcp session class.
     class tcp_session : private boost::noncopyable{
         public:
             //! process type
@@ -96,14 +96,14 @@ namespace l7vs{
             //! @param[in]        set_access_logger is
             //!                     session use access logger
             tcp_session(virtualservice_tcp& vs,
-                    boost::asio::io_service& session_io,
-                    const tcp_socket_option_info set_option,
-                    const boost::asio::ip::tcp::endpoint listen_endpoint,
-                    const bool ssl_mode,
-                    boost::asio::ssl::context& set_ssl_context,
-                    const bool set_ssl_cache_flag,
-                    const int set_ssl_handshake_time_out,
-                    logger_implement_access* set_access_logger);
+                 boost::asio::io_service& session_io,
+                 const tcp_socket_option_info set_option,
+                 const boost::asio::ip::tcp::endpoint listen_endpoint,
+                 const bool ssl_mode,
+                 boost::asio::ssl::context& set_ssl_context,
+                 const bool set_ssl_cache_flag,
+                 const int set_ssl_handshake_time_out,
+                 logger_implement_access* set_access_logger);
 
             //! destructor
             virtual ~tcp_session();
@@ -121,7 +121,8 @@ namespace l7vs{
             bool is_thread_wait();
             //! message from parent virtualservice
             //! @param[in]        message is tcp virtualservice message type
-            void set_virtual_service_message(const TCP_VIRTUAL_SERVICE_MESSAGE_TAG  message);
+            void set_virtual_service_message(
+                 const TCP_VIRTUAL_SERVICE_MESSAGE_TAG  message);
             //! up stream thread main function
             void up_thread_run();
             //! down stream thread main function
@@ -134,54 +135,56 @@ namespace l7vs{
             typedef boost::function< void(TCP_PROCESS_TYPE_TAG) > tcp_session_func;
             //! up thread call function type
             enum UP_THREAD_FUNC_TYPE_TAG{
-                UP_FUNC_CLIENT_ACCEPT = 0,                //! up_thread_client_accept function
+                UP_FUNC_CLIENT_ACCEPT = 0,                  //! up_thread_client_accept function
                 UP_FUNC_CLIENT_ACCEPT_EVENT,                //! up_thread_client_accept_event function
-                UP_FUNC_CLIENT_DISCONNECT,                //! up_thread_client_disconnect function
+                UP_FUNC_CLIENT_DISCONNECT,                  //! up_thread_client_disconnect function
                 UP_FUNC_CLIENT_DISCONNECT_EVENT,            //! up_thread_client_disconnect_event function
-                UP_FUNC_CLIENT_RECEIVE,                    //! up_thread_client_receive function
+                UP_FUNC_CLIENT_RECEIVE,                     //! up_thread_client_receive function
                 UP_FUNC_CLIENT_RESPOND_SEND,                //! up_thread_client_respond function
-                UP_FUNC_CLIENT_RESPOND_SEND_EVENT,            //! up_thread_client_respond_event function
-                UP_FUNC_REALSERVER_GET_DEST_EVENT,            //! up_thread_realserver_get_distination_event function
-                UP_FUNC_REALSERVER_CONNECT,                //! up_thread_realserver_connect function
-                UP_FUNC_REALSERVER_CONNECT_EVENT,            //! up_thread_realserver_connect_event function
-                UP_FUNC_REALSERVER_CONNECT_FAIL_EVENT,            //! up_thread_realserver_connection_fail_event function
-                UP_FUNC_REALSERVER_SEND,                //! up_thread_realserver_send function
-                UP_FUNC_REALSERVER_DISCONNECT,                //! up_thread_realserver_disconnect function
-                UP_FUNC_REALSERVER_DISCONNECT_EVENT,            //! up_thread_realserver_disconnect_event function
-                UP_FUNC_REALSERVER_ALL_DISCONNECT,            //! up_thread_all_realserver_disconnect function
-                UP_FUNC_SORRYSERVER_GET_DEST,                //! up_thread_sorryserver_get_destination_event function
+                UP_FUNC_CLIENT_RESPOND_SEND_EVENT,          //! up_thread_client_respond_event function
+                UP_FUNC_REALSERVER_GET_DEST_EVENT,          //! up_thread_realserver_get_distination_event function
+                UP_FUNC_REALSERVER_CONNECT,                 //! up_thread_realserver_connect function
+                UP_FUNC_REALSERVER_CONNECT_EVENT,           //! up_thread_realserver_connect_event function
+                UP_FUNC_REALSERVER_CONNECT_FAIL_EVENT,      //! up_thread_realserver_connection_fail_event function
+                UP_FUNC_REALSERVER_SEND,                    //! up_thread_realserver_send function
+                UP_FUNC_REALSERVER_DISCONNECT,              //! up_thread_realserver_disconnect function
+                UP_FUNC_REALSERVER_DISCONNECT_EVENT,        //! up_thread_realserver_disconnect_event function
+                UP_FUNC_REALSERVER_ALL_DISCONNECT,          //! up_thread_all_realserver_disconnect function
+                UP_FUNC_SORRYSERVER_GET_DEST,               //! up_thread_sorryserver_get_destination_event function
                 UP_FUNC_SORRYSERVER_CONNECT,                //! up_thread_sorryserver_connect function
-                UP_FUNC_SORRYSERVER_CONNECT_EVENT,            //! up_thread_sorryserver_connect_event function
-                UP_FUNC_SORRYSERVER_CONNECT_FAIL_EVENT,            //! up_thread_sorryserver_connection_fail_event function
-                UP_FUNC_SORRYSERVER_SEND,                //! up_thread_sorryserver_send function
-                UP_FUNC_SORRYSERVER_DISCONNECT,                //! up_thread_sorryserver_disconnect function
-                UP_FUNC_SORRYSERVER_MOD_DISCONNECT,            //! up_thread_sorryserver_mod_disconnect function
-                UP_FUNC_SORRYSERVER_DISCONNECT_EVENT,            //! up_thread_sorryserver_disconnect_event function
-                UP_FUNC_SORRY_ENABLE_EVENT,                //! up_thread_sorry_enable_event function
+                UP_FUNC_SORRYSERVER_CONNECT_EVENT,          //! up_thread_sorryserver_connect_event function
+                UP_FUNC_SORRYSERVER_CONNECT_FAIL_EVENT,     //! up_thread_sorryserver_connection_fail_event function
+                UP_FUNC_SORRYSERVER_SEND,                   //! up_thread_sorryserver_send function
+                UP_FUNC_SORRYSERVER_DISCONNECT,             //! up_thread_sorryserver_disconnect function
+                UP_FUNC_SORRYSERVER_MOD_DISCONNECT,         //! up_thread_sorryserver_mod_disconnect function
+                UP_FUNC_SORRYSERVER_DISCONNECT_EVENT,       //! up_thread_sorryserver_disconnect_event function
+                UP_FUNC_SORRY_ENABLE_EVENT,                 //! up_thread_sorry_enable_event function
                 UP_FUNC_SORRY_DISABLE_EVENT,                //! up_thread_sorry_disable_event function
-                UP_FUNC_EXIT                        //! up_thread_exit function
+                UP_FUNC_EXIT                                //! up_thread_exit function
             };
             //! down thread call function type
             enum DOWN_THREAD_FUNC_TYPE_TAG{
                 DOWN_FUNC_CLIENT_DISCONNECT = 0,            //! down_thread_client_disconnect function
-                DOWN_FUNC_CLIENT_DISCONNECT_EVENT,            //! down_thread_client_disconnect_event function
+                DOWN_FUNC_CLIENT_DISCONNECT_EVENT,          //! down_thread_client_disconnect_event function
                 DOWN_FUNC_CLIENT_CONNECTION_CHK,            //! down_thread_client_connection_chk_event function
-                DOWN_FUNC_CLIENT_SEND,                    //! down_thread_client_send function
-                DOWN_FUNC_CLIENT_RESPOND_SEND_EVENT,            //! down_thread_client_respond_event function
-                DOWN_FUNC_REALSERVER_RECEIVE,                //! down_thread_realserver_receive function
+                DOWN_FUNC_CLIENT_SEND,                      //! down_thread_client_send function
+                DOWN_FUNC_CLIENT_RESPOND_SEND_EVENT,        //! down_thread_client_respond_event function
+                DOWN_FUNC_REALSERVER_RECEIVE,               //! down_thread_realserver_receive function
                 DOWN_FUNC_REALSERVER_DISCONNECT,            //! down_thread_realserver_disconnect function
-                DOWN_FUNC_REALSERVER_DISCONNECT_EVENT,            //! down_thread_realserver_disconnect_event function
-                DOWN_FUNC_REALSERVER_ALL_DISCONNECT,            //! down_thread_all_realserver_disconnect function
-                DOWN_FUNC_SORRYSERVER_RECEIVE,                //! down_thread_sorryserver_receive function
-                DOWN_FUNC_SORRYSERVER_DISCONNECT,            //! down_thread_sorryserver_disconnect function
-                DOWN_FUNC_SORRYSERVER_MOD_DISCONNECT,            //! down_thread_sorryserver_mod_disconnect function
-                DOWN_FUNC_SORRYSERVER_DISCONNECT_EVENT,            //! down_thread_sorryserver_disconnect_event function
-                DOWN_FUNC_SORRY_ENABLE_EVENT,                //! down_thread_sorry_enable_event function
-                DOWN_FUNC_SORRY_DISABLE_EVENT,                //! down_thread_sorry_disable_event function
-                DOWN_FUNC_EXIT                                //! down_thread_exit function
+                DOWN_FUNC_REALSERVER_DISCONNECT_EVENT,      //! down_thread_realserver_disconnect_event function
+                DOWN_FUNC_REALSERVER_ALL_DISCONNECT,        //! down_thread_all_realserver_disconnect function
+                DOWN_FUNC_SORRYSERVER_RECEIVE,              //! down_thread_sorryserver_receive function
+                DOWN_FUNC_SORRYSERVER_DISCONNECT,           //! down_thread_sorryserver_disconnect function
+                DOWN_FUNC_SORRYSERVER_MOD_DISCONNECT,       //! down_thread_sorryserver_mod_disconnect function
+                DOWN_FUNC_SORRYSERVER_DISCONNECT_EVENT,     //! down_thread_sorryserver_disconnect_event function
+                DOWN_FUNC_SORRY_ENABLE_EVENT,               //! down_thread_sorry_enable_event function
+                DOWN_FUNC_SORRY_DISABLE_EVENT,              //! down_thread_sorry_disable_event function
+                DOWN_FUNC_EXIT                              //! down_thread_exit function
             };
-            typedef std::pair< UP_THREAD_FUNC_TYPE_TAG, tcp_session_func > up_thread_function_pair;
-            typedef std::pair< DOWN_THREAD_FUNC_TYPE_TAG, tcp_session_func > down_thread_function_pair;
+            typedef std::pair< UP_THREAD_FUNC_TYPE_TAG, tcp_session_func > 
+                up_thread_function_pair;
+            typedef std::pair< DOWN_THREAD_FUNC_TYPE_TAG, tcp_session_func > 
+                down_thread_function_pair;
             //! tcp_session use io service
             boost::asio::io_service& io;
             //! parent virtualservice
@@ -209,13 +212,16 @@ namespace l7vs{
             //! sorryserver socket
             socket_element sorryserver_socket;
             //! up thread use realserver socket map
-            std::map<endpoint,tcp_socket_ptr> up_thread_send_realserver_socket_map;
+            std::map<endpoint,tcp_socket_ptr> 
+                up_thread_send_realserver_socket_map;
             //! connect realserver list
             tcp_realserver_connect_socket_list down_thread_connect_socket_list;
             //! down thread use realserver socket list
-            std::list<socket_element> down_thread_receive_realserver_socket_list;
+            std::list<socket_element> 
+                down_thread_receive_realserver_socket_list;
             //! down thread next receive realserver
-            std::list<socket_element>::iterator down_thread_current_receive_realserver_socket;
+            std::list<socket_element>::iterator 
+                down_thread_current_receive_realserver_socket;
             //! module function mutex (handle_response_send_inform) 
             wr_mutex module_function_response_send_inform_mutex;
             //! module function mutex (handle_client_disconnect) 
@@ -229,11 +235,13 @@ namespace l7vs{
             //! module function mutex (handle_sorry_disable) 
             wr_mutex module_function_sorry_disable_mutex;
             //! up thread call function object array
-            up_thread_function_pair    up_thread_function_array[UP_FUNC_EXIT+1];
+            up_thread_function_pair up_thread_function_array[UP_FUNC_EXIT+1];
             //! up thread recept module event convert to up thread function type map
-            std::map< protocol_module_base::EVENT_TAG , UP_THREAD_FUNC_TYPE_TAG > up_thread_module_event_map;
+            std::map< protocol_module_base::EVENT_TAG , 
+                UP_THREAD_FUNC_TYPE_TAG > up_thread_module_event_map;
             //! up thread raise message map for down thread
-            std::map< DOWN_THREAD_FUNC_TYPE_TAG, tcp_session_func > up_thread_message_down_thread_function_map;
+            std::map< DOWN_THREAD_FUNC_TYPE_TAG, 
+                tcp_session_func > up_thread_message_down_thread_function_map;
             //! up thread next call function object
             up_thread_function_pair up_thread_next_call_function;
             //! up thread use client side buffer
@@ -241,15 +249,18 @@ namespace l7vs{
             //! up thread use destination side buffer
             tcp_data up_thread_data_dest_side;
             //! message data queue for up thread
-            lockfree_queue< tcp_thread_message >        up_thread_message_que;
+            lockfree_queue< tcp_thread_message > up_thread_message_que;
             //! up thread use message data
             tcp_data up_thread_message_data;
             //! down thread call function object array
-            down_thread_function_pair    down_thread_function_array[DOWN_FUNC_EXIT+1];
+            down_thread_function_pair
+                down_thread_function_array[DOWN_FUNC_EXIT+1];
             //! down thread recept module event convert to down thread function type map
-            std::map< protocol_module_base::EVENT_TAG ,DOWN_THREAD_FUNC_TYPE_TAG > down_thread_module_event_map;
+            std::map< protocol_module_base::EVENT_TAG ,
+                DOWN_THREAD_FUNC_TYPE_TAG > down_thread_module_event_map;
             //! down thread raise message map for up thread
-            std::map< UP_THREAD_FUNC_TYPE_TAG, tcp_session_func > down_thread_message_up_thread_function_map;
+            std::map< UP_THREAD_FUNC_TYPE_TAG, tcp_session_func > 
+                down_thread_message_up_thread_function_map;
             //! down thread next call function object
             down_thread_function_pair down_thread_next_call_function;
             //! down thread use client side buffer
@@ -265,9 +276,11 @@ namespace l7vs{
             //! downstream socket buffer size
             int downstream_buffer_size;
             //! virtual service message convert to up thread function object map
-            std::map< TCP_VIRTUAL_SERVICE_MESSAGE_TAG, tcp_session_func>  virtual_service_message_up_thread_function_map;
+            std::map< TCP_VIRTUAL_SERVICE_MESSAGE_TAG, tcp_session_func> 
+                virtual_service_message_up_thread_function_map;
             //! virtual service message convert to down thread function object map
-            std::map< TCP_VIRTUAL_SERVICE_MESSAGE_TAG, tcp_session_func>  virtual_service_message_down_thread_function_map;
+            std::map< TCP_VIRTUAL_SERVICE_MESSAGE_TAG, tcp_session_func>  
+                virtual_service_message_down_thread_function_map;
             //! client conection src endpoint
             boost::asio::ip::tcp::endpoint client_endpoint;
             //! virtualservice accept endpoint
@@ -287,7 +300,8 @@ namespace l7vs{
             //! ssl session cache flag
             bool ssl_cache_flag;
             //! ssl handshake timer
-            typedef boost::shared_ptr<boost::asio::deadline_timer>  deadline_timer_ptr_type;
+            typedef boost::shared_ptr<boost::asio::deadline_timer>  
+                 deadline_timer_ptr_type;
             deadline_timer_ptr_type ssl_handshake_timer;
             //! ssl handshake timer flag
             bool ssl_handshake_timer_flag;
@@ -300,149 +314,196 @@ namespace l7vs{
             //! socket option 
             tcp_socket_option_info socket_opt_info;
 
-
-
-            
+           
             //! handshake timer handler
-            virtual void handle_ssl_handshake_timer(const boost::system::error_code& error);
+            //! @param[in]        error is error code object
+            virtual void handle_ssl_handshake_timer(
+                 const boost::system::error_code& error);
             //! reset ssl object for reuse
-            virtual bool ssl_clear_keep_cache(SSL *clear_ssl);
-
-            
+            //! @param[in/out]    clear_ssl is clear target SSL structure pointer
+            virtual bool ssl_clear_keep_cache(SSL *clear_ssl);          
             //! up and down thread state update
             //! @param[in]        thread_flag is regist or unregist bitset
             //! @param[in]        regist is regist or unregist flag
-            virtual void thread_state_update(const std::bitset<TCP_SESSION_THREAD_STATE_BIT> thread_flag,const bool regist);
-
+            virtual void thread_state_update(
+                const std::bitset<TCP_SESSION_THREAD_STATE_BIT> thread_flag,
+                const bool regist);
+            //! endpoint data to string infomation
+            //! @param[in]        endpoint is target endpoint object
+            virtual std::string endpoint_to_string( 
+                const boost::asio::ip::tcp::endpoint& target_endpoint); 
             //! up thread accept client side
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_accept(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_accept(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_accept
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_accept_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_accept_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread receive client side and raise module event of handle_client_recv
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_receive(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise client respond send event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_respond(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_respond(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_response_send_inform
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_respond_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_respond_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close client socket and raise client disconnect event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_client_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_client_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_client_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread send realserver and raise module event of handle_client_recv
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_send(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_send(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_realserver_select
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_get_destination_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_get_destination_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread connect realserver
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_connect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_connect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_realserver_connect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_connect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_connect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_realserver_connection_fail
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_connection_fail_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_connection_fail_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close realserver socket and raise realserver disconnect event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_realserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_realserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_realserver_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close all realserver socket and raise module event of handle_realserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_all_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_all_realserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread send sorryserver and raise module event of handle_sorryserver_send
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_send(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_send(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorryserver_select
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_get_destination_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_get_destination_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread connect sorryserver
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_connect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_connect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorryserver_connect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_connect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_connect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorryserver_connection_fail
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_connection_fail_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_connection_fail_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close sorryserver socket and raise sorryserver disconnect event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close sorryserver socket and raise module sorryserver disconnect event
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_mod_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_mod_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorryserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorryserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorryserver_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorry_enable
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorry_enable_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorry_enable_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread raise module event of handle_sorry_disable
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_sorry_disable_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_sorry_disable_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread exit main loop
             //! @param[in]        process_type is prosecess type
-            virtual void up_thread_exit(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void up_thread_exit(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! up thread close all socket
             virtual void up_thread_all_socket_close(void);
 
             //! down thread receive from realserver and raise module event of handle_realserver_recv
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_realserver_receive(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close realserver socket and raise realserver disconnect event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_realserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_realserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_realserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_realserver_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close all realserver socket and raise module event of handle_realserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_all_realserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_all_realserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_client_connection_check
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_client_connection_chk_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_client_connection_chk_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_response_send_inform
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_client_respond_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_client_respond_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread send for client and raise module event of handle_client_send
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_client_send(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_client_send(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close client socket and raise client disconnect event message for up and down thread 
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_client_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_client_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_client_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_client_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_client_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread receive from sorryserver and raise module event of handle_sorryserver_recv
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorryserver_receive(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorryserver_receive(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close sorryserver socket and raise sorryserver disconnect event message for up and down thread
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorryserver_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorryserver_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close sorryserver socket and raise module sorryserver disconnect event
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorryserver_mod_disconnect(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorryserver_mod_disconnect(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_sorryserver_disconnect
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorryserver_disconnect_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorryserver_disconnect_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_sorry_enable
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorry_enable_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorry_enable_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread raise module event of handle_sorry_disable
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_sorry_disable_event(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_sorry_disable_event(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread exit main loop
             //! @param[in]        process_type is prosecess type
-            virtual void down_thread_exit(const TCP_PROCESS_TYPE_TAG process_type);
+            virtual void down_thread_exit(
+                const TCP_PROCESS_TYPE_TAG process_type);
             //! down thread close all socket
             virtual void down_thread_all_socket_close(void);
 
index 4b320d0..4770987 100644 (file)
@@ -778,16 +778,16 @@ namespace l7vs{
         } else {
             client_ssl_socket.accept();
         }
-        endpoint cl_end;
+        
         {
             rd_scoped_lock scoped_lock(exit_flag_update_mutex);
             is_exit = exit_flag;
         }
         if(likely( !is_exit )){
             if (!ssl_flag) {
-                cl_end = client_socket.get_socket().lowest_layer().remote_endpoint(ec);
+                client_endpoint = client_socket.get_socket().lowest_layer().remote_endpoint(ec);
             } else {
-                cl_end = client_ssl_socket.get_socket().lowest_layer().remote_endpoint(ec);
+                client_endpoint = client_ssl_socket.get_socket().lowest_layer().remote_endpoint(ec);
             }
             if(unlikely( ec )){
                 //client endpoint get Error!
@@ -892,7 +892,7 @@ namespace l7vs{
             is_exit = exit_flag;
         }
         if(likely(!is_exit)){
-            module_event = protocol_module->handle_session_initialize(up_thread_id,down_thread_id,cl_end,dumy_end);
+            module_event = protocol_module->handle_session_initialize(up_thread_id,down_thread_id,client_endpoint,dumy_end);
             func_type = up_thread_module_event_map.find(module_event);
             if(unlikely( func_type == up_thread_module_event_map.end() )){
                 //Error unknown protocol_module_base::EVENT_TAG return
@@ -1253,6 +1253,19 @@ namespace l7vs{
         //----Debug log----------------------------------------------------------------------
     }
 
+    //! endpoint data to string infomation
+    //! @param[in]        endpoint is target endpoint object
+    std::string tcp_session::endpoint_to_string(
+                const boost::asio::ip::tcp::endpoint& target_endpoint){
+        std::stringstream ret;
+       if( target_endpoint.address().is_v6() ){
+            ret << "[" << target_endpoint.address().to_string() << "]:" << target_endpoint.port();
+        }else{
+            ret << target_endpoint.address().to_string() << ":" << target_endpoint.port();
+        }
+        return ret.str();
+    }
+
     //! up thread accept client side
     //! @param[in]        process_type is prosecess type
     void tcp_session::up_thread_client_accept(const TCP_PROCESS_TYPE_TAG process_type){
@@ -1733,6 +1746,22 @@ namespace l7vs{
             boost::system::error_code ec;
             bool bres = new_socket->connect(server_endpoint,ec);
             if(likely( bres )){
+                {
+                    rd_scoped_lock scoped_lock( access_log_flag_mutex );
+                    if( access_log_flag && access_logger != NULL ){
+                        boost::asio::ip::tcp::endpoint server_side_endpoint = 
+                            new_socket->get_socket().local_endpoint(ec);
+                        if( !ec ){
+                            std::string reserv_msg("");
+                            access_logger->putLog(
+                                endpoint_to_string( virtualservice_endpoint ),
+                                endpoint_to_string( client_endpoint ),
+                                endpoint_to_string( server_side_endpoint ),
+                                endpoint_to_string( server_endpoint ), 
+                                reserv_msg);
+                        }
+                    }
+                }
                 parent_service.connection_active(server_endpoint);
                 if(unlikely( !new_socket->set_non_blocking_mode(ec) )){
                     // socket set nonblocking mode error