OSDN Git Service

bug fix. Can not get statistic when option -c only.
[ultramonkey-l7/ultramonkey-l7-v3.git] / l7vsd / module / protocol / protocol_module_sessionless.cpp
index 4f2d5d1..27ef5dc 100644 (file)
@@ -59,14 +59,18 @@ const int protocol_module_sessionless::EDIT_DIVISION_EDIT = 1;
 
 const int protocol_module_sessionless::FORWARDED_FOR_OFF = 0;
 const int protocol_module_sessionless::FORWARDED_FOR_ON = 1;
-//! constractor
+
+const int protocol_module_sessionless::COLLECT_STATS_OFF = 0;
+const int protocol_module_sessionless::COLLECT_STATS_ON = 1;
+
+//! constructor
 protocol_module_sessionless::protocol_module_sessionless() :
         http_protocol_module_base(MODULE_NAME), forwarded_for(FORWARDED_FOR_OFF)
 {
         sorry_uri.assign('\0');
         sorry_uri[0] = '/';
 }
-//! destractor
+//! destructor
 protocol_module_sessionless::~protocol_module_sessionless()
 {
 }
@@ -98,7 +102,7 @@ bool protocol_module_sessionless::is_udp()
         return false;
 }
 
-//! replication interval interrrupt
+//! replication interval interrupt
 //! timer thread call this function. from virtualservice.
 void protocol_module_sessionless::replication_interrupt()
 {
@@ -136,9 +140,9 @@ void protocol_module_sessionless::initialize(rs_list_itr_func_type    inlist_beg
         rs_list_end = inlist_end;
         //RealServer list next function
         rs_list_next = inlist_next;
-        //RealServer list lock funtion
+        //RealServer list lock function
         rs_list_lock = inlist_lock;
-        //RealServer list unlock funtion
+        //RealServer list unlock function
         rs_list_unlock = inlist_unlock;
 
         /*-------- DEBUG LOG --------*/
@@ -161,7 +165,7 @@ void protocol_module_sessionless::finalize()
         }
         /*------DEBUG LOG END------*/
 
-        //RealServer list functions initializtion
+        //RealServer list functions initialization
         //RealServer list begin function
         rs_list_begin.clear();
         //RealServer list end function
@@ -181,8 +185,8 @@ void protocol_module_sessionless::finalize()
         }
         /*------DEBUG LOG END------*/
 
-        //Replication functions initializtion
-        //component memory allcate function
+        //Replication functions initialization
+        //component memory allocate function
         replication_pay_memory.clear();
         //component memory lock function
         replication_area_lock.clear();
@@ -197,7 +201,7 @@ void protocol_module_sessionless::finalize()
         }
         /*------DEBUG LOG END------*/
 
-        //ScheduleModule's functions initializtion
+        //ScheduleModule's functions initialization
         schedule_tcp.clear();
 
         /*-------- DEBUG LOG --------*/
@@ -208,7 +212,7 @@ void protocol_module_sessionless::finalize()
         }
         /*------DEBUG LOG END------*/
 
-        //Module's option initializtion
+        //Module's option initialization
         //forwarded_for
         forwarded_for = FORWARDED_FOR_OFF;
         //sorry-uri
@@ -228,7 +232,7 @@ void protocol_module_sessionless::finalize()
         /*------DEBUG LOG END------*/
 
 
-        //logger functions initializtion
+        //logger functions initialization
         //log level getting function
         getloglevel.clear();
         //logger(Fatal)
@@ -269,9 +273,9 @@ void protocol_module_sessionless::handle_rslist_update()
 }
 
 //! module parameter check.used by l7vsadm
