OSDN Git Service

#336対応
authoryatabe <yatabe@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Wed, 25 Mar 2009 02:28:49 +0000 (02:28 +0000)
committeryatabe <yatabe@1ed66053-1c2d-0410-8867-f7571e6e31d3>
Wed, 25 Mar 2009 02:28:49 +0000 (02:28 +0000)
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-shamshel-PT@7743 1ed66053-1c2d-0410-8867-f7571e6e31d3

module/protocol/http_protocol_module_base.cpp
module/protocol/http_protocol_module_base.h
module/protocol/protocol_module_cinsert.cpp
module/protocol/protocol_module_cinsert.h

index 5b286f5..7df9f55 100644 (file)
@@ -1,10 +1,26 @@
-//
-//     @file   http_protocol_module_base.cpp
-//     @brief  shared object http protocol module absctract class
-//
-//     Distributed under the Boost Software License, Version 1.0.(See accompanying
-//     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
-//
+/*
+ *     @file   http_protocol_module_base.cpp
+ *     @brief  shared object protocol module abstract class
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing
+ * Copyright (C) 2009  NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************/
 #include <boost/xpressive/xpressive.hpp>
 
 #include "http_protocol_module_base.h"
@@ -35,6 +51,20 @@ cregex       status_code_regex_check
                        range('1', '3') >> repeat<2>(_d) >> _s >>
                        *_;
 
+cregex method_and_version_regex
+               = (     as_xpr("GET")           | as_xpr("HEAD")                | as_xpr("POST")                |
+                       as_xpr("PUT")           | as_xpr("PROPFIND")    | as_xpr("PROPPATCH")   |
+                       as_xpr("OPTIONS")       | as_xpr("CONNECT")             | as_xpr("COPY")                |
+                       as_xpr("TRACE")         | as_xpr("DELETE")              | as_xpr("LOCK")                |
+                       as_xpr("UNLOCK")        | as_xpr("MOVE")                | as_xpr("MKCOL")) >> _s >>
+                       +~_s >> _s >>
+                       "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1"));
+
+cregex version_and_status_code_regex
+               =       "HTTP/" >> (as_xpr("1.0")|as_xpr("1.1")) >> _s >>
+                       range('1', '3') >> repeat<2>(_d) >> _s >>
+                       *_;
+
 cregex uri_regex
                =       +alpha >> _s >>
                        (s1 = *~_s) >> _s >>
@@ -342,6 +372,191 @@ l7vs::http_protocol_module_base::check_status_code(       const char* buffer,
 
 }
 
