virtual void down_thread_sorryserver_async_read_some_handler(const boost::system::error_code &error_code, std::size_t len);
virtual void down_thread_sorryserver_handle_async_read_some(const TCP_PROCESS_TYPE_TAG);
virtual void up_thread_client_ssl_socket_clear_socket_handler();
+ virtual void up_thread_client_disconnect_handler(const boost::system::error_code &error_code);
//! down thread receive from realserver and raise module event of handle_realserver_recv
//! @param[in] process_type is process type
public:
// typedef
typedef boost::function< void (const boost::system::error_code &) > async_handshake_handler_t;
+ typedef boost::function< void (const boost::system::error_code &) > async_shutdown_handler_t;
// constructor
tcp_ssl_socket(
return error_code ? false : true;
}
+ virtual void async_shutdown(async_handshake_handler_t handler) {
+ boost::mutex::scoped_lock lock(ssl_mutex);
+ boost::system::error_code error_code;
+ shutdown_con++;
+ my_socket->lowest_layer().cancel(error_code);
+ my_socket->async_shutdown(ssl_strand.wrap(handler));
+ }
+
virtual std::size_t read_some(const boost::asio::mutable_buffers_1 &buffers, boost::system::error_code &error_code) {
boost::mutex::scoped_lock lock(ssl_mutex);
if (write_con > 0 || handshake_con > 0) {
return write_con;
}
+ void decrement_shutdown_con() {
+ boost::mutex::scoped_lock lock(ssl_mutex);
+ shutdown_con--;
+ ssl_cond.notify_one();
+ }
+
+ int get_shutdown_con() {
+ return shutdown_con;
+ }
+
void wait_async_event_all_end() {
boost::mutex::scoped_lock lock(ssl_mutex);
- while (handshake_con > 0 || read_con > 0 || write_con > 0) {
+ while (handshake_con > 0 || read_con > 0 || write_con > 0 || shutdown_con > 0) {
boost::format fmt("handshake_con : %d read_con = %d write_con = %d ");
fmt % handshake_con % read_con % write_con ;
Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
int handshake_con;
int read_con;
int write_con;
+ int shutdown_con;
virtual void set_quickack(boost::system::error_code &error_code) {
int err = ::setsockopt(my_socket->lowest_layer().native(), IPPROTO_TCP, TCP_QUICKACK, &opt_info.quickack_val, sizeof(opt_info.quickack_val));
fmt % boost::this_thread::get_id() % ec.message();
Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
#endif
- func_tag = UP_FUNC_CLIENT_DISCONNECT;
+ upthread_status = UPTHREAD_LOCK;
+ tcp_ssl_socket::async_shutdown_handler_t handler;
+ handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
+ client_ssl_socket.async_shutdown(handler);
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+ return;
} else if (ec == boost::asio::error::eof) {
#ifdef DEBUG
boost::format fmt("Thread ID[%d] ssl_shutdown fail: %s");
downthread_status_cond.notify_one();
}
+void tcp_session::up_thread_client_disconnect_handler(const boost::system::error_code &error_code)
+{
+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+ boost::format fmt("Thread ID[%d] FUNC IN up_thread_client_disconnect_handler");
+ fmt % boost::this_thread::get_id();
+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
+ }
+
+ client_ssl_socket.decrement_shutdown_con();
+
+ tcp_thread_message *up_msg = new tcp_thread_message();
+ if (error_code == boost::asio::error::try_again) {
+ tcp_ssl_socket::async_shutdown_handler_t handler;
+ handler = boost::bind(&tcp_session::up_thread_client_disconnect_handler, this, boost::asio::placeholders::error);
+ client_ssl_socket.async_shutdown(handler);
+ up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+ return;
+ } else {
+ up_msg->message = up_que_function_map[UP_FUNC_CLIENT_DISCONNECT_EVENT];
+ while (!up_thread_message_que.push(up_msg)) {}
+ }
+
+ upthread_status_cond.notify_one();
+
+ if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {
+ boost::format fmt("Thread ID[%d] FUNC OUT up_thread_client_disconnect_handler");
+ fmt % boost::this_thread::get_id() ;
+ Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, fmt.str(), __FILE__, __LINE__);
+ }
+}
+
void tcp_session::up_thread_client_ssl_socket_clear_socket_handler()
{
if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) {