-//! @param[in]    module paramter string list
-//! @return    result.flag true is parameter is noproblem.
-//! @return result.flag false is paramter is problem.
+//! @param[in]    module parameter string list
+//! @return    result.flag true is parameter is no problem.
+//! @return result.flag false is parameter is problem.
 protocol_module_base::check_message_result protocol_module_sessionless::check_parameter(const std::vector <
                 std::string > & args)
 {
@@ -295,14 +299,46 @@ protocol_module_base::check_message_result protocol_module_sessionless::check_pa
         check_result.flag = true;
         bool forward_checked = false;
         bool sorryuri_checked = false;
+        bool stats_checked = false;
+
+        // cf RFC 2396 (A. Collected BNF for URI)
         sregex    sorry_uri_regex
         =    +('/' >>
-               *(alpha |
-                 digit |
-                 (set = ';', ':', '@', '&', '=') |
-                 (set = '$', '-', '_', '.', '+') |
-                 (set = '!', '*', '\'', '\(', ')', ',') |
-                 '%' >> repeat<2>(xdigit)));
+               *(
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') |
+                 '%' >> repeat<2>(xdigit) |
+                 (set = ':', '@', '&', '=', '+', '$', ',')
+               )
+               >>
+               *(';' >>
+                 *(
+                   alpha | digit |
+                   (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                   '%' >> repeat<2>(xdigit) | // escaped
+                   (set = ':', '@', '&', '=', '+', '$', ',')
+                 ) // pchar
+               ) // param
+             ) // segment
+             >>
+             !('?' >>
+               *(
+                 (set = ';', '/', '?', ':', '@', '&', '=', '+', '$', ',') | //reserved
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                 '%' >> repeat<2>(xdigit) // escaped
+               ) // uric
+             ) // query
+             >>
+             !('#' >>
+               *(
+                 (set = ';', '/', '?', ':', '@', '&', '=', '+', '$', ',') | //reserved
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                 '%' >> repeat<2>(xdigit) // escaped
+               ) // uric
+             ); // fragment
+
         typedef std::vector<std::string>::const_iterator vec_str_it;
 
         try {
@@ -391,6 +427,54 @@ protocol_module_base::check_message_result protocol_module_sessionless::check_pa
                                         break;
                                 }
                         }
+                        //option string = "-c/--statistic"
+                        else if (*it == "-c" || *it == "--statistic") {
+                                //statistic flag is OFF
+                                if (!stats_checked) {
+                                        //next item exist
+                                        if(++it != it_end) {
+                                            //collect statistic flag must be 0 or 1
+                                            if(*it == "0" || *it == "1"){
+                                                        //check OK
+                                                        //set statistic flag ON
+                                                        stats_checked = true;                                            }
+                                            else {
+                                                        std::ostringstream ostr;
+                                                        ostr << "'-c/--statistic' option value '" << *it << "' is not a valid value.";
+
+                                                        //set check result flag false
+                                                        check_result.flag = false;
+                                                        //set check result message
+                                                        check_result.message = ostr.str();
+                                                        putLogError(100128, check_result.message, __FILE__, __LINE__);
+                                                        //loop break
+                                                        break;
+                                                }
+                                        }
+                                        //next item is not exist
+                                        else {
+                                                //set check flag false
+                                                check_result.flag = false;
+                                                //set check result message
+                                                check_result.message = "You have to set option value '-c/--statistic'.";
+                                                putLogError(100129, check_result.message, __FILE__,
+                                                            __LINE__);
+                                                //loop break
+                                                break;
+                                        }
+                                }
+                                //statistic flag is ON
+                                else {
+                                        //set check result flag false
+                                        check_result.flag = false;
+                                        //set check result message
+                                        check_result.message = "Cannot set multiple option '-c/--statistic'.";
+                                        putLogError(100130, check_result.message, __FILE__,
+                                                    __LINE__);
+                                        //loop break
+                                        break;
+                                }
+                        }
                         //other option string
                         else {
                                 //set check result flag false
@@ -432,9 +516,9 @@ protocol_module_base::check_message_result protocol_module_sessionless::check_pa
 }
 
 //! parameter set