+l7vs::http_protocol_module_base::CHECK_RESULT_TAG
+l7vs::http_protocol_module_base::check_http_method_and_version(
+                                                                                                       const char* buffer,
+                                                                                                       const size_t buffer_len ) const {
+
+       //---------- DEBUG LOG START ------------------------------
+       if( LOG_LV_DEBUG == getloglevel())
+       {
+               boost::format   outform(        "function in  : [check_http_method_and_version] : "
+                                                                       "buffer_len = [%d]" );
+
+               outform % buffer_len;
+
+               putLogDebug(    0,
+                                               outform.str(),
+                                               __FILE__,
+                                               __LINE__ );
+       }
+       //---------- DEBUG LOG END ------------------------------
+
+       l7vs::http_protocol_module_base::CHECK_RESULT_TAG       check_result = CHECK_OK;
+
+       char*   check_string    = NULL;
+       size_t  line_length             = 0;
+
+       if( buffer != NULL ){
+
+               for( line_length = 0; line_length < buffer_len; line_length++ ){
+
+                       if( buffer[line_length] == '\r' || buffer[line_length] == '\n' ){
+
+                               break;
+
+                       }
+
+               }
+
+               if( line_length < buffer_len ){
+
+                       check_string = (char*)malloc( line_length + 1 );
+
+                       if( check_string != NULL ){
+                               memcpy( check_string, buffer, line_length );
+       
+                               check_string[line_length] = '\0';
+       
+                               if( !regex_match( check_string, method_and_version_regex )){
+       
+                                       check_result = CHECK_NG;
+       
+                               }
+       
+                               free( check_string );
+                       }
+                       else{
+
+                               check_result = CHECK_NG;
+
+                       }
+
+               }
+               else{
+
+                       check_result = CHECK_INPOSSIBLE;
+
+               }
+
+       }
+       else{
+
+               check_result = CHECK_NG;
+
+       }
+
+       //---------- DEBUG LOG START ------------------------------
+       if( LOG_LV_DEBUG == getloglevel())
+       {
+               boost::format   outform(        "function out : [check_http_method_and_version] : "
+                                                                       "check_result = [%d]" );
+
+               outform % check_result;
+
+               putLogDebug(    0,
+                                               outform.str(),
+                                               __FILE__,
+                                               __LINE__ );
+       }
+       //---------- DEBUG LOG END ------------------------------
+
+       return check_result;
+
+}
+
+l7vs::http_protocol_module_base::CHECK_RESULT_TAG
+l7vs::http_protocol_module_base::check_http_version_and_status_code(
+                                                                                                       const char* buffer,
+                                                                                                       const size_t buffer_len ) const {
+
+       //---------- DEBUG LOG START ------------------------------
+       if( LOG_LV_DEBUG == getloglevel())
+       {
+               boost::format   outform(        "function in  : [check_http_version_and_status_code] : "
+                                                                       "buffer_len = [%d]" );
+
+               outform % buffer_len;
+
+               putLogDebug(    0,
+                                               outform.str(),
+                                               __FILE__,
+                                               __LINE__ );
+       }
+       //---------- DEBUG LOG END ------------------------------
+
+       l7vs::http_protocol_module_base::CHECK_RESULT_TAG       check_result = CHECK_OK;
+
+       char*   check_string    = NULL;
+       size_t  line_length             = 0;
+
+       if( buffer != NULL ){
+
+               for( line_length = 0; line_length < buffer_len; line_length++ ){
+
+                       if( buffer[line_length] == '\r' || buffer[line_length] == '\n' ){
+
+                               break;
+
+                       }
+
+               }
+
+               if( line_length < buffer_len ){
+
+                       check_string = (char*)malloc( line_length + 1 );
+
+                       if( check_string != NULL ){
+                               memcpy( check_string, buffer, line_length );
+       
+                               check_string[line_length] = '\0';
+       
+                               if( !regex_match( check_string, version_and_status_code_regex )){
+       
+                                       check_result = CHECK_NG;
+       
+                               }
+       
+                               free( check_string );
+                       }
+                       else{
+
+                               check_result = CHECK_NG;
+
+                       }
+
+               }
+               else{
+
+                       check_result = CHECK_INPOSSIBLE;
+
+               }
+
+       }
+       else{
+
+               check_result = CHECK_NG;
+
+       }
+
+       //---------- DEBUG LOG START ------------------------------
+       if( LOG_LV_DEBUG == getloglevel())
+       {
+               boost::format   outform(        "function out : [check_http_version_and_status_code] : "
+                                                                       "check_result = [%d]" );
+
+               outform % check_result;
+
+               putLogDebug(    0,
+                                               outform.str(),
+                                               __FILE__,
+                                               __LINE__ );
+       }
+       //---------- DEBUG LOG END ------------------------------
+
+       return check_result;
+
+}
 
 bool   l7vs::http_protocol_module_base::find_uri(      const char* buffer,
                                                                                                        const size_t buffer_len,
index b9a634b..13379d5 100644 (file)
@@ -1,11 +1,26 @@
-//
-//     @file   http_protocol_module_base.h
-//     @brief  shared object http protocol module absctract class
-//
-//     Distributed under the Boost Software License, Version 1.0.(See accompanying
-//     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
-//
-
+/*
+ *     @file   http_protocol_module_base.h
+ *     @brief  shared object protocol module abstract class
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing
+ * Copyright (C) 2009  NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************/
 #ifndef        HTTP_PROTOCOL_MODULE_BASE_H
 #define        HTTP_PROTOCOL_MODULE_BASE_H
 
@@ -28,16 +43,31 @@ protected:
        //! @param const size_t                 buffer_len
        //! @return CHECK_RESULT_TAG    http method is valid
        CHECK_RESULT_TAG        check_http_method( const char*, const size_t ) const;
+
        //! check http version function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @return     CHECK_RESULT_TAG        http version 1.0 or 1.1
        CHECK_RESULT_TAG        check_http_version( const char*, const size_t ) const;
+
        //! check http status code function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @return     CHECK_RESULT_TAG        status code is nomal or error
        CHECK_RESULT_TAG        check_status_code( const char*, const size_t ) const;
+
+       //! check http method and version function
+       //! @param const char*                  buffer
+       //! @param const size_t                 buffer_len
+       //! @return CHECK_RESULT_TAG    http method and version is valid
+       CHECK_RESULT_TAG        check_http_method_and_version( const char*, const size_t ) const;
+
+       //! check http version and status code function
+       //! @param const char*                  buffer
+       //! @param const size_t                 buffer_len
+       //! @return CHECK_RESULT_TAG    http version and status code is valid
+       CHECK_RESULT_TAG        check_http_version_and_status_code( const char*, const size_t ) const;
+
        //! serch uri function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
@@ -45,6 +75,7 @@ protected:
        //! @param size_t&                              uri length
        //! @return bool                                find is true. not find is false
        bool    find_uri( const char*, const size_t, size_t&, size_t&);
+
        //! serch status function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
@@ -52,7 +83,8 @@ protected:
        //! @param size_t&                              status length
        //! @return bool                                find is true. not find is false
        bool    find_status_code( const char*, const size_t, size_t&, size_t& );
-       //! serch http header
+
+       //! serch http header function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @param const string&                header name
@@ -60,37 +92,44 @@ protected:
        //! @param size_t&                              header length
        //! @return bool                                find is true. not find is false
        bool    find_http_header( const char*, const size_t, const std::string&, size_t&, size_t& );
-       //! serch http header Cookie
+
+       //! serch http header Cookie function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @param size_t&                              header offset
        //! @param size_t&                              header length
        //! @return bool                                find is true. not find is false
        bool    find_http_header_cookie( const char*, const size_t, size_t&, size_t& );
-       //! serch http header Content_Length
+
+       //! serch http header Content_Length function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @param size_t&                              header offset
        //! @param size_t&                              header length
        //! @return bool                                find is true. not find is false
        bool    find_http_header_content_length( const char*, const size_t, size_t&, size_t& );
-       //! serch http header X_Forwarded_For
+
+       //! serch http header X_Forwarded_For function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @param size_t&                              header offset
        //! @param size_t&                              header length
        //! @return bool                                find is true. not find is false
        bool    find_http_header_x_forwarded_for( const char*, const size_t, size_t&, size_t& );
-       //! serch http header all
+
+       //! serch http header all function
        //! @param const char*                  buffer
        //! @param const size_t                 buffer_len
        //! @param size_t&                              header offset
        //! @param size_t&                              header length
        //! @return bool                                find is true. not find is false
        bool    find_http_header_all( const char*, const size_t, size_t&, size_t& );
+
 public:
+
        //! constractor
        http_protocol_module_base( std::string in_modulename ) : protocol_module_base( in_modulename ){};
+
        //! destractor
        virtual ~http_protocol_module_base(){};
 };
