修訂 | a25ac81183f94e01b6face1db6e06ae210f0df92 (tree) |
---|---|
時間 | 2013-07-05 11:31:00 |
作者 | Hiroaki Nakano <nakano.hiroaki@nttc...> |
Commiter | Hiroaki Nakano |
Merge branch 'v3.1.0-devel' into gettid_for_debug
@@ -1,8 +1,19 @@ | ||
1 | -[Sep. 8 2012] 3.1.0-1 HIBARI Michiro | |
1 | +[Sep. 8 2012] 3.1.0-1 HIBARI Michiro, Hiroaki Nakano | |
2 | 2 | - Add "session_thread_pool_size" option for l7vsadm and l7directord. |
3 | 3 | - Change spec file. Make devel package. |
4 | 4 | - Fixed bug: Evaluated the header section with the body section in HTTP negotiate check. |
5 | 5 | - Add "server_connect_timeout" option at l7vsd.cf. |
6 | + - #30844 Fixed man isn't installed. | |
7 | + - #30845 Fixed config file of log-rotation isn't installed. | |
8 | + - #30846 Add CRM sample file for Pacemaker. | |
9 | + - #30847 Support cross operation on Pacemaker. | |
10 | + - #30993 Fixed compailing error of gcc4.6. | |
11 | + - #31199 Fixed remaining threads when deleted virtual service. | |
12 | + - #31200 Fixed segmantaion fault when deleted virtual service. | |
13 | + - #31545 Fixed bulding error of boost 1.50 upper. | |
14 | + | |
15 | +[Dec. 12 2012] 3.0.4-3 Hiroaki Nakano | |
16 | + - Fixed breaking HTTP header over MAX_BUFFER_SIZE on ip module.(#30300 patch) | |
6 | 17 | |
7 | 18 | [Aug. 30 2012] 3.0.4-2 Hiroaki Nakano |
8 | 19 | - Fixed LogLevel at #29144 patch. |
@@ -39,6 +39,7 @@ case "$1" in | ||
39 | 39 | start) |
40 | 40 | action "Starting l7directord ... " /usr/sbin/l7directord start |
41 | 41 | if [ $? -eq 0 ]; then |
42 | + mkdir -p `dirname $LOCKFILE` | |
42 | 43 | touch $LOCKFILE |
43 | 44 | fi |
44 | 45 | ;; |
@@ -120,7 +120,7 @@ public: | ||
120 | 120 | } |
121 | 121 | |
122 | 122 | //! create up down thread |
123 | - void start_thread(); | |
123 | + int start_thread(); | |
124 | 124 | |
125 | 125 | //! session shared ptr getter |
126 | 126 | //! @return session shared ptr |
@@ -451,6 +451,8 @@ protected: | ||
451 | 451 | session_map_type active_sessions; |
452 | 452 | l7vs::atomic<unsigned long long> |
453 | 453 | active_count; |
454 | + session_thread_control *waiting_stc; | |
455 | + //! session_thread_control waiting accept | |
454 | 456 | |
455 | 457 | bool defer_accept_opt; |
456 | 458 | //! is set option TCP_DEFER_ACCEPT |
@@ -39,6 +39,7 @@ start() { | ||
39 | 39 | else |
40 | 40 | echo "done." |
41 | 41 | pidof $PROG > $PIDFILE |
42 | + mkdir -p `dirname $LOCKFILE` | |
42 | 43 | touch $LOCKFILE |
43 | 44 | fi |
44 | 45 |
@@ -324,7 +324,6 @@ protocol_module_base::check_message_result protocol_module_ip::check_parameter(c | ||
324 | 324 | bool timeout_flag = false; |
325 | 325 | bool reschedule_flag = false; |
326 | 326 | bool no_reschedule_flag = false; |
327 | - bool forward_checked = false; | |
328 | 327 | bool sorryuri_checked = false; |
329 | 328 | bool stats_checked = false; |
330 | 329 |
@@ -447,11 +446,6 @@ protocol_module_base::check_message_result protocol_module_ip::check_parameter(c | ||
447 | 446 | break; |
448 | 447 | } |
449 | 448 | } |
450 | - //option string = "-F" | |
451 | - else if (*it == "-F" || *it == "--forwarded-for") { | |
452 | - //set forward flag ON | |
453 | - forward_checked = true; | |
454 | - } | |
455 | 449 | //option string = "-S" |
456 | 450 | else if (*it == "-S" || *it == "--sorry-uri") { |
457 | 451 | //set sorryURI flag OFF |
@@ -5657,11 +5651,6 @@ bool protocol_module_ip::put_data_into_sendbuffer( | ||
5657 | 5651 | buffer_element.first += sendbuffer_rest_size; |
5658 | 5652 | buffer_element.second -= sendbuffer_rest_size; |
5659 | 5653 | sendbuffer_rest_size = 0; |
5660 | - | |
5661 | - //add remain item | |
5662 | - data_ptr->buffer_sequence.push_back(buffer_element); | |
5663 | - //delete the item | |
5664 | - data_ptr->buffer_sequence.pop_front(); | |
5665 | 5654 | break; |
5666 | 5655 | } |
5667 | 5656 | } |
@@ -93,8 +93,8 @@ protected: | ||
93 | 93 | hash = cl_endpoint.address().to_v4().to_ulong() * GOLDEN_RATIO_PRIME; |
94 | 94 | } else { |
95 | 95 | boost::asio::ip::address_v6::bytes_type v6_bytes = cl_endpoint.address().to_v6().to_bytes(); |
96 | - boost::asio::ip::address_v4::bytes_type v4_bytes = {{v6_bytes[12], v6_bytes[13], v6_bytes[14], v6_bytes[15]}}; | |
97 | - boost::asio::ip::address_v4::address_v4 v4_address = boost::asio::ip::address_v4::address_v4(v4_bytes); | |
96 | + const boost::asio::ip::address_v4::bytes_type v4_bytes = {{v6_bytes[12], v6_bytes[13], v6_bytes[14], v6_bytes[15]}}; | |
97 | + boost::asio::ip::address_v4 v4_address(v4_bytes); | |
98 | 98 | hash = v4_address.to_ulong() * GOLDEN_RATIO_PRIME; |
99 | 99 | |
100 | 100 | } |
@@ -356,7 +356,6 @@ protocol_module_base::check_message_result protocol_module_sessionless::check_pa | ||
356 | 356 | //set check result true |
357 | 357 | check_message_result check_result; |
358 | 358 | check_result.flag = true; |
359 | - bool forward_checked = false; | |
360 | 359 | bool sorryuri_checked = false; |
361 | 360 | bool stats_checked = false; |
362 | 361 |
@@ -405,13 +404,8 @@ protocol_module_base::check_message_result protocol_module_sessionless::check_pa | ||
405 | 404 | vec_str_it it_end = args.end(); |
406 | 405 | //loop option strings |
407 | 406 | for (; it != it_end; ++it) { |
408 | - //option string = "-F" | |
409 | - if (*it == "-F" || *it == "--forwarded-for") { | |
410 | - //set forward flag ON | |
411 | - forward_checked = true; | |
412 | - } | |
413 | 407 | //option string = "-S" |
414 | - else if (*it == "-S" || *it == "--sorry-uri") { | |
408 | + if (*it == "-S" || *it == "--sorry-uri") { | |
415 | 409 | //set sorryURI flag OFF |
416 | 410 | if (!sorryuri_checked) { |
417 | 411 | //next item exist |
@@ -2993,14 +2993,14 @@ bool l7vs::l7vsadm::execute(int argc, char *argv[]) | ||
2993 | 2993 | set_parameter(); |
2994 | 2994 | |
2995 | 2995 | // Get l7vsadm execute file path from /proc/(pid)/exe (symbolic link) |
2996 | + ssize_t ret; | |
2996 | 2997 | char l7vsadm_file_path[256]; |
2997 | - ssize_t retsize; | |
2998 | 2998 | memset(l7vsadm_file_path, 0, sizeof(l7vsadm_file_path)); |
2999 | - retsize = readlink("/proc/self/exe", l7vsadm_file_path, sizeof(l7vsadm_file_path)); | |
2999 | + ret = readlink("/proc/self/exe", l7vsadm_file_path, sizeof(l7vsadm_file_path)); | |
3000 | 3000 | |
3001 | 3001 | // L7vsadm command conflict check. (Try l7vsadm execute file lock) |
3002 | 3002 | file_lock lock(l7vsadm_file_path, l7vsadm_err); |
3003 | - if (l7vsadm_err) { | |
3003 | + if (l7vsadm_err || ret == -1) { | |
3004 | 3004 | std::cerr << "COMMON ERROR: " << l7vsadm_err.get_message() << std::endl; |
3005 | 3005 | Logger::putLogError(LOG_CAT_L7VSADM_COMMON, 2, l7vsadm_err.get_message(), __FILE__, __LINE__); |
3006 | 3006 | return false; |
@@ -3039,7 +3039,12 @@ bool l7vs::l7vsadm::execute(int argc, char *argv[]) | ||
3039 | 3039 | |
3040 | 3040 | // Lock retrying. |
3041 | 3041 | boost::xtime xt; |
3042 | +#if BOOST_VERSION >= 105000 | |
3043 | + xtime_get(&xt, boost::TIME_UTC_); | |
3044 | +#else | |
3042 | 3045 | xtime_get(&xt, boost::TIME_UTC); |
3046 | +#endif | |
3047 | + | |
3043 | 3048 | xt.sec += command_wait_interval; |
3044 | 3049 | boost::thread::sleep(xt); |
3045 | 3050 | } |
@@ -343,9 +343,8 @@ bool l7vs::LoggerImpl::init() | ||
343 | 343 | } |
344 | 344 | |
345 | 345 | // get hostname |
346 | - int ret = 0; | |
347 | 346 | char buff[HOST_NAME_MAX]; |
348 | - ret = gethostname(buff, HOST_NAME_MAX); | |
347 | + gethostname(buff, HOST_NAME_MAX); | |
349 | 348 | hostname = buff; |
350 | 349 | |
351 | 350 | initialized = true; |
@@ -34,18 +34,18 @@ namespace l7vs | ||
34 | 34 | // |
35 | 35 | //! @brief create up down thread |
36 | 36 | // |
37 | -void session_thread_control::start_thread() | |
37 | +int session_thread_control::start_thread() | |
38 | 38 | { |
39 | 39 | |
40 | - int int_val; | |
41 | - | |
42 | 40 | upthread.reset(new boost::thread(&session_thread_control::upstream_run, this)); //! upstream thread create |
43 | 41 | downthread.reset(new boost::thread(&session_thread_control::downstream_run, this)); //! downstream thread create |
44 | 42 | |
45 | 43 | //pthread_setschedparam |
46 | 44 | int retval, sched_policy; |
47 | 45 | sched_param scheduler_param; |
48 | - int_val = pthread_getschedparam(upthread->native_handle(), &sched_policy, &scheduler_param); | |
46 | + retval = pthread_getschedparam(upthread->native_handle(), &sched_policy, &scheduler_param); | |
47 | + if (retval != 0) return retval; | |
48 | + | |
49 | 49 | if (SCHED_FIFO == sched_algorithm) { |
50 | 50 | scheduler_param.__sched_priority = sched_priority; |
51 | 51 | sched_policy = SCHED_FIFO; |
@@ -57,9 +57,12 @@ void session_thread_control::start_thread() | ||
57 | 57 | } |
58 | 58 | if (0 <= sched_algorithm) { |
59 | 59 | retval = pthread_setschedparam(upthread->native_handle(), sched_algorithm, &scheduler_param); |
60 | + if (retval != 0 ) return retval; | |
60 | 61 | retval = pthread_setschedparam(downthread->native_handle(), sched_algorithm, &scheduler_param); |
62 | + if (retval != 0 ) return retval; | |
61 | 63 | } |
62 | 64 | |
65 | + return retval; | |
63 | 66 | } |
64 | 67 | |
65 | 68 | // |
@@ -108,7 +111,12 @@ void session_thread_control::upstream_run() | ||
108 | 111 | if (state == WAIT) { // after create or session end. this thread is pooling mode |
109 | 112 | boost::mutex::scoped_lock lock(upthread_condition_mutex); |
110 | 113 | boost::xtime wait; |
114 | +#if BOOST_VERSION >= 105000 | |
115 | + boost::xtime_get(&wait, boost::TIME_UTC_); | |
116 | +#else | |
111 | 117 | boost::xtime_get(&wait, boost::TIME_UTC); |
118 | +#endif | |
119 | + | |
112 | 120 | wait.sec += 1; |
113 | 121 | upthread_running_mutex.unlock(); |
114 | 122 | upthread_condition.timed_wait(lock, wait); // thread is condition wait( start at notify_all() ) |
@@ -175,7 +183,12 @@ void session_thread_control::downstream_run() | ||
175 | 183 | boost::mutex::scoped_lock lock(downthread_condition_mutex); |
176 | 184 | // downthread_condition.wait( lock ); // thread is condition wait( start at notify_all() ) |
177 | 185 | boost::xtime wait; |
186 | +#if BOOST_VERSION >= 105000 | |
187 | + boost::xtime_get(&wait, boost::TIME_UTC_); | |
188 | +#else | |
178 | 189 | boost::xtime_get(&wait, boost::TIME_UTC); |
190 | +#endif | |
191 | + | |
179 | 192 | wait.sec += 1; |
180 | 193 | downthread_running_mutex.unlock(); |
181 | 194 | downthread_condition.timed_wait(lock, wait); // thread is condition wait( start at notify_all() ) |
@@ -822,7 +822,12 @@ void tcp_session::up_thread_run() | ||
822 | 822 | } //message alive end. |
823 | 823 | if (ssl_flag && up_thread_next_call_function.first == UP_FUNC_CLIENT_ACCEPT_EVENT) { //handshake timeout check |
824 | 824 | boost::xtime now_time; |
825 | +#if BOOST_VERSION >= 105000 | |
826 | + boost::xtime_get(&now_time, boost::TIME_UTC_); | |
827 | +#else | |
825 | 828 | boost::xtime_get(&now_time, boost::TIME_UTC); |
829 | +#endif | |
830 | + | |
826 | 831 | if ((now_time.sec - start_handshake_time.sec) > ssl_handshake_time_out) { // timeout detect. |
827 | 832 | boost::system::error_code error_code; |
828 | 833 | client_ssl_socket.close(error_code); |
@@ -1123,7 +1128,12 @@ void tcp_session::up_thread_client_accept(const TCP_PROCESS_TYPE_TAG process_typ | ||
1123 | 1128 | if (ssl_flag) { |
1124 | 1129 | upthread_status = UPTHREAD_LOCK; |
1125 | 1130 | // try ssl handshake |
1131 | +#if BOOST_VERSION >= 105000 | |
1132 | + boost::xtime_get(&start_handshake_time, boost::TIME_UTC_); | |
1133 | +#else | |
1126 | 1134 | boost::xtime_get(&start_handshake_time, boost::TIME_UTC); |
1135 | +#endif | |
1136 | + | |
1127 | 1137 | client_ssl_socket.setoption(error_code); |
1128 | 1138 | client_ssl_socket.async_handshake(boost::bind(&tcp_session::up_thread_client_handshake_handle, |
1129 | 1139 | this, |
@@ -4192,7 +4202,12 @@ void tcp_session::down_thread_sorryserver_handle_async_read_some(tcp_session::TC | ||
4192 | 4202 | //! milliseconds to boost::xtime converter |
4193 | 4203 | void tcp_session::to_time(int in, boost::xtime &xt) |
4194 | 4204 | { |
4205 | +#if BOOST_VERSION >= 105000 | |
4206 | + boost::xtime_get(&xt, boost::TIME_UTC_); | |
4207 | +#else | |
4195 | 4208 | boost::xtime_get(&xt, boost::TIME_UTC); |
4209 | +#endif | |
4210 | + | |
4196 | 4211 | xt.sec += (in / 1000); |
4197 | 4212 | xt.nsec += (in % 1000) * 1000000; |
4198 | 4213 | if (xt.nsec >= 1000000000) { |
@@ -481,7 +481,7 @@ cpu_set_t l7vs::virtualservice_base::get_cpu_mask(std::string nic_name) | ||
481 | 481 | map< size_t, string > cpu_nic_map; |
482 | 482 | string buff; |
483 | 483 | ifstream ifs("/proc/interrupts"); |
484 | - unsigned int target_interrupt; | |
484 | + //unsigned int target_interrupt; | |
485 | 485 | size_t target_cpuid = 0; |
486 | 486 | cpu_set_t mask; |
487 | 487 | sched_getaffinity(0, sizeof(cpu_set_t), &mask); |
@@ -503,7 +503,8 @@ cpu_set_t l7vs::virtualservice_base::get_cpu_mask(std::string nic_name) | ||
503 | 503 | algorithm::split(split_vec, buff, algorithm::is_any_of(":")); |
504 | 504 | if (!split_vec.size()) return mask; // cannot split interrupt |
505 | 505 | algorithm::trim(split_vec[0]); |
506 | - target_interrupt = lexical_cast<unsigned int>(split_vec[0]); | |
506 | + //target_interrupt = lexical_cast<unsigned int>(split_vec[0]); | |
507 | + lexical_cast<unsigned int>(split_vec[0]); | |
507 | 508 | for (size_t i = 0; i < cpu_nic_map.size(); ++i) { |
508 | 509 | size_t start_position = 4 + (i * 11); |
509 | 510 | size_t end_position = 11; |
@@ -30,6 +30,7 @@ | ||
30 | 30 | #include <boost/format.hpp> |
31 | 31 | #include <sys/socket.h> |
32 | 32 | #include <linux/version.h> |
33 | +#include <pthread.h> | |
33 | 34 | |
34 | 35 | #include "virtualservice.h" |
35 | 36 | #include "logger_enum.h" |
@@ -433,6 +434,7 @@ void l7vs::virtualservice_tcp::handle_accept(const l7vs::session_thread_control | ||
433 | 434 | stc_ptr_noconst->session_access_log_output_mode_change(access_log_flag); |
434 | 435 | |
435 | 436 | active_sessions.insert(tmp_session, stc_ptr_noconst); |
437 | + waiting_stc = NULL; | |
436 | 438 | |
437 | 439 | //check sorry flag and status |
438 | 440 | if (unlikely( |
@@ -503,6 +505,7 @@ void l7vs::virtualservice_tcp::handle_accept(const l7vs::session_thread_control | ||
503 | 505 | boost::mutex::scoped_lock down_wait_lk(stc_ptr_register_accept->get_downthread_mutex()); |
504 | 506 | |
505 | 507 | waiting_session = stc_ptr_register_accept->get_session().get(); |
508 | + waiting_stc = stc_ptr_register_accept; | |
506 | 509 | |
507 | 510 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
508 | 511 | boost::format fmt1("active session thread id = %d"); |
@@ -551,6 +554,8 @@ void l7vs::virtualservice_tcp::handle_accept(const l7vs::session_thread_control | ||
551 | 554 | */ |
552 | 555 | void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) |
553 | 556 | { |
557 | + int ret = 0; | |
558 | + | |
554 | 559 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
555 | 560 | boost::format formatter("in_function: void virtualservice_tcp::initialize( " |
556 | 561 | "l7vs::error_code& err )"); |
@@ -833,7 +838,16 @@ void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) | ||
833 | 838 | session_thread_control *p_stc = new session_thread_control( |
834 | 839 | sess, vsnic_cpumask, rsnic_cpumask, -1); |
835 | 840 | |
836 | - p_stc->start_thread(); | |
841 | + ret = p_stc->start_thread(); | |
842 | + if (ret == ESRCH) { | |
843 | + continue; | |
844 | + } else if (ret == EPERM) { | |
845 | + //Error | |
846 | + Logger::putLogError(LOG_CAT_L7VSD_VIRTUALSERVICE, 999, "Not super user authority", | |
847 | + __FILE__, __LINE__); | |
848 | + err.setter(true, "set pthread schedule parameter."); | |
849 | + throw; | |
850 | + } | |
837 | 851 | while (!pool_sessions.push(p_stc)) {} |
838 | 852 | } catch (...) { |
839 | 853 | Logger::putLogFatal( |
@@ -889,6 +903,7 @@ void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) | ||
889 | 903 | */ |
890 | 904 | void l7vs::virtualservice_tcp::finalize(l7vs::error_code &err) |
891 | 905 | { |
906 | + | |
892 | 907 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
893 | 908 | boost::format formatter("in_function: void virtualservice_tcp::finalize( " |
894 | 909 | "l7vs::error_code& err )"); |
@@ -915,7 +930,7 @@ void l7vs::virtualservice_tcp::finalize(l7vs::error_code &err) | ||
915 | 930 | delete stc; |
916 | 931 | stc = NULL; |
917 | 932 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
918 | - boost::format fmt("join pool session: pool_sessions.size = %d"); | |
933 | + boost::format fmt("join pool session: pool_session.size = %d"); | |
919 | 934 | fmt % pool_sessions.size(); |
920 | 935 | Logger::putLogDebug(LOG_CAT_L7VSD_VIRTUALSERVICE, 55, fmt.str(), |
921 | 936 | __FILE__, __LINE__); |
@@ -925,6 +940,9 @@ void l7vs::virtualservice_tcp::finalize(l7vs::error_code &err) | ||
925 | 940 | delete waiting_session; |
926 | 941 | waiting_session = NULL; |
927 | 942 | |
943 | + //waiting thread delete | |
944 | + waiting_stc->join(); | |
945 | + | |
928 | 946 | //unload ProtocolModule |
929 | 947 | if (protomod) { |
930 | 948 | //finalize ProtocolModule |
@@ -1595,6 +1613,7 @@ void l7vs::virtualservice_tcp::run() | ||
1595 | 1613 | } while (!stc_ptr); |
1596 | 1614 | |
1597 | 1615 | waiting_session = stc_ptr->get_session().get(); |
1616 | + waiting_stc = stc_ptr; | |
1598 | 1617 | |
1599 | 1618 | if (!ssl_virtualservice_mode_flag) { |
1600 | 1619 | acceptor_->async_accept(waiting_session->get_client_socket().get_socket(), |
@@ -1640,11 +1659,6 @@ void l7vs::virtualservice_tcp::run() | ||
1640 | 1659 | |
1641 | 1660 | //join dispatcher_thread_group when virtualservice_tcp::stop() executed. |
1642 | 1661 | dispatcher_thread_group.join_all(); |
1643 | - | |
1644 | - //stop all active sessions | |
1645 | - { | |
1646 | - active_sessions.do_all(boost::bind(&session_thread_control::session_stop, _1)); | |
1647 | - } | |
1648 | 1662 | } |
1649 | 1663 | |
1650 | 1664 | /*! |