-//! @param[in] module paramter string list
-//! @return    result.flag true is parameter is noproblem.
-//! @return result.flag false is paramter is problem.
+//! @param[in] module parameter string list
+//! @return    result.flag true is parameter is no problem.
+//! @return result.flag false is parameter is problem.
 protocol_module_base::check_message_result protocol_module_sessionless::set_parameter(const std::vector <
                 std::string > & args)
 {
@@ -458,14 +542,45 @@ protocol_module_base::check_message_result protocol_module_sessionless::set_para
         check_result.flag = true;
         bool forward_checked = false;
         bool sorryuri_checked = false;
+        bool stats_checked = false;
+
+        // cf RFC 2396 (A. Collected BNF for URI)
         sregex    sorry_uri_regex
         =    +('/' >>
-               *(alpha |
-                 digit |
-                 (set = ';', ':', '@', '&', '=') |
-                 (set = '$', '-', '_', '.', '+') |
-                 (set = '!', '*', '\'', '\(', ')', ',') |
-                 '%' >> repeat<2>(xdigit)));
+               *(
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') |
+                 '%' >> repeat<2>(xdigit) |
+                 (set = ':', '@', '&', '=', '+', '$', ',')
+               )
+               >>
+               *(';' >>
+                 *(
+                   alpha | digit |
+                   (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                   '%' >> repeat<2>(xdigit) | // escaped
+                   (set = ':', '@', '&', '=', '+', '$', ',')
+                 ) // pchar
+               ) // param
+             ) // segment
+             >>
+             !('?' >>
+               *(
+                 (set = ';', '/', '?', ':', '@', '&', '=', '+', '$', ',') | //reserved
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                 '%' >> repeat<2>(xdigit) // escaped
+               ) // uric
+             ) // query
+             >>
+             !('#' >>
+               *(
+                 (set = ';', '/', '?', ':', '@', '&', '=', '+', '$', ',') | //reserved
+                 alpha | digit |
+                 (set = '-', '_', '.', '!', '~', '*', '\'', '(', ')') | // mark
+                 '%' >> repeat<2>(xdigit) // escaped
+               ) // uric
+             ); // fragment
 
         typedef std::vector<std::string>::const_iterator vec_str_it;
 
@@ -559,6 +674,57 @@ protocol_module_base::check_message_result protocol_module_sessionless::set_para
                                         break;
                                 }
                         }
+                        //option string = "-c/--statistic"
+                        else if (*it == "-c" || *it == "--statistic") {
+                                //statistic flag is OFF
+                                if (!stats_checked) {
+                                        //next item exist
+                                        if(++it != it_end) {
+                                            //collect statistic flag must be 0 or 1
+                                            if(*it == "0" || *it == "1"){
+                                                        //check OK
+                                                        //set statistic flag ON
+                                                        stats_checked = true;
+
+                                                        //set collect statistic flag
+                                                        statistic = boost::lexical_cast<int>(*it);                                          }
+                                            else {
+                                                        std::ostringstream ostr;
+                                                        ostr << "'-c/--statistic' option value '" << *it << "' is not a valid value.";
+
+                                                        //set check result flag false
+                                                        check_result.flag = false;
+                                                        //set check result message
+                                                        check_result.message = ostr.str();
+                                                        putLogError(100131, check_result.message, __FILE__, __LINE__);
+                                                        //loop break
+                                                        break;
+                                                }
+                                        }
+                                        //next item is not exist
+                                        else {
+                                                //set check flag false
+                                                check_result.flag = false;
+                                                //set check result message
+                                                check_result.message = "You have to set option value '-c/--statistic'.";
+                                                putLogError(100132, check_result.message, __FILE__,
+                                                            __LINE__);
+                                                //loop break
+                                                break;
+                                        }
+                                }
+                                //statistic flag is ON
+                                else {
+                                        //set check result flag false
+                                        check_result.flag = false;
+                                        //set check result message
+                                        check_result.message = "Cannot set multiple option '-c/--statistic'.";
+                                        putLogError(100133, check_result.message, __FILE__,
+                                                    __LINE__);
+                                        //loop break
+                                        break;
+                                }
+                        }
                         //others
                         else {
                                 //set check result flag false
@@ -578,6 +744,11 @@ protocol_module_base::check_message_result protocol_module_sessionless::set_para
                         if (!forward_checked) {
                                 forwarded_for = FORWARDED_FOR_OFF;
                         }
+
+                        //collect statistic flag = OFF
+                        if (!stats_checked) {
+                                statistic = COLLECT_STATS_OFF;
+                        }
                 }
 
         } catch (const std::exception &ex) {
@@ -611,9 +782,9 @@ protocol_module_base::check_message_result protocol_module_sessionless::set_para
 }
 
 //! parameter add
-//! @param[in] module paramter string list
-//! @return    result.flag true is parameter is noproblem.
-//! @return result.flag false is paramter is problem.
+//! @param[in] module parameter string list
+//! @return    result.flag true is parameter is no problem.
+//! @return result.flag false is parameter is problem.
 protocol_module_base::check_message_result protocol_module_sessionless::add_parameter(const std::vector <
                 std::string > & args)
 {
@@ -659,7 +830,7 @@ protocol_module_base::check_message_result protocol_module_sessionless::add_para
 }
 
 //! get option info
