tcp_schedule_func_type;
typedef l7vs::atomic<unsigned long long> AUUL;
+ //typedef l7vs::atomic<unsigned int> AUI;
+
//! @struct replication_header replication header structure
struct replication_header{
AUUL wait_count_up; //! upstream recv wait count
AUUL wait_count_down; //! downstream recv wait count
+ AUUL ir_running;
+ AUUL stop_flag;
+
// protocol module option string
std::string protocol_module_for_indication_options;
explicit virtualservice_base( const l7vsd&,
const replication&,
const virtualservice_element& );
- virtual ~virtualservice_base(){};
+ virtual ~virtualservice_base(){ dispatcher.reset();dispatcher.stop(); };
virtual void initialize( error_code& ) = 0;
virtual void finalize( error_code& ) = 0;
wait_count_up = 0;
wait_count_down = 0;
+ ir_running = 0;
+ stop_flag = 0;
+
calc_bps_timer.reset( new boost::asio::deadline_timer( dispatcher ) );
replication_timer.reset( new boost::asio::deadline_timer( dispatcher ) );
protomod_rep_timer.reset( new boost::asio::deadline_timer( dispatcher ) );
}
if( likely( !err ) ){
if( likely( NULL != protomod ) ){
+
+ ir_running++;
+
protomod->replication_interrupt();
+ if(0!=stop_flag.get()){
//register handle_protomod_replication
protomod_rep_timer->expires_from_now( boost::posix_time::milliseconds( param_data.rep_interval ) );
protomod_rep_timer->async_wait( boost::bind( &l7vs::virtualservice_tcp::handle_protomod_replication,
this, boost::asio::placeholders::error ) );
+ }
+ ir_running--;
+
}else{
l7vs::Logger::putLogError( l7vs::LOG_CAT_L7VSD_VIRTUALSERVICE_THREAD, 1, PROTOMOD_NOTLOAD_ERROR_MSG, __FILE__, __LINE__ );
}
}
if( likely( !err ) ){
if( likely( NULL != schedmod ) ){
+
+ //si_runnig
+ ir_running++;
+
+ if(0!=stop_flag.get()){
schedmod->replication_interrupt();
//register handle_schedmod_replication
schedmod_rep_timer->expires_from_now( boost::posix_time::milliseconds( param_data.rep_interval ) );
schedmod_rep_timer->async_wait( boost::bind( &l7vs::virtualservice_tcp::handle_schedmod_replication,
this, boost::asio::placeholders::error ) );
+
+ }
+ ir_running--;
+
}else{
l7vs::Logger::putLogError( l7vs::LOG_CAT_L7VSD_VIRTUALSERVICE_THREAD, 3, SCHEDMOD_NOTLOAD_ERROR_MSG, __FILE__, __LINE__ );
}
}
//register timer event
+ if(0!=stop_flag.get()){
calc_bps_timer->expires_from_now( boost::posix_time::milliseconds( param_data.bps_interval ) );
calc_bps_timer->async_wait( boost::bind( &l7vs::virtualservice_tcp::handle_throughput_update,
this, boost::asio::placeholders::error ) );
+ }
if( unlikely( LOG_LV_DEBUG == l7vs::Logger::getLogLevel( l7vs::LOG_CAT_L7VSD_VIRTUALSERVICE_THREAD ) ) ){
boost::format formatter1("throughput(upstream) dump : %d, wait_count_up dump : %d");
formatter1 % throughput_up.get() % wait_count_up.get();
rep_noconst.unlock( REP_AREA_NAME );
//register handle_replication_interrupt
+
+ if(0!=stop_flag.get()){
replication_timer->expires_from_now( boost::posix_time::milliseconds( param_data.rep_interval ) );
replication_timer->async_wait( boost::bind( &virtualservice_tcp::handle_replication_interrupt,
this, boost::asio::placeholders::error ) );
+ }
if( unlikely( LOG_LV_DEBUG == Logger::getLogLevel( LOG_CAT_L7VSD_VIRTUALSERVICE ) ) ){
Logger::putLogDebug( LOG_CAT_L7VSD_VIRTUALSERVICE, 21, "out_function : void virtualservice_tcp::handle_replication_interrupt( const boost::system::error_code& err )", __FILE__, __LINE__ );
}
return;
}
+ catch( ... ){
+ Logger::putLogFatal(
+ LOG_CAT_L7VSD_VIRTUALSERVICE, 999, "unknown error, create session.", __FILE__, __LINE__ );
+ if( unlikely( LOG_LV_DEBUG == Logger::getLogLevel( LOG_CAT_L7VSD_VIRTUALSERVICE ) ) ){
+ Logger::putLogDebug( LOG_CAT_L7VSD_VIRTUALSERVICE, 999, "out_function : void virtualservice_tcp::initialize( l7vs::error_code& err ) : unknown error.", __FILE__, __LINE__ );
+ }
+ return;
+ }
}
if( unlikely( LOG_LV_DEBUG == Logger::getLogLevel( LOG_CAT_L7VSD_VIRTUALSERVICE ) ) ){
boost::format fmt1( "pool_session.size = %d" );
}
//stop main loop
- stop();
+ //stop();
while(active_sessions.size()){
boost::this_thread::yield();
}
}
- vsd.release_virtual_service( element );
+ //vsd.release_virtual_service( element );
if( access_log_file_name != "" ) {
// erase access log instance.
__FILE__, __LINE__ );
}
}
+
+ vsd.release_virtual_service( element );
err.setter( false, "" );
boost::system::error_code err;
+ stop_flag++;
+
+ while(ir_running.get()){
+ boost::this_thread::yield();
+ }
+
acceptor_.close( err );
if( err ){
Logger::putLogError( LOG_CAT_L7VSD_VIRTUALSERVICE, 18, err.message(), __FILE__, __LINE__ );
}
//stop dispatcher
+
+ size_t ret1 = calc_bps_timer->cancel();
+ size_t ret2 = replication_timer->cancel();
+ size_t ret3 = protomod_rep_timer->cancel();
+ size_t ret4 = schedmod_rep_timer->cancel();
+
+ Logger::putLogError( LOG_CAT_L7VSD_VIRTUALSERVICE, 18, (boost::format("ret1=%d,ret2=%d,ret3=%d,ret4=%d") % ret1 % ret2 % ret3 % ret4).str(), __FILE__, __LINE__ );
+ dispatcher.reset();
dispatcher.stop();
}