修訂 | 79dda64a2127ae3175220e3e0718c1db2ae08a78 (tree) |
---|---|
時間 | 2013-06-10 14:17:31 |
作者 | Hiroaki Nakano <nakano.hiroaki@nttc...> |
Commiter | Hiroaki Nakano |
Merge branch 'for_gcc4.7' into v3.1.0-devel
@@ -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 |
@@ -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 |
@@ -2994,9 +2994,8 @@ bool l7vs::l7vsadm::execute(int argc, char *argv[]) | ||
2994 | 2994 | |
2995 | 2995 | // Get l7vsadm execute file path from /proc/(pid)/exe (symbolic link) |
2996 | 2996 | char l7vsadm_file_path[256]; |
2997 | - ssize_t retsize; | |
2998 | 2997 | memset(l7vsadm_file_path, 0, sizeof(l7vsadm_file_path)); |
2999 | - retsize = readlink("/proc/self/exe", l7vsadm_file_path, sizeof(l7vsadm_file_path)); | |
2998 | + readlink("/proc/self/exe", l7vsadm_file_path, sizeof(l7vsadm_file_path)); | |
3000 | 2999 | |
3001 | 3000 | // L7vsadm command conflict check. (Try l7vsadm execute file lock) |
3002 | 3001 | file_lock lock(l7vsadm_file_path, l7vsadm_err); |
@@ -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; |
@@ -33,18 +33,18 @@ namespace l7vs | ||
33 | 33 | // |
34 | 34 | //! @brief create up down thread |
35 | 35 | // |
36 | -void session_thread_control::start_thread() | |
36 | +int session_thread_control::start_thread() | |
37 | 37 | { |
38 | 38 | |
39 | - int int_val; | |
40 | - | |
41 | 39 | upthread.reset(new boost::thread(&session_thread_control::upstream_run, this)); //! upstream thread create |
42 | 40 | downthread.reset(new boost::thread(&session_thread_control::downstream_run, this)); //! downstream thread create |
43 | 41 | |
44 | 42 | //pthread_setschedparam |
45 | 43 | int retval, sched_policy; |
46 | 44 | sched_param scheduler_param; |
47 | - int_val = pthread_getschedparam(upthread->native_handle(), &sched_policy, &scheduler_param); | |
45 | + retval = pthread_getschedparam(upthread->native_handle(), &sched_policy, &scheduler_param); | |
46 | + if (retval != 0) return retval; | |
47 | + | |
48 | 48 | if (SCHED_FIFO == sched_algorithm) { |
49 | 49 | scheduler_param.__sched_priority = sched_priority; |
50 | 50 | sched_policy = SCHED_FIFO; |
@@ -56,9 +56,12 @@ void session_thread_control::start_thread() | ||
56 | 56 | } |
57 | 57 | if (0 <= sched_algorithm) { |
58 | 58 | retval = pthread_setschedparam(upthread->native_handle(), sched_algorithm, &scheduler_param); |
59 | + if (retval != 0 ) return retval; | |
59 | 60 | retval = pthread_setschedparam(downthread->native_handle(), sched_algorithm, &scheduler_param); |
61 | + if (retval != 0 ) return retval; | |
60 | 62 | } |
61 | 63 | |
64 | + return retval; | |
62 | 65 | } |
63 | 66 | |
64 | 67 | // |
@@ -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" |
@@ -552,6 +553,8 @@ void l7vs::virtualservice_tcp::handle_accept(const l7vs::session_thread_control | ||
552 | 553 | */ |
553 | 554 | void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) |
554 | 555 | { |
556 | + int ret = 0; | |
557 | + | |
555 | 558 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
556 | 559 | boost::format formatter("in_function: void virtualservice_tcp::initialize( " |
557 | 560 | "l7vs::error_code& err )"); |
@@ -834,7 +837,16 @@ void l7vs::virtualservice_tcp::initialize(l7vs::error_code &err) | ||
834 | 837 | session_thread_control *p_stc = new session_thread_control( |
835 | 838 | sess, vsnic_cpumask, rsnic_cpumask, -1); |
836 | 839 | |
837 | - p_stc->start_thread(); | |
840 | + ret = p_stc->start_thread(); | |
841 | + if (ret == ESRCH) { | |
842 | + continue; | |
843 | + } else if (ret == EPERM) { | |
844 | + //Error | |
845 | + Logger::putLogError(LOG_CAT_L7VSD_VIRTUALSERVICE, 999, "Not super user authority", | |
846 | + __FILE__, __LINE__); | |
847 | + err.setter(true, "set pthread schedule parameter."); | |
848 | + throw; | |
849 | + } | |
838 | 850 | while (!pool_sessions.push(p_stc)) {} |
839 | 851 | } catch (...) { |
840 | 852 | Logger::putLogFatal( |