-//! @param[out] module paramter string
+//! @param[out] module parameter string
 void protocol_module_sessionless::get_option_info(std::string &option)
 {
         /*-------- DEBUG LOG --------*/
@@ -669,8 +840,9 @@ void protocol_module_sessionless::get_option_info(std::string &option)
         }
         /*------DEBUG LOG END------*/
 
-        boost::format option_formatter("%s--sorry-uri '%s'");
-        option_formatter % (forwarded_for ? "--forwarded-for " : "") % sorry_uri.c_array();
+        boost::format option_formatter("%s--sorry-uri '%s' --statistic %d");
+        option_formatter % (forwarded_for ? "--forwarded-for " : "") % sorry_uri.c_array()
+                         % statistic;
         option.assign(option_formatter.str());
 
         /*-------- DEBUG LOG --------*/
@@ -683,7 +855,7 @@ void protocol_module_sessionless::get_option_info(std::string &option)
         /*------DEBUG LOG END------*/
 }
 
-//! TCP/IP scheduled function registation.
+//! TCP/IP scheduled function registration.
 //! @param[in] schedule module TCP/IP scheduled function object type
 void protocol_module_sessionless::register_schedule(tcp_schedule_func_type inschedule)
 {
@@ -702,8 +874,8 @@ void protocol_module_sessionless::register_schedule(tcp_schedule_func_type insch
         /*------DEBUG LOG END------*/
 }
 
-//! UDP scheduled function registation
-//! @param[in] schedule module UDP scheduled funtion object type
+//! UDP scheduled function registration
+//! @param[in] schedule module UDP scheduled function object type
 void protocol_module_sessionless::register_schedule(udp_schedule_func_type inschedule)
 {
         /*-------- DEBUG LOG --------*/
@@ -715,7 +887,7 @@ void protocol_module_sessionless::register_schedule(udp_schedule_func_type insch
         /*------DEBUG LOG END------*/
 }
 
-//! called from session initialzie use in upstream_thread
+//! called from session initialize use in upstream_thread
 //! @param[in]    upstream thread id.
 //! @param[in]    downstream thread id
 //! @return        session use EVENT mode.
@@ -985,7 +1157,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_accept(const
                         //set return status
                         status = SORRYSERVER_SELECT;
                 }
-                //sorry flag on
+                //sorry flag off
                 else {
                         //set return status
                         status = REALSERVER_SELECT;
@@ -1031,7 +1203,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_accept(const
 
 //! called from after session recv in client socket. use in upstream thread.
 //! @param[in]    upstream thread id
-//! @param[in]    receive buffer refarence.
+//! @param[in]    receive buffer reference.
 //! @param[in]    receive length
 //! @return        session use EVENT mode.
 protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(const boost::thread::id thread_id,
@@ -1227,7 +1399,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                 if (recv_data.receive_buffer_max_size < data_remain_size + recvlen) {
                                         //the buffer's size that will be allocated is exceed the upper limit value
                                         if (MAX_SESSIONLESS_MODULE_BUFFER_SIZE < data_remain_size + recvlen) {
-                                                std::cerr << "protocol_module_sessionless::handle_client_recv() : the buffer's size that will be allacted is exceed the upper limit value." << std::endl;
+                                                std::cerr << "protocol_module_sessionless::handle_client_recv() : the buffer's size that will be allocated is exceed the upper limit value." << std::endl;
                                                 boost::format formatter("The buffer's size that will be allocated is exceed the upper limit value. thread id : %d.");
                                                 formatter % boost::this_thread::get_id();
                                                 putLogError(100030, formatter.str(), __FILE__, __LINE__);
@@ -1352,7 +1524,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                         //set new buffer's max size
                                         recv_data.receive_buffer_max_size = buffer_size;
                                 }
-                                //buffer's max size >= remain data size + requst size
+                                //buffer's max size >= remain data size + request size
                                 //buffer isn't need reallocate, but switch
                                 else {
                                         //pointer valid check
@@ -1422,7 +1594,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                         }
                                         //using buffer is buffer2
                                         else {
-                                                //buffer1 initializtion
+                                                //buffer1 initialization
                                                 memset(recv_data.receive_buffer1, 0, recv_data.receive_buffer_max_size);
                                                 /*-------- DEBUG LOG --------*/
                                                 if (unlikely(LOG_LV_DEBUG == getloglevel())) {
@@ -1575,7 +1747,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                 }
                                 //status is SEND_NG
                                 else if (it->status == SEND_NG) {
-                                        if (forwarded_for == FORWARDED_FOR_ON) {
+                                        if (statistic == COLLECT_STATS_ON || forwarded_for == FORWARDED_FOR_ON) {
                                                 //check http method
                                                 check_result = check_http_method(recv_data.receive_buffer + it->send_offset, data_remain_size);
                                                 /*-------- DEBUG LOG --------*/
@@ -1673,6 +1845,18 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                                                                 it->send_rest_size = header_offset + header_offset_len + cr_lf_cr_lf_len;
                                                                         }
                                                                 }
+
+                                                                //increment http statistics
+                                                                increment_stats(recv_data.receive_buffer + it->send_offset);
+                                                                /*-------- DEBUG LOG --------*/
+                                                                if (unlikely(LOG_LV_DEBUG == getloglevel())) {
+                                                                        boost::format formatter("function : protocol_module_base::EVENT_TAG protocol_module_sessionless::"
+                                                                                                "handle_client_recv() : call increment_stats : thread id : %d.");
+                                                                        formatter % boost::this_thread::get_id();
+                                                                        putLogDebug(100263, formatter.str(), __FILE__, __LINE__);
+                                                                }
+                                                                /*------DEBUG LOG END------*/
+
                                                                 //set edit_division flag on
                                                                 it->edit_division = EDIT_DIVISION_EDIT;
                                                         }
@@ -1770,11 +1954,11 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                 //add new status to status_list
                                 recv_data.send_status_list.push_back(new_send_state);
                                 std::list<send_status>::reverse_iterator new_send_it = recv_data.send_status_list.rbegin();
-                                //cacl offset
+                                //calc offset
                                 new_send_it->send_offset = recv_data.receive_buffer_max_size - recv_data.receive_buffer_rest_size
                                                            - request_data_remain_size;
 
-                                if (forwarded_for == FORWARDED_FOR_ON || session_data->sorry_flag == SORRY_FLAG_ON) {
+                                if (statistic == COLLECT_STATS_ON || forwarded_for == FORWARDED_FOR_ON || session_data->sorry_flag == SORRY_FLAG_ON) {
                                         //check http method
                                         check_result = check_http_method(recv_data.receive_buffer + new_send_it->send_offset,
                                                                          request_data_remain_size);
@@ -1875,6 +2059,18 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_recv(
                                                                 }
 
                                                         }
+
+                                                        //increment http statistics
+                                                        increment_stats(recv_data.receive_buffer + new_send_it->send_offset);
+                                                        /*-------- DEBUG LOG --------*/
+                                                        if (unlikely(LOG_LV_DEBUG == getloglevel())) {
+                                                                boost::format formatter("function : protocol_module_base::EVENT_TAG protocol_module_sessionless::"
+                                                                                        "handle_client_recv() : call increment_stats : thread id : %d.");
+                                                                formatter % boost::this_thread::get_id();
+                                                                putLogDebug(100264, formatter.str(), __FILE__, __LINE__);
+                                                        }
+                                                        /*------DEBUG LOG END------*/
+
                                                         //set edit_division flag on
                                                         new_send_it->edit_division = EDIT_DIVISION_EDIT;
                                                 }
@@ -2343,7 +2539,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_c
                                         it->edit_division = EDIT_DIVISION_NO_EDIT;
 
                                         if (send_buffer_remian_size > 0 && it->send_possible_size > 0) {
-                                                //send_buffer_remian_size is larger
+                                                //send_buffer_remain_size is larger
                                                 if (send_buffer_remian_size >= it->send_possible_size) {
                                                         copy_size = it->send_possible_size;
                                                         /*-------- DEBUG LOG --------*/
@@ -2429,10 +2625,10 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_c
                                 }
                                 //edit_data_list is not empty
                                 else {
-                                        //find the item in the list which has mininum insert_posission
+                                        //find the item in the list which has minimum insert_position
                                         std::list<edit_data>::iterator edit_min = std::min_element(it->edit_data_list.begin(),
                                                         it->edit_data_list.end());
-                                        //send_buffer_remian_size is larger than data that before X-Forwarded-For
+                                        //send_buffer_remain_size is larger than data that before X-Forwarded-For
                                         if (send_buffer_remian_size >= edit_min->insert_posission - it->send_end_size) {
                                                 //copy data before X-Forwarded-For
                                                 copy_size = edit_min->insert_posission - it->send_end_size;
@@ -2514,7 +2710,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_c
                                                         break;
                                                 }
                                         }
-                                        //data that before X-Forwarded-For is larger than send_buffer_remian_size
+                                        //data that before X-Forwarded-For is larger than send_buffer_remain_size
                                         else {
                                                 copy_size = send_buffer_remian_size;
                                                 /*-------- DEBUG LOG --------*/
@@ -2641,7 +2837,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_c
                         }
                 }
 
-                //set copyed data length
+                //set copied data length
                 datalen = send_buffer_end_size - send_buffer_remian_size;
                 status = REALSERVER_SEND;
         } catch (int e) {
@@ -2843,7 +3039,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_s
                         //offset recalc
                         it->send_offset += it->send_end_size;
 
-                        //insert_posission recalc
+                        //insert_position recalc
                         for (std::list<edit_data>::iterator list_it = it->edit_data_list.begin(); list_it
                              != it->edit_data_list.end(); ++list_it) {
                                 list_it->insert_posission -= it->send_end_size;
@@ -2918,7 +3114,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_s
 
 //! called from after sorryserver select
 //! @param[in]    upstream thread id
-//! @param[in]    sorryserver endpiont reference
+//! @param[in]    sorryserver endpoint reference
 //! @return        session use EVENT mode.
 protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_select(
         const boost::thread::id thread_id, boost::asio::ip::tcp::endpoint &sorry_endpoint)
@@ -3135,7 +3331,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                         }
                                 }
 
-                                if (forwarded_for == FORWARDED_FOR_ON || session_data->sorry_flag == SORRY_FLAG_ON) {
+                                if (forwarded_for == FORWARDED_FOR_ON) {
                                         //search X-Forwarded-For header
                                         ret = find_http_header(recv_data.receive_buffer + it->send_offset, it->send_possible_size,
                                                                str_forword_for.c_str(), header_offset, header_offset_len);
@@ -3225,7 +3421,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                         it->edit_division = EDIT_DIVISION_NO_EDIT;
 
                                         if (send_buffer_remian_size > 0 && it->send_possible_size > 0) {
-                                                //send_buffer_remian_size is larger
+                                                //send_buffer_remain_size is larger
                                                 if (send_buffer_remian_size > it->send_possible_size) {
                                                         //copy data from receive_buffer to sendbuffer by sending_possible size
                                                         copy_size = it->send_possible_size;
@@ -3308,10 +3504,10 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                 }
                                 //edit_data_list is not empty
                                 else {
-                                        //search item which insert_posission is mininum
+                                        //search item which insert_position is minimum
                                         std::list<edit_data>::iterator edit_min = std::min_element(it->edit_data_list.begin(),
                                                         it->edit_data_list.end());
-                                        //send_buffer_remian_size is larger than data that before X-Forwarded-For/uri
+                                        //send_buffer_remain_size is larger than data that before X-Forwarded-For/uri
                                         if (send_buffer_remian_size >= edit_min->insert_posission - it->send_end_size) {
                                                 //copy data before X-Forwarded-For/url
                                                 copy_size = edit_min->insert_posission - it->send_end_size;
@@ -3393,7 +3589,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                                         break;
                                                 }
                                         }
-                                        //data that before X-Forwarded-For/uri is larger than send_buffer_remian_size
+                                        //data that before X-Forwarded-For/uri is larger than send_buffer_remain_size
                                         else {
                                                 copy_size = send_buffer_remian_size;
                                                 /*-------- DEBUG LOG --------*/
@@ -3523,7 +3719,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                         }
                 }
 
-                //set copyed data length
+                //set copied data length
                 datalen = send_buffer_end_size - send_buffer_remian_size;
 
                 status = SORRYSERVER_SEND;
@@ -3732,7 +3928,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                         //offset recalc
                         it->send_offset += it->send_end_size;
 
-                        //insert_posission recalc
+                        //insert_position recalc
                         for (std::list<edit_data>::iterator list_it = it->edit_data_list.begin(); list_it
                              != it->edit_data_list.end(); ++list_it) {
                                 list_it->insert_posission -= it->send_end_size;
@@ -3743,12 +3939,12 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                 }
                 //sending possible data is not exist
                 else {
-                        //can receive from clent continue
+                        //can receive from client continue
                         if (it->send_rest_size > 0) {
                                 //change status from SEND_OK to SEND_CONTINUE
                                 it->status = SEND_CONTINUE;
                         }
-                        //can not receive from clent continue
+                        //can not receive from client continue
                         else {
                                 //change status from SEND_OK to SEND_END
                                 it->status = SEND_END;
@@ -3830,7 +4026,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_r
         return STOP;
 }
 
-//! called from after realserver recvive for TCP/IP
+//! called from after realserver receive for TCP/IP
 //! @param[in]    downstream thread id
 //! @param[in]    realserver TCP/IP endpoint reference
 //! @param[in]    realserver receive buffer reference.
@@ -4026,7 +4222,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_r
                         if (recv_data.receive_buffer_max_size < data_remain_size + recvlen) {
                                 //the buffer's size that will be allocated is exceed the upper limit value
                                 if (MAX_SESSIONLESS_MODULE_BUFFER_SIZE < data_remain_size + recvlen) {
-                                        std::cerr << "protocol_module_sessionless::handle_realserver_recv() : the buffer's size that will be allacted is exceed the upper limit value." << std::endl;
+                                        std::cerr << "protocol_module_sessionless::handle_realserver_recv() : the buffer's size that will be allocated is exceed the upper limit value." << std::endl;
                                         boost::format formatter("The buffer's size that will be allocated is exceed the upper limit value. thread id : %d.");
                                         formatter % boost::this_thread::get_id();
                                         putLogError(100083, formatter.str(), __FILE__, __LINE__);
@@ -4155,7 +4351,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_r
                                 //set new buffer's max size
                                 recv_data.receive_buffer_max_size = buffer_size;
                         }
-                        //buffer's max size >= remain data size + requst size
+                        //buffer's max size >= remain data size + request size
                         //buffer isn't need reallocate, but switch
                         else {
                                 //pointer valid check
@@ -4997,7 +5193,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                         if (recv_data.receive_buffer_max_size < data_remain_size + recvlen) {
                                 //the buffer's size that will be allocated is exceed the upper limit value
                                 if (MAX_SESSIONLESS_MODULE_BUFFER_SIZE < data_remain_size + recvlen) {
-                                        std::cerr << "protocol_module_sessionless::handle_sorryserver_recv() : the buffer's size that will be allacted is exceed the upper limit value." << std::endl;
+                                        std::cerr << "protocol_module_sessionless::handle_sorryserver_recv() : the buffer's size that will be allocated is exceed the upper limit value." << std::endl;
                                         boost::format formatter("The buffer's size that will be allocated is exceed the upper limit value. thread id : %d.");
                                         formatter % boost::this_thread::get_id();
                                         putLogError(100094, formatter.str(), __FILE__, __LINE__);
@@ -5122,7 +5318,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                 //set new buffer's max size
                                 recv_data.receive_buffer_max_size = buffer_size;
                         }
-                        //buffer's max size >= remain data size + requst size
+                        //buffer's max size >= remain data size + request size
                         //buffer isn't need reallocate, but switch
                         else {
                                 //pointer valid check
@@ -5192,7 +5388,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                                 }
                                 //using buffer is buffer2
                                 else {
-                                        //buffer1 initializtion
+                                        //buffer1 initialization
                                         memset(recv_data.receive_buffer1, 0, recv_data.receive_buffer_max_size);
                                         /*-------- DEBUG LOG --------*/
                                         if (unlikely(LOG_LV_DEBUG == getloglevel())) {
@@ -5517,7 +5713,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                         //add new status to status_list
                         recv_data.send_status_list.push_back(new_send_state);
                         std::list<send_status>::reverse_iterator new_send_it = recv_data.send_status_list.rbegin();
-                        //cacl offset
+                        //calc offset
                         new_send_it->send_offset = recv_data.receive_buffer_max_size - recv_data.receive_buffer_rest_size
                                                    - request_data_remain_size;
 
@@ -5750,7 +5946,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
         return status;
 }
 
-//! called from UPSTEEARM thread. make module original message.
+//! called from UPSTREAM thread. make module original message.
 //! @param[in]    downstream thread id.
 //! @return     session use EVENT mode
 protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_response_send_inform(
@@ -5770,7 +5966,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_response_sen
 
 //! called from after client connection check. use TCP/IP only. create client send message.
 //! @param[in]    downstream thread id
-//! @param[out]    send budffer reference
+//! @param[out]    send buffer reference
 //! @param[out]    send data length
 //! @return     session use EVENT mode
 protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_connection_check(
@@ -5861,7 +6057,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_conne
                         /*------DEBUG LOG END------*/
                         //send_end_size recalc
                         it->send_end_size = it->send_possible_size;
-                        //set copyed data length
+                        //set copied data length
                         datalen = it->send_possible_size;
                         //sending_possible size recalc
                         it->send_possible_size = 0;
@@ -5900,7 +6096,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_conne
                         it->send_end_size = send_buffer_size;
                         //sending_possible size recalc
                         it->send_possible_size -= send_buffer_size;
-                        //set copyed data length
+                        //set copied data length
                         datalen = send_buffer_size;
                 }
 
@@ -6045,12 +6241,12 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_client_send(
                 }
                 //sending possible data is not exist
                 else {
-                        //can receive from clent continue
+                        //can receive from client continue
                         if (it->send_rest_size > 0) {
                                 //change status from SEND_OK to SEND_CONTINUE
                                 it->status = SEND_CONTINUE;
                         }
-                        //can not receive from clent continue
+                        //can not receive from client continue
                         else {
                                 //change status from SEND_OK to SEND_END
                                 it->status = SEND_END;
@@ -6322,7 +6518,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorry_enable
                                         }
                                         /*------DEBUG LOG END------*/
 
-                                        //sending ng data is exist or send_rest_size > 0
+                                        //sending NG data is exist or send_rest_size > 0
                                         if (send_disable) {
                                                 //set end flag on
                                                 session_data->end_flag = END_FLAG_ON;
@@ -6457,7 +6653,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorry_disabl
                                 send_possible = true;
                         }
 
-                        //sending ng data is exist or send_rest_size > 0
+                        //sending NG data is exist or send_rest_size > 0
                         it = find_if(recv_data.send_status_list.begin(), recv_data.send_status_list.end(), data_send_disable());
                         if (it != recv_data.send_status_list.end()) {
                                 send_disable = true;
@@ -6562,7 +6758,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorry_disabl
                                                 putLogDebug(100244, formatter.str(), __FILE__, __LINE__);
                                         }
                                         /*------DEBUG LOG END------*/
-                                        //sending ng data is exist or send_rest_size > 0
+                                        //sending NG data is exist or send_rest_size > 0
                                         if (send_disable) {
                                                 //set end flag on
                                                 session_data->end_flag = END_FLAG_ON;
@@ -6817,7 +7013,7 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_realserver_d
         return status;
 }
 
-//! call from sorry server disconnect. use upstraem thread and downstream thread
+//! call from sorry server disconnect. use upstream thread and downstream thread
 //! @param[in]    upstream and downstream thread id( check! one thread one event )
 //! @param[in]    disconnect sorryserver endpoint
 //! @return        session use EVENT mode
@@ -6861,8 +7057,8 @@ protocol_module_base::EVENT_TAG protocol_module_sessionless::handle_sorryserver_
                            : session_data->target_endpoint;
                 receive_data_map_it receive_data_it = session_data->receive_data_map.find(endpoint);
                 if (unlikely(receive_data_it == session_data->receive_data_map.end())) {
-                        boost::format formatter("Invalid endpoint. thread id : %d.");
-                        formatter % boost::this_thread::get_id();
+                        boost::format formatter("Invalid endpoint(%s). thread id: %d.");
+                        formatter % endpoint % boost::this_thread::get_id();
                         putLogError(100125, formatter.str(), __FILE__, __LINE__);
                         throw - 1;
                 }