index fab781a..4a985d2 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ *     @file   protocol_module_cinsert.cpp
+ *     @brief  shared object protocol module class
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing
+ * Copyright (C) 2009  NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************/
 #include <vector>
 #include <list>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -1133,7 +1156,8 @@ protocol_module_cinsert::handle_session_initialize(
                down_thread_data->client_endpoint_tcp           = client_endpoint_tcp;
 
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rw_scoped_lock  lock( session_thread_data_map_mutex );
                        session_thread_data_map[ up_thread_id ]         = up_thread_data;
                        session_thread_data_map[ down_thread_id ]       = down_thread_data;
                }
@@ -1209,7 +1233,8 @@ protocol_module_cinsert::handle_session_finalize(
        try
        {
 
-               boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//             boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+               rw_scoped_lock  lock( session_thread_data_map_mutex );
 
                thread_data_itr = session_thread_data_map.find( up_thread_id );
 
@@ -1296,7 +1321,8 @@ protocol_module_cinsert::handle_accept( const boost::thread::id thread_id )
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -1410,7 +1436,8 @@ protocol_module_cinsert::handle_client_recv(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -1609,7 +1636,21 @@ protocol_module_cinsert::handle_client_recv(
                                                else if( send_status_itr->status == SEND_NG )
                                                {
 
-                                                       check_result = check_http_method(
+//                                                     check_result = check_http_method(
+//                                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                                     + send_status_itr->send_offset,
+//                                                                                             unsend_data_size );
+// 
+//                                                     if( check_result == CHECK_OK )
+//                                                     {
+// 
+//                                                             check_result = check_http_version(
+//                                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                                             + send_status_itr->send_offset,
+//                                                                                                     unsend_data_size );
+//                                                     }
+
+                                                       check_result = check_http_method_and_version(
                                                                                                (const char*)recive_data_itr->second.recive_buffer
                                                                                                        + send_status_itr->send_offset,
                                                                                                unsend_data_size );
@@ -1617,15 +1658,6 @@ protocol_module_cinsert::handle_client_recv(
                                                        if( check_result == CHECK_OK )
                                                        {
 
-                                                               check_result = check_http_version(
-                                                                                                       (const char*)recive_data_itr->second.recive_buffer
-                                                                                                               + send_status_itr->send_offset,
-                                                                                                       unsend_data_size );
-                                                       }
-
-                                                       if( check_result == CHECK_OK )
-                                                       {
-
 //                                                             find_result = find_http_header(
 //                                                                                             (const char*)recive_data_itr->second.recive_buffer
 //                                                                                                     + send_status_itr->send_offset,
@@ -1793,7 +1825,21 @@ protocol_module_cinsert::handle_client_recv(
                                                send_status_add.edit_division           = 0;
                                                send_status_add.send_offset                     = next_request_offset;
 
-                                               check_result = check_http_method(
+//                                             check_result = check_http_method(
+//                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                             + send_status_add.send_offset,
+//                                                                                     rest_request_data_size );
+// 
+//                                             if( check_result == CHECK_OK )
+//                                             {
+// 
+//                                                     check_result = check_http_version(
+//                                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                                     + send_status_add.send_offset,
+//                                                                                             rest_request_data_size );
+//                                             }
+
+                                               check_result = check_http_method_and_version(
                                                                                        (const char*)recive_data_itr->second.recive_buffer
                                                                                                + send_status_add.send_offset,
                                                                                        rest_request_data_size );
@@ -1801,15 +1847,6 @@ protocol_module_cinsert::handle_client_recv(
                                                if( check_result == CHECK_OK )
                                                {
 
-                                                       check_result = check_http_version(
-                                                                                               (const char*)recive_data_itr->second.recive_buffer
-                                                                                                       + send_status_add.send_offset,
-                                                                                               rest_request_data_size );
-                                               }
-
-                                               if( check_result == CHECK_OK )
-                                               {
-
 //                                                     find_result = find_http_header(
 //                                                                                     (const char*)recive_data_itr->second.recive_buffer
 //                                                                                             + send_status_add.send_offset,
@@ -2079,7 +2116,8 @@ protocol_module_cinsert::handle_realserver_select(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -2181,9 +2219,11 @@ protocol_module_cinsert::handle_realserver_select(
                                                                        boost::asio::ip::tcp::endpoint
                                                                                endpoint_tmp(   boost::asio::ip::address::from_string(cookie_address),
                                                                                                                boost::lexical_cast<unsigned short>(cookie_port));
-               
+
+                                                                       rs_list_lock();
+
                                                                        rs_list_itr = rs_list_begin();
-               
+
                                                                        while( rs_list_itr != rs_list_end())
                                                                        {
                
@@ -2196,6 +2236,9 @@ protocol_module_cinsert::handle_realserver_select(
                
                                                                                rs_list_itr = rs_list_next( rs_list_itr );
                                                                        }
+
+                                                                       rs_list_unlock();
+
                                                                } catch (...)
                                                                {
                                                                        boost::format   outform(        "cookie value invalid endpoint : [handle_realserver_select] : "
@@ -2352,7 +2395,8 @@ protocol_module_cinsert::handle_realserver_connect(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -2749,7 +2793,8 @@ protocol_module_cinsert::handle_realserver_connection_fail(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -2839,7 +2884,8 @@ protocol_module_cinsert::handle_realserver_send( const boost::thread::id thread_
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -3000,7 +3046,8 @@ protocol_module_cinsert::handle_sorryserver_select(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -3144,7 +3191,8 @@ protocol_module_cinsert::handle_sorryserver_connect(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -3559,7 +3607,8 @@ protocol_module_cinsert::handle_sorryserver_connection_fail(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -3649,7 +3698,8 @@ protocol_module_cinsert::handle_sorryserver_send( const boost::thread::id thread
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -3833,7 +3883,8 @@ protocol_module_cinsert::handle_realserver_recv(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -4046,7 +4097,21 @@ protocol_module_cinsert::handle_realserver_recv(
                                        else if( send_status_itr->status == SEND_NG )
                                        {
 
-                                               check_result = check_status_code(
+//                                             check_result = check_status_code(
+//                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                             + send_status_itr->send_offset,
+//                                                                                     unsend_data_size );
+// 
+//                                             if( check_result == CHECK_OK )
+//                                             {
+// 
+//                                                     check_result = check_http_version(
+//                                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                                     + send_status_itr->send_offset,
+//                                                                                             unsend_data_size );
+//                                             }
+
+                                               check_result = check_http_version_and_status_code(
                                                                                        (const char*)recive_data_itr->second.recive_buffer
                                                                                                + send_status_itr->send_offset,
                                                                                        unsend_data_size );
@@ -4054,15 +4119,6 @@ protocol_module_cinsert::handle_realserver_recv(
                                                if( check_result == CHECK_OK )
                                                {
 
-                                                       check_result = check_http_version(
-                                                                                               (const char*)recive_data_itr->second.recive_buffer
-                                                                                                       + send_status_itr->send_offset,
-                                                                                               unsend_data_size );
-                                               }
-
-                                               if( check_result == CHECK_OK )
-                                               {
-
 //                                                     find_result = find_http_header(
 //                                                                                     (const char*)recive_data_itr->second.recive_buffer
 //                                                                                             + send_status_itr->send_offset,
@@ -4232,7 +4288,21 @@ protocol_module_cinsert::handle_realserver_recv(
                                        send_status_add.edit_division           = 0;
                                        send_status_add.send_offset                     = next_response_offset;
 
-                                       check_result = check_status_code(
+//                                     check_result = check_status_code(
+//                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                     + send_status_add.send_offset,
+//                                                                             rest_response_data_size );
+// 
+//                                     if( check_result == CHECK_OK )
+//                                     {
+// 
+//                                             check_result = check_http_version(
+//                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                             + send_status_add.send_offset,
+//                                                                                     rest_response_data_size );
+//                                     }
+
+                                       check_result = check_http_version_and_status_code(
                                                                                (const char*)recive_data_itr->second.recive_buffer
                                                                                        + send_status_add.send_offset,
                                                                                rest_response_data_size );
@@ -4240,15 +4310,6 @@ protocol_module_cinsert::handle_realserver_recv(
                                        if( check_result == CHECK_OK )
                                        {
 
-                                               check_result = check_http_version(
-                                                                                       (const char*)recive_data_itr->second.recive_buffer
-                                                                                               + send_status_add.send_offset,
-                                                                                       rest_response_data_size );
-                                       }
-
-                                       if( check_result == CHECK_OK )
-                                       {
-
 //                                             find_result = find_http_header(
 //                                                                             (const char*)recive_data_itr->second.recive_buffer
 //                                                                                     + send_status_add.send_offset,
@@ -4527,7 +4588,8 @@ protocol_module_cinsert::handle_sorryserver_recv(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -4735,21 +4797,26 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                        else if( send_status_itr->status == SEND_NG )
                                        {
 
-                                               check_result = check_status_code(
+//                                             check_result = check_status_code(
+//                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                             + send_status_itr->send_offset,
+//                                                                                     unsend_data_size );
+// 
+//                                             if( check_result == CHECK_OK )
+//                                             {
+//                                                     check_result = check_http_version(
+//                                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                                     + send_status_itr->send_offset,
+//                                                                                             unsend_data_size );
+//                                             }
+
+                                               check_result = check_http_version_and_status_code(
                                                                                        (const char*)recive_data_itr->second.recive_buffer
                                                                                                + send_status_itr->send_offset,
                                                                                        unsend_data_size );
 
                                                if( check_result == CHECK_OK )
                                                {
-                                                       check_result = check_http_version(
-                                                                                               (const char*)recive_data_itr->second.recive_buffer
-                                                                                                       + send_status_itr->send_offset,
-                                                                                               unsend_data_size );
-                                               }
-
-                                               if( check_result == CHECK_OK )
-                                               {
 
 //                                                     find_result = find_http_header(
 //                                                                                     (const char*)recive_data_itr->second.recive_buffer
@@ -4918,21 +4985,26 @@ protocol_module_cinsert::handle_sorryserver_recv(
                                        send_status_add.edit_division           = 0;
                                        send_status_add.send_offset                     = next_response_offset;
 
-                                       check_result = check_status_code(
+//                                     check_result = check_status_code(
+//                                                                             (const char*)recive_data_itr->second.recive_buffer
+//                                                                                     + send_status_add.send_offset,
+//                                                                             rest_response_data_size );
+// 
+//                                     if( check_result == CHECK_OK )
+//                                     {
+//                                             check_result = check_http_version(
+//                                                                                     (const char*)recive_data_itr->second.recive_buffer
+//                                                                                             + send_status_add.send_offset,
+//                                                                                     rest_response_data_size );
+//                                     }
+
+                                       check_result = check_http_version_and_status_code(
                                                                                (const char*)recive_data_itr->second.recive_buffer
                                                                                        + send_status_add.send_offset,
                                                                                rest_response_data_size );
 
                                        if( check_result == CHECK_OK )
                                        {
-                                               check_result = check_http_version(
-                                                                                       (const char*)recive_data_itr->second.recive_buffer
-                                                                                               + send_status_add.send_offset,
-                                                                                       rest_response_data_size );
-                                       }
-
-                                       if( check_result == CHECK_OK )
-                                       {
 
 //                                             find_result = find_http_header(
 //                                                                             (const char*)recive_data_itr->second.recive_buffer
@@ -5199,7 +5271,8 @@ protocol_module_cinsert::handle_client_connection_check(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -5613,7 +5686,8 @@ protocol_module_cinsert::handle_client_send( const boost::thread::id thread_id )
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -5848,7 +5922,8 @@ protocol_module_cinsert::handle_sorry_enable( const boost::thread::id thread_id
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -6094,7 +6169,8 @@ protocol_module_cinsert::handle_sorry_disable( const boost::thread::id thread_id
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -6342,7 +6418,8 @@ protocol_module_cinsert::handle_realserver_disconnect(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
@@ -6535,7 +6612,8 @@ protocol_module_cinsert::handle_sorryserver_disconnect(
        try
        {
                {
-                       boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+//                     boost::mutex::scoped_lock       lock( session_thread_data_map_mutex );
+                       rd_scoped_lock  lock( session_thread_data_map_mutex );
 
                        thread_data_itr = session_thread_data_map.find( thread_id );
 
index 03f2102..0ca06b3 100644 (file)
@@ -1,6 +1,30 @@
+/*
+ *     @file   protocol_module_cinsert.h
+ *     @brief  shared object protocol module class
+ *
+ * L7VSD: Linux Virtual Server for Layer7 Load Balancing
+ * Copyright (C) 2009  NTT COMWARE Corporation.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ **********************************************************************/
 #include <boost/thread/mutex.hpp>
 #include <boost/shared_ptr.hpp>
 #include "http_protocol_module_base.h"
+#include "wrlock.h"
 
 #ifndef PROTOCOL_MODULE_CINSERT_H
 #define PROTOCOL_MODULE_CINSERT_H
@@ -99,8 +123,6 @@ public:
                                                                ( unsend_size == in.unsend_size )                               &&
                                                                ( edit_division == in.edit_division )                   &&
                                                                ( send_endpoint == in.send_endpoint )   );
-//                                                             ( send_endpoint == in.send_endpoint )                   &&
-//                                                             ( edit_data_list == in.edit_data_list ) );
                                }
 
                bool    operator!=( const send_status& in )
@@ -113,8 +135,6 @@ public:
                                                                ( unsend_size != in.unsend_size )                               ||
                                                                ( edit_division != in.edit_division )                   ||
                                                                ( send_endpoint != in.send_endpoint )   );
-//                                                             ( send_endpoint != in.send_endpoint )                   ||
-//                                                             ( edit_data_list != in.edit_data_list ) );
                                }
 
                send_status() :
@@ -154,8 +174,6 @@ public:
                                                                ( recive_buffer_2 == in.recive_buffer_2 )                                       &&
                                                                ( recive_buffer_max_size == in.recive_buffer_max_size )         &&
                                                                ( recive_buffer_rest_size == in.recive_buffer_rest_size ));
-//                                                             ( recive_buffer_rest_size == in.recive_buffer_rest_size )       &&
-//                                                             ( send_status_list == in.send_status_list )     );
                                }
 
                bool    operator!=( const recive_data& in )
@@ -165,8 +183,6 @@ public:
                                                                ( recive_buffer_2 != in.recive_buffer_2 )                                       ||
                                                                ( recive_buffer_max_size != in.recive_buffer_max_size )         ||
                                                                ( recive_buffer_rest_size != in.recive_buffer_rest_size )       );
-//                                                             ( recive_buffer_rest_size != in.recive_buffer_rest_size )       ||
-//                                                             ( send_status_list != in.send_status_list )     );
                                }
 
                recive_data() :
@@ -217,7 +233,6 @@ public:
                                {       return  (       ( thread_id == in.thread_id )                                                           &&
                                                                ( thread_division == in.thread_division )                                       &&
                                                                ( pair_thread_id == in.pair_thread_id )                                         &&
-//                                                             ( recive_data_map == in.recive_data_map )                                       &&
                                                                ( end_flag == in.end_flag )                                                                     &&
                                                                ( accept_end_flag == in.accept_end_flag )                                       &&
                                                                ( sorry_flag == in.sorry_flag )                                                         &&
@@ -232,7 +247,6 @@ public:
                                        return  (       ( thread_id != in.thread_id )                                                           ||
                                                                ( thread_division != in.thread_division )                                       ||
                                                                ( pair_thread_id != in.pair_thread_id )                                         ||
-//                                                             ( recive_data_map != in.recive_data_map )                                       ||
                                                                ( end_flag != in.end_flag )                                                                     ||
                                                                ( accept_end_flag != in.accept_end_flag )                                       ||
                                                                ( sorry_flag != in.sorry_flag )                                                         ||
@@ -300,7 +314,8 @@ protected:
        boost::array< char, MAX_OPTION_SIZE >   cookie_name;
        boost::array< char, MAX_OPTION_SIZE >   sorry_uri;
        t_session_thread_data_map       session_thread_data_map;
-       boost::mutex    session_thread_data_map_mutex;
+//     boost::mutex    session_thread_data_map_mutex;
+       wr_mutex        session_thread_data_map_mutex;
 
 public:
        protocol_module_cinsert();