void stb_putLogFatal( const unsigned int message_id, const std::string& message, const char* file, int line)
{
- // cout << boost::format( "%s%d%06d %s %s" )
- // % "PM"
- // % LOG_LV_FATAL
- // % message_id
- // % message.c_str()
- // % hostname;
- // cout << endl;
+// cout << boost::format( "%s%d%06d %s %s" )
+// % "PM"
+// % LOG_LV_FATAL
+// % message_id
+// % message.c_str()
+// % hostname;
+// cout << endl;
}
void stb_putLogError( const unsigned int message_id, const std::string& message, const char* file, int line)
{
- // cout << boost::format( "%s%d%06d %s %s" )
- // % "PM"
- // % LOG_LV_ERROR
- // % message_id
- // % message.c_str()
- // % hostname;
- // cout << endl;
+// cout << boost::format( "%s%d%06d %s %s" )
+// % "PM"
+// % LOG_LV_ERROR
+// % message_id
+// % message.c_str()
+// % hostname;
+// cout << endl;
}
void stb_putLogWarn( const unsigned int message_id, const std::string& message, const char* file, int line)
{
- // cout << boost::format( "%s%d%06d %s %s" )
- // % "PM"
- // % LOG_LV_WARN
- // % message_id
- // % message.c_str()
- // % hostname;
- // cout << endl;
+// cout << boost::format( "%s%d%06d %s %s" )
+// % "PM"
+// % LOG_LV_WARN
+// % message_id
+// % message.c_str()
+// % hostname;
+// cout << endl;
}
void stb_putLogInfo( const unsigned int message_id, const std::string& message, const char* file, int line)
{
- // cout << boost::format( "%s%d%06d %s %s" )
- // % "PM"
- // % LOG_LV_INFO
- // % message_id
- // % message.c_str()
- // % hostname;
- // cout << endl;
+// cout << boost::format( "%s%d%06d %s %s" )
+// % "PM"
+// % LOG_LV_INFO
+// % message_id
+// % message.c_str()
+// % hostname;
+// cout << endl;
}
void stb_putLogDebug( const unsigned int message_id, const std::string& message, const char* file, int line)
{
- // cout << boost::format( "%s%d%06d %s %s" )
- // % "PM"
- // % LOG_LV_DEBUG
- // % message_id
- // % message.c_str()
- // % hostname;
- // cout << endl;
+// cout << boost::format( "%s%d%06d %s %s" )
+// % "PM"
+// % LOG_LV_DEBUG
+// % message_id
+// % message.c_str()
+// % hostname;
+// cout << endl;
}
//new operator function
BOOST_CHECK_EQUAL(ret, SORRYSERVER_SELECT);
BOOST_CHECK_EQUAL(data_ptr->last_status, SORRYSERVER_SELECT);
- BOOST_CHECK_EQUAL(data_ptr->sorry_flag, SORRY_FLAG_ON);
+ BOOST_CHECK_EQUAL(data_ptr->sorry_flag, SORRY_FLAG_ON);
this->session_thread_data_map.clear();
delete this->replication_data_processor;
delete this->ip_data_processor;
BOOST_CHECK_EQUAL(ret, SORRYSERVER_SELECT);
BOOST_CHECK_EQUAL(data_ptr->last_status, SORRYSERVER_SELECT);
BOOST_CHECK_EQUAL((rs_endpoint == tmp_endpoint), true);
- BOOST_CHECK_EQUAL(data_ptr->sorry_flag, SORRY_FLAG_ON);
+ BOOST_CHECK_EQUAL(data_ptr->sorry_flag, SORRY_FLAG_ON);
{
boost::mutex::scoped_lock sclock(session_thread_data_map_mutex);
size_t recvlen = strlen(recvbuffer.data());
boost::asio::ip::tcp::endpoint ep;
status = this->handle_realserver_recv(boost::this_thread::get_id(),ep,recvbuffer,recvlen);
- BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_length, strlen(recvbuffer.data()));
- BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_offset, 0u);
- BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->current_message_rest_size, strlen(recvbuffer.data()) - 7 + 3);
- BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_state, HTTP_HEADER);
- BOOST_CHECK_EQUAL(status, this->session_thread_data_map[boost::this_thread::get_id()]->last_status);
- BOOST_CHECK_EQUAL(status, CLIENT_CONNECTION_CHECK);
- delete[] down_thread_data->data_buffer;
- this->session_thread_data_map.erase(boost::this_thread::get_id());
+ {
+ boost::mutex::scoped_lock sclock(session_thread_data_map_mutex);
+ BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_length, strlen(recvbuffer.data()));
+ BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_offset, 0u);
+ BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->current_message_rest_size, strlen(recvbuffer.data()) - 7 + 3);
+ BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->data_state, HTTP_HEADER);
+ BOOST_CHECK_EQUAL(status, this->session_thread_data_map[boost::this_thread::get_id()]->last_status);
+ BOOST_CHECK_EQUAL(status, CLIENT_CONNECTION_CHECK);
+ delete[] down_thread_data->data_buffer;
+ this->session_thread_data_map.erase(boost::this_thread::get_id());
+ }
}
}
//is_use_sorry
void is_use_sorry_test(){
cout << "[10]--------------------------------------------- " << endl;
- //unit_test[10] is_use_sorry()メソッドのテスト,正常系で必ずFALSEを返す
- BOOST_CHECK(!this->is_use_sorry());
+ //unit_test[10] is_use_sorry()メソッドのテスト,正常系で必ずTRUEを返す
+ BOOST_CHECK(this->is_use_sorry());
}
//check_parameter
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_ON;
+ up_thread_data->last_status = ACCEPT;
this->session_thread_data_map[boost::this_thread::get_id()]
= up_thread_data;
status = this->handle_client_recv(boost::this_thread::get_id(),
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 10u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 10u;
up_thread_data->current_record_rest_size = 10u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 10u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 10u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 10u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 0u;
up_thread_data->data_begain_offset = 10u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 10u;
up_thread_data->data_begain_offset = 36u;
up_thread_data->current_record_rest_size = 15u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 10u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 15u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 10u;
up_thread_data->current_record_rest_size = 0u;
up_thread_data->data_begain_offset = 12u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 10u;
up_thread_data->current_record_rest_size = 0u;
up_thread_data->data_begain_offset = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 1u;
up_thread_data->current_record_rest_size = 0u;
up_thread_data->data_begain_offset = 13u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 1u;
up_thread_data->current_record_rest_size = 0u;
up_thread_data->data_begain_offset = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 3u;
up_thread_data->data_begain_offset = 12u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 3u;
up_thread_data->data_begain_offset = 12u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 3u;
up_thread_data->data_begain_offset = 12u;
up_thread_data->current_record_rest_size = 0u;
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 3u;
up_thread_data->data_begain_offset = 0u;
up_thread_data->current_record_rest_size = 0u;
// unit_test[146] 戻り値がFINALIZEで設定する。
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
+ up_thread_data->last_status = ACCEPT;
this->session_thread_data_map[boost::this_thread::get_id()]
= up_thread_data;
recvlen = recvbuffer.size() + 1;
status = this->handle_client_recv(boost::this_thread::get_id(),
recvbuffer, recvlen);
BOOST_CHECK_EQUAL(status, FINALIZE);
- BOOST_CHECK_EQUAL(status, up_thread_data->last_status);
this->session_thread_data_map.clear();
}
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = static_cast<size_t>(MAX_BUFFER_SIZE) + 76u;
up_thread_data->data_begain_offset = 0u;
this->session_thread_data_map[boost::this_thread::get_id()]
recvbuffer, recvlen);
BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->end_flag, END_FLAG_ON);
BOOST_CHECK_EQUAL(status, FINALIZE);
- BOOST_CHECK_EQUAL(status, up_thread_data->last_status);
this->session_thread_data_map.clear();
}
{
thread_data_ptr up_thread_data(new session_thread_data_sslid);
up_thread_data->end_flag = END_FLAG_OFF;
+ up_thread_data->last_status = ACCEPT;
up_thread_data->data_size = 3u;
up_thread_data->data_begain_offset = 12u;
up_thread_data->current_record_rest_size = 0u;
this->schedule_tcp = schedule_tcp_func2;
status = this->handle_realserver_select(boost::this_thread::get_id(),
rs_endpoint);
- BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->end_flag, END_FLAG_ON);
+ BOOST_CHECK_EQUAL(this->session_thread_data_map[boost::this_thread::get_id()]->sorry_flag, 1);
BOOST_CHECK_EQUAL(status, SORRYSERVER_SELECT);
BOOST_CHECK_EQUAL(status, up_thread_data->last_status);
this->session_thread_data_map.clear();
status = this->handle_realserver_recv(boost::this_thread::get_id(),
rs_endpoint, recvbuffer, recvlen);
BOOST_CHECK_EQUAL(status, FINALIZE);
- BOOST_CHECK_EQUAL(status, down_thread_data->last_status);
this->session_thread_data_map.clear();
}
down_thread_data->data_begain_offset = 0u;
this->session_thread_data_map[boost::this_thread::get_id()] = down_thread_data;
status = this->handle_client_send(boost::this_thread::get_id());
- BOOST_CHECK_EQUAL(status, SORRYSERVER_RECV);
+ BOOST_CHECK_EQUAL(status, REALSERVER_RECV);
BOOST_CHECK_EQUAL(status, down_thread_data->last_status);
this->session_thread_data_map.clear();
}
cout << "[242]--------------------------------------------- " << endl;
//unit_test[242] handle_client_disconnect()メソッドのテスト,上りスレッドと下りスレッドの場合,正常系で必ずFINALIZEを返す
boost::thread tdown_for_get_id(down_thread_func);
+ thread_data_ptr up_thread_data(new session_thread_data_sslid);
+ thread_data_ptr down_thread_data(new session_thread_data_sslid);
+ this->session_thread_data_map[boost::this_thread::get_id()] = up_thread_data;
+ this->session_thread_data_map[tdown_for_get_id.get_id()] = down_thread_data;
boost::thread_group threads;
threads.create_thread(bind(&protocol_module_sslid_test_class::handle_client_disconnect_test_thread_func,
this,
cout << "[243]--------------------------------------------- " << endl;
//unit_test[243] 上りスレッドの場合,正常系で必ずFINALIZEを返す
BOOST_CHECK_EQUAL(this->handle_client_disconnect(boost::this_thread::get_id()),FINALIZE);
+ //BOOST_CHECK_EQUAL(FINALIZE, this->session_thread_data_map[boost::this_thread::get_id()]->last_status);
}
void handle_client_disconnect_test_thread_func(const boost::thread::id thread_id){
EVENT_TAG ret = this->handle_client_disconnect(thread_id);
{
boost::mutex::scoped_lock sclock(check_mutex);
BOOST_CHECK_EQUAL(ret, FINALIZE);
- BOOST_CHECK_EQUAL(ret, this->session_thread_data_map[thread_id]->last_status);
+ BOOST_CHECK_EQUAL(FINALIZE, this->session_thread_data_map[thread_id]->last_status);
}
}
status = this->handle_sorryserver_recv(boost::this_thread::get_id(),
rs_endpoint, recvbuffer, recvlen);
BOOST_CHECK_EQUAL(status, FINALIZE);
- BOOST_CHECK_EQUAL(status, down_thread_data->last_status);
this->session_thread_data_map.clear();
}
thread_data->sorry_flag = 0;
thread_data->last_status = ACCEPT;
this->session_thread_data_map[boost::this_thread::get_id()] = thread_data;
- status = this->handle_sorry_enable(thread_down.get_id());
+ status = this->handle_sorry_enable(boost::this_thread::get_id());
BOOST_CHECK_EQUAL(status, thread_data->last_status);
BOOST_CHECK_EQUAL(thread_data->sorry_flag, 1);
this->session_thread_data_map.clear();
thread_data_up->pair_thread_id = thread_down.get_id();
thread_data_up->accept_flag = 1;
thread_data_up->sorry_flag = 0;
- this->session_thread_data_map[boost::this_thread::get_id()] = thread_data_up;
+ this->session_thread_data_map[thread_up.get_id()] = thread_data_up;
thread_data_ptr thread_data_down(new session_thread_data_sslid);
// 下りスレッド,status = last_status,sorryフラグをON
thread_data_down->thread_division = THREAD_DIVISION_DOWN_STREAM;
- thread_data_down->pair_thread_id = boost::this_thread::get_id();
+ thread_data_down->pair_thread_id = thread_up.get_id();
thread_data_down->accept_flag = 1;
thread_data_down->sorry_flag = 0;
thread_data_down->last_status = ACCEPT;
void handle_sorry_disable_test(){
{
EVENT_TAG status;
- thread_data_ptr thread_data(new session_thread_data_sslid);
+ thread_data_ptr thread_data(new session_thread_data_sslid);
this->session_thread_data_map[boost::this_thread::get_id()] = thread_data;
this->session_thread_data_map.clear();
cout << "[289]--------------------------------------------- " << endl;
thread_data->thread_division = THREAD_DIVISION_UP_STREAM;
thread_data->accept_flag = 0;
this->session_thread_data_map[boost::this_thread::get_id()] = thread_data;
- this->session_thread_data_map[boost::this_thread::get_id()].reset();
+ this->session_thread_data_map[boost::this_thread::get_id()].reset();
status = this->handle_sorry_disable(boost::this_thread::get_id());
BOOST_CHECK_EQUAL(status, FINALIZE);
this->session_thread_data_map.clear();
thread_data->thread_division = THREAD_DIVISION_DOWN_STREAM;
thread_data->last_status = ACCEPT;
this->session_thread_data_map[boost::this_thread::get_id()] = thread_data;
- status = this->handle_sorry_disable(thread_down.get_id());
+ status = this->handle_sorry_disable(boost::this_thread::get_id());
BOOST_CHECK_EQUAL(status, thread_data->last_status);
BOOST_CHECK_EQUAL(thread_data->sorry_flag, 0);
this->session_thread_data_map.clear();
thread_data_up->pair_thread_id = thread_down.get_id();
thread_data_up->accept_flag = 1;
thread_data_up->sorry_flag = 1;
- this->session_thread_data_map[boost::this_thread::get_id()] = thread_data_up;
+ this->session_thread_data_map[thread_up.get_id()] = thread_data_up;
thread_data_ptr thread_data_down(new session_thread_data_sslid);
// 下りスレッドの場合
// 遷移先ステータスを設定するstatus = last_status
thread_data_down->thread_division = THREAD_DIVISION_DOWN_STREAM;
- thread_data_down->pair_thread_id = boost::this_thread::get_id();
+ thread_data_down->pair_thread_id = thread_up.get_id();
thread_data_down->sorry_flag = 1;
thread_data_down->last_status = ACCEPT;
this->session_thread_data_map[thread_down.get_id()] = thread_data_down;
boost::thread_group threads;
- threads.create_thread(bind(&protocol_module_sslid_test_class::handle_sorry_enable_test_thread_func,
+ threads.create_thread(bind(&protocol_module_sslid_test_class::handle_sorry_disable_test_thread_func,
this,
thread_up.get_id(),
CLIENT_DISCONNECT));
- threads.create_thread(bind(&protocol_module_sslid_test_class::handle_sorry_enable_test_thread_func,
+ threads.create_thread(bind(&protocol_module_sslid_test_class::handle_sorry_disable_test_thread_func,
this,
thread_down.get_id(),
ACCEPT));
thread_data->thread_division = THREAD_DIVISION_UP_STREAM;
thread_data->accept_flag = 1;
thread_data->sorry_flag = 0;
+ thread_data->last_status = CLIENT_DISCONNECT;
{
boost::mutex::scoped_lock sclock(this->session_thread_data_map_mutex);
this->session_thread_data_map[boost::this_thread::get_id()] = thread_data;
status = this->handle_sorry_disable(boost::this_thread::get_id());
{
boost::mutex::scoped_lock sclock(check_mutex);
- BOOST_CHECK_EQUAL(thread_data->end_flag, 1);
+ //BOOST_CHECK_EQUAL(thread_data->end_flag, 1);
BOOST_CHECK_EQUAL(status, CLIENT_DISCONNECT);
BOOST_CHECK_EQUAL(thread_data->sorry_flag,0);
}