Revisão | eb3423115483df4c6344a9f367599a96f48ddbb3 (tree) |
---|---|
Hora | 2010-11-08 21:13:55 |
Autor | 0809216 <0809216@1ed6...> |
Commiter | 0809216 |
l7directord copyright
git-svn-id: http://10.144.169.20/repos/um/branches/l7vsd-3.x-ramiel-epoll-cond@10424 1ed66053-1c2d-0410-8867-f7571e6e31d3
@@ -78,7 +78,7 @@ use Socket6; | ||
78 | 78 | |
79 | 79 | # current version |
80 | 80 | our $VERSION = '3.0.0-0'; |
81 | -our $COPYRIGHT = 'Copyright (C) 2010 NTT COMWARE CORPORATION; | |
81 | +our $COPYRIGHT = 'Copyright (C) 2010 NTT COMWARE CORPORATION'; | |
82 | 82 | |
83 | 83 | # default global config values |
84 | 84 | our %GLOBAL = ( |
@@ -1378,93 +1378,25 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty | ||
1378 | 1378 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - if (unlikely(0 < parent_service.get_wait_upstream())) { | |
1382 | - //----Debug log---------------------------------------------------------------------- | |
1383 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
1384 | - std::stringstream buf; | |
1385 | - buf << "Thread ID[" << boost::this_thread::get_id() << "] "; | |
1386 | - buf << "up_thread_client_receive qos wait active"; | |
1387 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 35, buf.str(), __FILE__, __LINE__); | |
1388 | - } | |
1389 | - //----Debug log---------------------------------------------------------------------- | |
1390 | - return; // try again | |
1391 | - } | |
1392 | - up_thread_data_client_side.initialize(); | |
1393 | - boost::array<char, MAX_BUFFER_SIZE>& data_buff = up_thread_data_client_side.get_data(); | |
1394 | 1381 | boost::system::error_code ec; |
1395 | 1382 | std::size_t recv_size; |
1396 | - UP_THREAD_FUNC_TYPE_TAG func_tag; | |
1397 | - | |
1383 | + UP_THREAD_FUNC_TYPE_TAG func_tag = UP_FUNC_CLIENT_RECEIVE; | |
1398 | 1384 | struct epoll_event event; |
1399 | - event.data.fd = !ssl_flag ? client_socket.get_socket().native() | |
1400 | - : client_ssl_socket.get_socket().lowest_layer().native(); | |
1385 | + int ret_fds; | |
1401 | 1386 | |
1402 | - // epoll wait codes | |
1403 | - if (is_epoll_edge_trigger) { | |
1404 | - event.events = EPOLLIN | EPOLLHUP | EPOLLET; | |
1405 | - } else { | |
1406 | - event.events = EPOLLIN | EPOLLHUP; | |
1407 | - } | |
1408 | - bool add_flag = false; | |
1409 | - if (!up_client_epollfd_registered) { | |
1410 | - if (epoll_ctl(up_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
1411 | - std::stringstream buf; | |
1412 | - buf << "up_thread_client_receive: epoll_ctl EPOLL_CTL_ADD error: "; | |
1413 | - buf << strerror(errno); | |
1414 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1415 | - boost::this_thread::yield(); | |
1416 | - return; | |
1417 | - } | |
1418 | - up_client_epollfd_registered = true; | |
1419 | - add_flag = true; | |
1420 | - } | |
1387 | + up_thread_data_client_side.initialize(); | |
1388 | + boost::array<char, MAX_BUFFER_SIZE>& data_buff = up_thread_data_client_side.get_data(); | |
1421 | 1389 | |
1422 | - if (is_epoll_edge_trigger && (!add_flag)) { | |
1423 | - if (epoll_ctl(up_client_epollfd, EPOLL_CTL_MOD, event.data.fd, &event) < 0) { | |
1424 | - std::stringstream buf; | |
1425 | - buf << "up_thread_client_receive: epoll_ctl EPOLL_CTL_MOD error: "; | |
1426 | - buf << strerror(errno); | |
1427 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1428 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT]; | |
1429 | - return; | |
1430 | - } | |
1431 | - } | |
1432 | - int ret_fds = epoll_wait(up_client_epollfd, up_client_events, EVENT_NUM, epoll_timeout); | |
1433 | - if (ret_fds == 0) { | |
1390 | + if (unlikely(0 < parent_service.get_wait_upstream())) { | |
1434 | 1391 | //----Debug log---------------------------------------------------------------------- |
1435 | 1392 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
1436 | - boost::format formatter("up_thread_client_receive: epoll_wait timeout %d msec"); | |
1437 | - formatter % epoll_timeout; | |
1438 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1393 | + std::stringstream buf; | |
1394 | + buf << "Thread ID[" << boost::this_thread::get_id() << "] "; | |
1395 | + buf << "up_thread_client_receive qos wait active"; | |
1396 | + Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 35, buf.str(), __FILE__, __LINE__); | |
1439 | 1397 | } |
1440 | 1398 | //----Debug log---------------------------------------------------------------------- |
1441 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_RECEIVE]; | |
1442 | - return; | |
1443 | - } else if (ret_fds < 0) { | |
1444 | - boost::format formatter("up_thread_client_receive: epoll_wait error: %s"); | |
1445 | - formatter % strerror(errno); | |
1446 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1447 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT]; | |
1448 | - return; | |
1449 | - } | |
1450 | - | |
1451 | - for (int i = 0; i < ret_fds; ++i) { | |
1452 | - if (up_client_events[i].data.fd == event.data.fd) { | |
1453 | - if (up_client_events[i].events & EPOLLIN) { | |
1454 | - break; | |
1455 | - } | |
1456 | - if (up_client_events[i].events & EPOLLHUP) { | |
1457 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_CLIENT_DISCONNECT]; | |
1458 | - //----Debug log---------------------------------------------------------------------- | |
1459 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
1460 | - boost::format formatter("Thread ID[%d] FUNC OUT up_thread_client_receive EPOLLHUP: NEXT_FUNC[%s]"); | |
1461 | - formatter % boost::this_thread::get_id() % func_tag_to_string(UP_FUNC_CLIENT_DISCONNECT); | |
1462 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1463 | - } | |
1464 | - //----Debug log---------------------------------------------------------------------- | |
1465 | - return; | |
1466 | - } | |
1467 | - } | |
1399 | + goto up_thread_client_receive_out; | |
1468 | 1400 | } |
1469 | 1401 | |
1470 | 1402 | recv_size = !ssl_flag ? client_socket.read_some( |
@@ -1473,14 +1405,10 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty | ||
1473 | 1405 | : client_ssl_socket.read_some( |
1474 | 1406 | boost::asio::buffer(data_buff, MAX_BUFFER_SIZE), |
1475 | 1407 | ec); |
1476 | - | |
1477 | 1408 | if (!ec) { |
1478 | 1409 | if (recv_size > 0) { |
1479 | 1410 | //----Debug log---------------------------------------------------------------------- |
1480 | 1411 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
1481 | - endpoint client_endpoint; // XXX redefined??? | |
1482 | - client_endpoint = !ssl_flag ? client_socket.get_socket().lowest_layer().remote_endpoint(ec) | |
1483 | - : client_ssl_socket.get_socket().lowest_layer().remote_endpoint(ec); | |
1484 | 1412 | boost::format formatter("Thread ID[%d] up_thread_client_receive receive data size[%d] from [%d]"); |
1485 | 1413 | formatter % boost::this_thread::get_id() % recv_size % client_endpoint; |
1486 | 1414 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 36, formatter.str(), __FILE__, __LINE__); |
@@ -1496,20 +1424,70 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty | ||
1496 | 1424 | formatter % boost::this_thread::get_id() % module_event; |
1497 | 1425 | Logger::putLogError(LOG_CAT_L7VSD_SESSION, 20, formatter.str(), __FILE__, __LINE__); |
1498 | 1426 | up_thread_exit(process_type); |
1499 | - return; | |
1427 | + func_tag = UP_FUNC_EXIT; | |
1428 | + } else { | |
1429 | + func_tag = func_type->second; | |
1500 | 1430 | } |
1501 | - func_tag = func_type->second; | |
1502 | - } else { | |
1431 | + } else if (recv_size < 0) { | |
1503 | 1432 | boost::format formatter("Thread ID[%d] client read error. recv_size: %d"); |
1504 | 1433 | formatter % boost::this_thread::get_id() % recv_size; |
1505 | 1434 | Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); |
1506 | - func_tag = UP_FUNC_CLIENT_RECEIVE; | |
1507 | 1435 | } |
1508 | 1436 | } else { |
1509 | - if (ec == boost::asio::error::eof) { | |
1437 | + if (ec == boost::asio::error::try_again) { | |
1438 | + // epoll wait codes | |
1439 | + event.data.fd = !ssl_flag ? client_socket.get_socket().native() | |
1440 | + : client_ssl_socket.get_socket().lowest_layer().native(); | |
1441 | + | |
1442 | + if (!up_client_epollfd_registered) { | |
1443 | + if (is_epoll_edge_trigger) { | |
1444 | + event.events = EPOLLIN | EPOLLHUP | EPOLLET; | |
1445 | + } else { | |
1446 | + event.events = EPOLLIN | EPOLLHUP; | |
1447 | + } | |
1448 | + if ( (!ssl_flag && !client_socket.get_socket().is_open()) || | |
1449 | + (ssl_flag && !client_ssl_socket.get_socket().lowest_layer().is_open()) ) { | |
1450 | + func_tag = UP_FUNC_CLIENT_DISCONNECT; | |
1451 | + goto up_thread_client_receive_out; | |
1452 | + } | |
1453 | + if (epoll_ctl(up_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
1454 | + std::stringstream buf; | |
1455 | + buf << "up_thread_client_receive: epoll_ctl EPOLL_CTL_ADD error: "; | |
1456 | + buf << strerror(errno); | |
1457 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1458 | + func_tag = UP_FUNC_CLIENT_DISCONNECT; | |
1459 | + goto up_thread_client_receive_out; | |
1460 | + } | |
1461 | + up_client_epollfd_registered = true; | |
1462 | + } | |
1463 | + ret_fds = epoll_wait(up_client_epollfd, up_client_events, EVENT_NUM, epoll_timeout); | |
1464 | + if (ret_fds == 0) { | |
1465 | + goto up_thread_client_receive_out; // epoll timeout | |
1466 | + } else if (ret_fds < 0) { | |
1467 | + boost::format formatter("up_thread_client_receive: epoll_wait error: %s"); | |
1468 | + formatter % strerror(errno); | |
1469 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1470 | + func_tag = UP_FUNC_CLIENT_DISCONNECT; | |
1471 | + goto up_thread_client_receive_out; | |
1472 | + } | |
1473 | + | |
1474 | + for (int i = 0; i < ret_fds; ++i) { | |
1475 | + if (up_client_events[i].data.fd == event.data.fd) { | |
1476 | + if (up_client_events[i].events & EPOLLIN) { | |
1477 | + goto up_thread_client_receive_out; | |
1478 | + } | |
1479 | + if (up_client_events[i].events & EPOLLHUP) { | |
1480 | + func_tag = UP_FUNC_CLIENT_DISCONNECT; | |
1481 | + goto up_thread_client_receive_out; | |
1482 | + } | |
1483 | + } | |
1484 | + } | |
1485 | + boost::format formatter("up_thread_client_receive: unknown file descriptor's event: %s"); | |
1486 | + formatter % strerror(errno); | |
1487 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1488 | + func_tag = UP_FUNC_CLIENT_DISCONNECT; | |
1489 | + } else if (ec == boost::asio::error::eof) { | |
1510 | 1490 | func_tag = UP_FUNC_CLIENT_DISCONNECT; |
1511 | - } else if (ec == boost::asio::error::try_again) { | |
1512 | - func_tag = UP_FUNC_CLIENT_RECEIVE; | |
1513 | 1491 | } else { |
1514 | 1492 | boost::format formatter("Thread ID[%d] client read error: %s"); |
1515 | 1493 | formatter % boost::this_thread::get_id() % ec.message(); |
@@ -1517,6 +1495,8 @@ void tcp_session::up_thread_client_receive(const TCP_PROCESS_TYPE_TAG process_ty | ||
1517 | 1495 | func_tag = UP_FUNC_CLIENT_DISCONNECT; |
1518 | 1496 | } |
1519 | 1497 | } |
1498 | + | |
1499 | +up_thread_client_receive_out: | |
1520 | 1500 | up_thread_next_call_function = up_thread_function_array[func_tag]; |
1521 | 1501 | |
1522 | 1502 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
@@ -1651,82 +1631,10 @@ void tcp_session::up_thread_realserver_send(const TCP_PROCESS_TYPE_TAG process_t | ||
1651 | 1631 | std::size_t data_size = up_thread_data_dest_side.get_size(); |
1652 | 1632 | std::size_t send_data_size = up_thread_data_dest_side.get_send_size(); |
1653 | 1633 | std::size_t send_size; |
1654 | - UP_THREAD_FUNC_TYPE_TAG func_tag; | |
1634 | + UP_THREAD_FUNC_TYPE_TAG func_tag = UP_FUNC_REALSERVER_SEND; | |
1635 | + int ret_fds; | |
1655 | 1636 | |
1656 | 1637 | struct epoll_event event; |
1657 | - event.data.fd = send_socket->second->get_socket().native(); | |
1658 | - if (is_epoll_edge_trigger) { | |
1659 | - event.events = EPOLLOUT | EPOLLHUP | EPOLLET; | |
1660 | - } else { | |
1661 | - event.events = EPOLLOUT | EPOLLHUP; | |
1662 | - } | |
1663 | - bool add_flag = false; | |
1664 | - if (!up_realserver_epollfd_registered) { | |
1665 | - if (epoll_ctl(up_realserver_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
1666 | - std::stringstream buf; | |
1667 | - buf << "up_thread_realserver_send: epoll_ctl EPOLL_CTL_ADD error: "; | |
1668 | - buf << strerror(errno); | |
1669 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1670 | - boost::this_thread::yield(); | |
1671 | - return; | |
1672 | - } | |
1673 | - up_realserver_epollfd_registered = true; | |
1674 | - add_flag = true; | |
1675 | - } | |
1676 | - | |
1677 | - { | |
1678 | - rd_scoped_lock scoped_lock(exit_flag_update_mutex); | |
1679 | - if (unlikely(exit_flag)) { | |
1680 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_EXIT]; | |
1681 | - return; | |
1682 | - } | |
1683 | - } | |
1684 | - | |
1685 | - if (is_epoll_edge_trigger && (!add_flag)) { | |
1686 | - if (epoll_ctl(up_realserver_epollfd, EPOLL_CTL_MOD, event.data.fd, &event) < 0) { | |
1687 | - std::stringstream buf; | |
1688 | - buf << "up_thread_realserver_send: epoll_ctl EPOLL_CTL_MOD error: "; | |
1689 | - buf << strerror(errno); | |
1690 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1691 | - boost::this_thread::yield(); | |
1692 | - return; | |
1693 | - } | |
1694 | - } | |
1695 | - | |
1696 | - int ret_fds = epoll_wait(up_realserver_epollfd, up_realserver_events, EVENT_NUM, epoll_timeout); | |
1697 | - if (ret_fds <= 0) { | |
1698 | - if (ret_fds == 0) { | |
1699 | - //----Debug log---------------------------------------------------------------------- | |
1700 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
1701 | - std::stringstream buf; | |
1702 | - buf << "up_thread_realserver_send: epoll_wait timeout " << epoll_timeout << " msec."; | |
1703 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1704 | - } | |
1705 | - //----Debug log---------------------------------------------------------------------- | |
1706 | - } else { | |
1707 | - std::stringstream buf; | |
1708 | - buf << "up_thread_realserver_send: epoll_wait error: " << strerror(errno); | |
1709 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1710 | - } | |
1711 | - //XXX no need to retry??? | |
1712 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_REALSERVER_DISCONNECT]; | |
1713 | - return; | |
1714 | - } | |
1715 | - | |
1716 | - for (int i = 0; i < ret_fds; ++i) { | |
1717 | - if (up_realserver_events[i].data.fd == event.data.fd) { | |
1718 | - if (up_realserver_events[i].events & EPOLLOUT) { | |
1719 | - break; | |
1720 | - } else if (up_realserver_events[i].events & EPOLLHUP) { | |
1721 | - std::stringstream buf; | |
1722 | - buf << "up_thread_realserver_send: epoll hung up event"; | |
1723 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1724 | - up_thread_next_call_function = up_thread_function_array[UP_FUNC_REALSERVER_DISCONNECT]; | |
1725 | - return; | |
1726 | - } | |
1727 | - } | |
1728 | - } | |
1729 | - | |
1730 | 1638 | send_size = send_socket->second->write_some( |
1731 | 1639 | boost::asio::buffer( |
1732 | 1640 | data_buff.data() + send_data_size, |
@@ -1743,29 +1651,70 @@ void tcp_session::up_thread_realserver_send(const TCP_PROCESS_TYPE_TAG process_t | ||
1743 | 1651 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 37, formatter.str(), __FILE__, __LINE__); |
1744 | 1652 | } |
1745 | 1653 | //----Debug log---------------------------------------------------------------------- |
1746 | - if (data_size > send_data_size) { | |
1747 | - func_tag = UP_FUNC_REALSERVER_SEND; | |
1748 | - } else { | |
1654 | + if (data_size <= send_data_size) { | |
1749 | 1655 | protocol_module_base::EVENT_TAG module_event = protocol_module->handle_realserver_send(up_thread_id); |
1750 | 1656 | std::map<protocol_module_base::EVENT_TAG, UP_THREAD_FUNC_TYPE_TAG>::iterator func_type = up_thread_module_event_map.find(module_event); |
1751 | 1657 | func_tag = func_type->second; |
1752 | 1658 | } |
1753 | 1659 | } else { |
1754 | 1660 | if (ec == boost::asio::error::try_again) { |
1755 | - func_tag = UP_FUNC_REALSERVER_SEND; | |
1661 | + event.data.fd = send_socket->second->get_socket().native(); | |
1662 | + if (!up_realserver_epollfd_registered) { | |
1663 | + if (is_epoll_edge_trigger) { | |
1664 | + event.events = EPOLLOUT | EPOLLHUP | EPOLLET; | |
1665 | + } else { | |
1666 | + event.events = EPOLLOUT | EPOLLHUP; | |
1667 | + } | |
1668 | + if (epoll_ctl(up_realserver_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
1669 | + std::stringstream buf; | |
1670 | + buf << "up_thread_realserver_send: epoll_ctl EPOLL_CTL_ADD error: "; | |
1671 | + buf << strerror(errno); | |
1672 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1673 | + goto up_thread_realserver_send_out; | |
1674 | + } | |
1675 | + up_realserver_epollfd_registered = true; | |
1676 | + } | |
1677 | + ret_fds = epoll_wait(up_realserver_epollfd, up_realserver_events, EVENT_NUM, epoll_timeout); | |
1678 | + if (ret_fds == 0) { | |
1679 | + goto up_thread_realserver_send_out; // epoll timeout | |
1680 | + } else if (ret_fds < 0) { | |
1681 | + std::stringstream buf; | |
1682 | + buf << "up_thread_realserver_send: epoll_wait error: " << strerror(errno); | |
1683 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
1684 | + func_tag = UP_FUNC_REALSERVER_DISCONNECT; | |
1685 | + goto up_thread_realserver_send_out; | |
1686 | + } | |
1687 | + for (int i = 0; i < ret_fds; ++i) { | |
1688 | + if (up_realserver_events[i].data.fd == event.data.fd) { | |
1689 | + if (up_realserver_events[i].events & EPOLLOUT) { | |
1690 | + goto up_thread_realserver_send_out; | |
1691 | + } else if (up_realserver_events[i].events & EPOLLHUP) { | |
1692 | + func_tag = UP_FUNC_REALSERVER_DISCONNECT; | |
1693 | + goto up_thread_realserver_send_out; | |
1694 | + } | |
1695 | + } | |
1696 | + } | |
1697 | + boost::format formatter("up_thread_realserver_send: unknown file descriptor's event: %s"); | |
1698 | + formatter % strerror(errno); | |
1699 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1700 | + func_tag = UP_FUNC_REALSERVER_DISCONNECT; | |
1701 | + } else if (ec == boost::asio::error::eof) { | |
1702 | + func_tag = UP_FUNC_REALSERVER_DISCONNECT; | |
1756 | 1703 | } else { |
1704 | + boost::format formatter("Thread ID[%d] realserver write error: %s"); | |
1705 | + formatter % boost::this_thread::get_id() % ec.message(); | |
1706 | + Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
1757 | 1707 | func_tag = UP_FUNC_REALSERVER_DISCONNECT; |
1758 | 1708 | } |
1759 | 1709 | } |
1760 | 1710 | |
1711 | +up_thread_realserver_send_out: | |
1761 | 1712 | up_thread_next_call_function = up_thread_function_array[func_tag]; |
1762 | - | |
1763 | 1713 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
1764 | 1714 | boost::format formatter("Thread ID[%d] FUNC OUT up_thread_realserver_send: NEXT_FUNC[%s]"); |
1765 | 1715 | formatter % boost::this_thread::get_id() % func_tag_to_string(func_tag); |
1766 | 1716 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); |
1767 | 1717 | } |
1768 | - | |
1769 | 1718 | } |
1770 | 1719 | |
1771 | 1720 | //! up thread raise module event of handle_realserver_select |
@@ -2659,6 +2608,16 @@ void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG proc | ||
2659 | 2608 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); |
2660 | 2609 | } |
2661 | 2610 | |
2611 | + down_thread_data_dest_side.initialize(); | |
2612 | + boost::array<char, MAX_BUFFER_SIZE>& data_buff = down_thread_data_dest_side.get_data(); | |
2613 | + boost::system::error_code ec; | |
2614 | + size_t recv_size; | |
2615 | + DOWN_THREAD_FUNC_TYPE_TAG func_tag = DOWN_FUNC_REALSERVER_RECEIVE; | |
2616 | + struct epoll_event event; | |
2617 | + int ret_fds; | |
2618 | + endpoint server_endpoint; | |
2619 | + std::list<socket_element>::iterator list_end; | |
2620 | + | |
2662 | 2621 | if (down_thread_receive_realserver_socket_list.empty()) { |
2663 | 2622 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
2664 | 2623 | boost::format formatter("Thread ID[%d] FUNC OUT down_thread_realserver_receive"); |
@@ -2669,10 +2628,8 @@ void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG proc | ||
2669 | 2628 | if (!realserver_connect_status) { |
2670 | 2629 | to_time(LOCKTIMEOUT, xt); |
2671 | 2630 | realserver_connect_cond.timed_wait(lock, xt); |
2672 | - //realserver_connect_cond.wait(lock); | |
2673 | 2631 | } |
2674 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_REALSERVER_RECEIVE]; | |
2675 | - return; | |
2632 | + goto down_thread_realserver_receive_no_socket_out; | |
2676 | 2633 | } |
2677 | 2634 | |
2678 | 2635 | if (unlikely(0 < parent_service.get_wait_downstream())) { |
@@ -2684,81 +2641,10 @@ void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG proc | ||
2684 | 2641 | Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 42, buf.str(), __FILE__, __LINE__); |
2685 | 2642 | } |
2686 | 2643 | //----Debug log---------------------------------------------------------------------- |
2687 | - return; | |
2688 | - } | |
2689 | - down_thread_data_dest_side.initialize(); | |
2690 | - boost::array<char, MAX_BUFFER_SIZE>& data_buff = down_thread_data_dest_side.get_data(); | |
2691 | - boost::system::error_code ec; | |
2692 | - size_t recv_size; | |
2693 | - DOWN_THREAD_FUNC_TYPE_TAG func_tag; | |
2694 | - | |
2695 | - struct epoll_event event; | |
2696 | - event.data.fd = down_thread_current_receive_realserver_socket->second->get_socket().native(); | |
2697 | - if (is_epoll_edge_trigger) { | |
2698 | - event.events = EPOLLIN | EPOLLHUP | EPOLLET; | |
2699 | - } else { | |
2700 | - event.events = EPOLLIN | EPOLLHUP; | |
2701 | - } | |
2702 | - bool add_flag = false; | |
2703 | - if (!down_realserver_epollfd_registered) { | |
2704 | - if (epoll_ctl(down_realserver_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
2705 | - std::stringstream buf; | |
2706 | - buf << "down_thread_realserver_receive: epoll_ctl EPOLL_CTL_ADD error: " << strerror(errno); | |
2707 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
2708 | - boost::this_thread::yield(); | |
2709 | - return; | |
2710 | - } | |
2711 | - down_realserver_epollfd_registered = true; | |
2712 | - add_flag = true; | |
2713 | - } | |
2714 | - | |
2715 | - if (is_epoll_edge_trigger && (!add_flag)) { | |
2716 | - if (epoll_ctl(down_realserver_epollfd, EPOLL_CTL_MOD, event.data.fd, &event) < 0) { | |
2717 | - std::stringstream buf; | |
2718 | - buf << "down_thread_realserver_receive: epoll_ctl EPOLL_CTL_MOD error: " << strerror(errno); | |
2719 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
2720 | - boost::this_thread::yield(); | |
2721 | - return; | |
2722 | - } | |
2723 | - } | |
2724 | - | |
2725 | - int ret_fds = epoll_wait(down_realserver_epollfd, down_realserver_events, EVENT_NUM, epoll_timeout); | |
2726 | - if (ret_fds <= 0) { | |
2727 | - if (ret_fds == 0) { | |
2728 | - //----Debug log---------------------------------------------------------------------- | |
2729 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
2730 | - boost::format formatter("down_thread_realserver_receive: epoll_wait timeout %d msec."); | |
2731 | - formatter % epoll_timeout; | |
2732 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
2733 | - } | |
2734 | - //----Debug log---------------------------------------------------------------------- | |
2735 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_REALSERVER_RECEIVE]; | |
2736 | - return; | |
2737 | - } else { | |
2738 | - boost::format formatter("down_thread_realserver_receive: epoll_wait error: %d"); | |
2739 | - formatter % strerror(errno); | |
2740 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
2741 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_REALSERVER_DISCONNECT]; | |
2742 | - return; | |
2743 | - } | |
2644 | + goto down_thread_realserver_receive_out; | |
2744 | 2645 | } |
2745 | 2646 | |
2746 | - for (int i = 0; i < ret_fds; ++i) { | |
2747 | - if (down_realserver_events[i].data.fd == event.data.fd) { | |
2748 | - if (down_realserver_events[i].events & EPOLLIN) { | |
2749 | - break; | |
2750 | - } else if (down_realserver_events[i].events & EPOLLHUP) { | |
2751 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_REALSERVER_DISCONNECT]; | |
2752 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
2753 | - boost::format formatter("Thread ID[%d] FUNC OUT down_thread_realserver_receive: EPOLL_HUP"); | |
2754 | - formatter % boost::this_thread::get_id(); | |
2755 | - } | |
2756 | - return; | |
2757 | - } | |
2758 | - } | |
2759 | - } | |
2760 | - | |
2761 | - endpoint server_endpoint = down_thread_current_receive_realserver_socket->first; | |
2647 | + server_endpoint = down_thread_current_receive_realserver_socket->first; | |
2762 | 2648 | down_thread_data_dest_side.set_endpoint(server_endpoint); |
2763 | 2649 | |
2764 | 2650 | recv_size = down_thread_current_receive_realserver_socket->second->read_some(boost::asio::buffer(data_buff, MAX_BUFFER_SIZE), ec); |
@@ -2779,25 +2665,68 @@ void tcp_session::down_thread_realserver_receive(const TCP_PROCESS_TYPE_TAG proc | ||
2779 | 2665 | |
2780 | 2666 | std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event); |
2781 | 2667 | func_tag = func_type->second; |
2782 | - } else { | |
2783 | - func_tag = DOWN_FUNC_REALSERVER_RECEIVE; | |
2784 | - //boost::this_thread::yield(); | |
2785 | 2668 | } |
2786 | 2669 | } else { |
2787 | 2670 | if (ec == boost::asio::error::try_again) { |
2788 | - func_tag = DOWN_FUNC_REALSERVER_RECEIVE; | |
2789 | - //boost::this_thread::yield(); | |
2671 | + // epoll wait | |
2672 | + event.data.fd = down_thread_current_receive_realserver_socket->second->get_socket().native(); | |
2673 | + if (!down_realserver_epollfd_registered) { | |
2674 | + if (is_epoll_edge_trigger) { | |
2675 | + event.events = EPOLLIN | EPOLLHUP | EPOLLET; | |
2676 | + } else { | |
2677 | + event.events = EPOLLIN | EPOLLHUP; | |
2678 | + } | |
2679 | + if (epoll_ctl(down_realserver_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
2680 | + std::stringstream buf; | |
2681 | + buf << "down_thread_realserver_receive: epoll_ctl EPOLL_CTL_ADD error: " << strerror(errno); | |
2682 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
2683 | + goto down_thread_realserver_receive_out; | |
2684 | + } | |
2685 | + down_realserver_epollfd_registered = true; | |
2686 | + } | |
2687 | + ret_fds = epoll_wait(down_realserver_epollfd, down_realserver_events, EVENT_NUM, epoll_timeout); | |
2688 | + if (ret_fds == 0) { | |
2689 | + goto down_thread_realserver_receive_out; // epoll timeout | |
2690 | + } else if (ret_fds < 0) { | |
2691 | + boost::format formatter("down_thread_realserver_receive: epoll_wait error: %d"); | |
2692 | + formatter % strerror(errno); | |
2693 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
2694 | + func_tag = DOWN_FUNC_REALSERVER_DISCONNECT; | |
2695 | + goto down_thread_realserver_receive_out; | |
2696 | + } | |
2697 | + for (int i = 0; i < ret_fds; ++i) { | |
2698 | + if (down_realserver_events[i].data.fd == event.data.fd) { | |
2699 | + if (down_realserver_events[i].events & EPOLLIN) { | |
2700 | + goto down_thread_realserver_receive_out; | |
2701 | + } else if (down_realserver_events[i].events & EPOLLHUP) { | |
2702 | + func_tag = DOWN_FUNC_REALSERVER_DISCONNECT; | |
2703 | + goto down_thread_realserver_receive_out; | |
2704 | + } | |
2705 | + } | |
2706 | + } | |
2707 | + boost::format formatter("down_thread_realserver_receive: unknown file descriptor's event: %s"); | |
2708 | + formatter % strerror(errno); | |
2709 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
2710 | + func_tag = DOWN_FUNC_REALSERVER_DISCONNECT; | |
2711 | + } else if (ec == boost::asio::error::eof) { | |
2712 | + func_tag = DOWN_FUNC_REALSERVER_DISCONNECT; | |
2790 | 2713 | } else { |
2714 | + boost::format formatter("Thread ID[%d] realserver read error: %s"); | |
2715 | + formatter % boost::this_thread::get_id() % ec.message(); | |
2716 | + Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
2791 | 2717 | func_tag = DOWN_FUNC_REALSERVER_DISCONNECT; |
2792 | 2718 | } |
2793 | 2719 | } |
2794 | 2720 | |
2795 | - down_thread_function_pair func = down_thread_function_array[func_tag]; | |
2721 | +down_thread_realserver_receive_out: | |
2796 | 2722 | down_thread_current_receive_realserver_socket++; |
2797 | - std::list<socket_element>::iterator list_end = down_thread_receive_realserver_socket_list.end(); | |
2723 | + list_end = down_thread_receive_realserver_socket_list.end(); | |
2798 | 2724 | if (down_thread_current_receive_realserver_socket == list_end) { |
2799 | 2725 | down_thread_current_receive_realserver_socket = down_thread_receive_realserver_socket_list.begin(); |
2800 | 2726 | } |
2727 | + | |
2728 | +down_thread_realserver_receive_no_socket_out: | |
2729 | + down_thread_function_pair func = down_thread_function_array[func_tag]; | |
2801 | 2730 | down_thread_next_call_function = func; |
2802 | 2731 | |
2803 | 2732 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
@@ -3004,124 +2933,91 @@ void tcp_session::down_thread_client_send(const TCP_PROCESS_TYPE_TAG process_typ | ||
3004 | 2933 | std::size_t data_size = down_thread_data_client_side.get_size(); |
3005 | 2934 | std::size_t send_data_size = down_thread_data_client_side.get_send_size(); |
3006 | 2935 | std::size_t send_size; |
3007 | - DOWN_THREAD_FUNC_TYPE_TAG func_tag; | |
3008 | - | |
2936 | + DOWN_THREAD_FUNC_TYPE_TAG func_tag = DOWN_FUNC_CLIENT_SEND; | |
3009 | 2937 | struct epoll_event event; |
3010 | - event.data.fd = !ssl_flag ? client_socket.get_socket().native() | |
3011 | - : client_ssl_socket.get_socket().lowest_layer().native(); | |
2938 | + int ret_fds; | |
3012 | 2939 | |
3013 | - if (is_epoll_edge_trigger) { | |
3014 | - event.events = EPOLLOUT | EPOLLHUP | EPOLLET; | |
3015 | - } else { | |
3016 | - event.events = EPOLLOUT | EPOLLHUP; | |
3017 | - } | |
3018 | - bool add_flag = false; | |
3019 | - if (!down_client_epollfd_registered) { | |
3020 | - if (epoll_ctl(down_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
3021 | - std::stringstream buf; | |
3022 | - buf << "down_thread_client_send: epoll_ctl EPOLL_CTL_ADD error: "; | |
3023 | - buf << strerror(errno); | |
3024 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
3025 | - boost::this_thread::yield(); | |
3026 | - return; | |
2940 | + send_size = !ssl_flag ? client_socket.write_some( | |
2941 | + boost::asio::buffer( | |
2942 | + data_buff.data() + send_data_size, | |
2943 | + data_size - send_data_size), | |
2944 | + ec) | |
2945 | + : client_ssl_socket.write_some( | |
2946 | + boost::asio::buffer( | |
2947 | + data_buff.data() + send_data_size, | |
2948 | + data_size - send_data_size), | |
2949 | + ec); | |
2950 | + if (!ec) { | |
2951 | + send_data_size += send_size; | |
2952 | + down_thread_data_client_side.set_send_size(send_data_size); | |
2953 | + parent_service.update_down_send_size(send_size); | |
2954 | + //----Debug log---------------------------------------------------------------------- | |
2955 | + if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
2956 | + boost::format formatter("Thread ID[%d] down_thread_client_send send data size[%d] for [%d]"); | |
2957 | + formatter % boost::this_thread::get_id() % send_size % client_endpoint; | |
2958 | + Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 45, formatter.str(), __FILE__, __LINE__); | |
3027 | 2959 | } |
3028 | - down_client_epollfd_registered = true; | |
3029 | - add_flag = true; | |
3030 | - } | |
3031 | - | |
3032 | - while (true) { | |
3033 | - { | |
3034 | - rd_scoped_lock scoped_lock(exit_flag_update_mutex); | |
3035 | - if (unlikely(exit_flag)) { | |
3036 | - func_tag = DOWN_FUNC_EXIT; | |
3037 | - break; | |
3038 | - } | |
2960 | + //----Debug log---------------------------------------------------------------------- | |
2961 | + if (data_size > send_data_size) { | |
2962 | + goto down_thread_client_send_out; | |
2963 | + } else { | |
2964 | + protocol_module_base::EVENT_TAG module_event = protocol_module->handle_client_send(down_thread_id); | |
2965 | + std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event); | |
2966 | + func_tag = func_type->second; | |
2967 | + goto down_thread_client_send_out; | |
3039 | 2968 | } |
3040 | - | |
3041 | - if (is_epoll_edge_trigger && (!add_flag)) { | |
3042 | - if (epoll_ctl(down_client_epollfd, EPOLL_CTL_MOD, event.data.fd, &event) < 0) { | |
3043 | - std::stringstream buf; | |
3044 | - buf << "down_thread_client_send: epoll_ctl EPOLL_CTL_MOD error: "; | |
3045 | - buf << strerror(errno); | |
3046 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
3047 | - boost::this_thread::yield(); | |
3048 | - return; | |
2969 | + } else { | |
2970 | + if (ec == boost::asio::error::try_again) { | |
2971 | + event.data.fd = !ssl_flag ? client_socket.get_socket().native() | |
2972 | + : client_ssl_socket.get_socket().lowest_layer().native(); | |
2973 | + if (!down_client_epollfd_registered) { | |
2974 | + if (is_epoll_edge_trigger) { | |
2975 | + event.events = EPOLLOUT | EPOLLHUP | EPOLLET; | |
2976 | + } else { | |
2977 | + event.events = EPOLLOUT | EPOLLHUP; | |
2978 | + } | |
2979 | + if (epoll_ctl(down_client_epollfd, EPOLL_CTL_ADD, event.data.fd, &event) < 0) { | |
2980 | + std::stringstream buf; | |
2981 | + buf << "down_thread_client_send: epoll_ctl EPOLL_CTL_ADD error: "; | |
2982 | + buf << strerror(errno); | |
2983 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
2984 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
2985 | + goto down_thread_client_send_out; | |
2986 | + } | |
2987 | + down_client_epollfd_registered = true; | |
3049 | 2988 | } |
3050 | - } | |
3051 | - | |
3052 | - int ret_fds = epoll_wait(down_client_epollfd, down_client_events, EVENT_NUM, epoll_timeout); | |
3053 | - if (ret_fds <= 0) { | |
2989 | + ret_fds = epoll_wait(down_client_epollfd, down_client_events, EVENT_NUM, epoll_timeout); | |
3054 | 2990 | if (ret_fds == 0) { |
3055 | - std::stringstream buf; | |
3056 | - buf << "down_thread_client_send: epoll_wait timeout "; | |
3057 | - buf << epoll_timeout; | |
3058 | - buf << "mS"; | |
3059 | - Logger::putLogInfo(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
3060 | - } else { | |
3061 | - std::stringstream buf; | |
3062 | - buf << "down_thread_client_send: epoll_wait error: "; | |
3063 | - buf << strerror(errno); | |
3064 | - Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, buf.str(), __FILE__, __LINE__); | |
2991 | + goto down_thread_client_send_out; // epoll timeout | |
2992 | + } else if (ret_fds < 0) { | |
2993 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
2994 | + goto down_thread_client_send_out; | |
3065 | 2995 | } |
3066 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_CLIENT_DISCONNECT]; | |
3067 | - return; | |
3068 | - } | |
3069 | - | |
3070 | - for (int i = 0; i < ret_fds; ++i) { | |
3071 | - if (down_client_events[i].data.fd == event.data.fd) { | |
3072 | - if (down_client_events[i].events & EPOLLOUT) { | |
3073 | - break; | |
3074 | - } else if (down_client_events[i].events & EPOLLHUP) { | |
3075 | - down_thread_next_call_function = down_thread_function_array[DOWN_FUNC_CLIENT_DISCONNECT]; | |
3076 | - return; | |
2996 | + for (int i = 0; i < ret_fds; ++i) { | |
2997 | + if (down_client_events[i].data.fd == event.data.fd) { | |
2998 | + if (down_client_events[i].events & EPOLLOUT) { | |
2999 | + goto down_thread_client_send_out; | |
3000 | + } else if (down_client_events[i].events & EPOLLHUP) { | |
3001 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
3002 | + goto down_thread_client_send_out; | |
3003 | + } | |
3077 | 3004 | } |
3078 | 3005 | } |
3079 | - } | |
3080 | - | |
3081 | - send_size = !ssl_flag ? client_socket.write_some( | |
3082 | - boost::asio::buffer( | |
3083 | - data_buff.data() + send_data_size, | |
3084 | - data_size - send_data_size), | |
3085 | - ec) | |
3086 | - : client_ssl_socket.write_some( | |
3087 | - boost::asio::buffer( | |
3088 | - data_buff.data() + send_data_size, | |
3089 | - data_size - send_data_size), | |
3090 | - ec); | |
3091 | - if (!ec) { | |
3092 | - send_data_size += send_size; | |
3093 | - down_thread_data_client_side.set_send_size(send_data_size); | |
3094 | - parent_service.update_down_send_size(send_size); | |
3095 | - //----Debug log---------------------------------------------------------------------- | |
3096 | - if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { | |
3097 | - endpoint client_endpoint // XXX redefined??? | |
3098 | - = !ssl_flag ? client_socket.get_socket().lowest_layer().remote_endpoint(ec) | |
3099 | - : client_ssl_socket.get_socket().lowest_layer().remote_endpoint(ec); | |
3100 | - boost::format formatter("Thread ID[%d] down_thread_client_send send data size[%d] for [%d]"); | |
3101 | - formatter % boost::this_thread::get_id() % send_size % client_endpoint; | |
3102 | - Logger::putLogDebug(LOG_CAT_L7VSD_SESSION, 45, formatter.str(), __FILE__, __LINE__); | |
3103 | - } | |
3104 | - //----Debug log---------------------------------------------------------------------- | |
3105 | - if (data_size > send_data_size) { | |
3106 | - func_tag = DOWN_FUNC_CLIENT_SEND; | |
3107 | - //down_send_wait.reset(); | |
3108 | - } else { | |
3109 | - protocol_module_base::EVENT_TAG module_event = protocol_module->handle_client_send(down_thread_id); | |
3110 | - std::map<protocol_module_base::EVENT_TAG, DOWN_THREAD_FUNC_TYPE_TAG>::iterator func_type = down_thread_module_event_map.find(module_event); | |
3111 | - func_tag = func_type->second; | |
3112 | - } | |
3113 | - break; | |
3006 | + boost::format formatter("down_thread_client_send: unknown file descriptor's event: %s"); | |
3007 | + formatter % strerror(errno); | |
3008 | + Logger::putLogWarn(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
3009 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
3010 | + } else if (ec == boost::asio::error::eof) { | |
3011 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
3114 | 3012 | } else { |
3115 | - if (ec == boost::asio::error::try_again) { | |
3116 | - //func_tag = DOWN_FUNC_CLIENT_SEND; | |
3117 | - //boost::this_thread::yield(); | |
3118 | - } else { | |
3119 | - func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
3120 | - break; | |
3121 | - } | |
3013 | + boost::format formatter("Thread ID[%d] client write error: %s"); | |
3014 | + formatter % boost::this_thread::get_id() % ec.message(); | |
3015 | + Logger::putLogError(LOG_CAT_L7VSD_SESSION, 999, formatter.str(), __FILE__, __LINE__); | |
3016 | + func_tag = DOWN_FUNC_CLIENT_DISCONNECT; | |
3122 | 3017 | } |
3123 | 3018 | } |
3124 | 3019 | |
3020 | +down_thread_client_send_out: | |
3125 | 3021 | down_thread_next_call_function = down_thread_function_array[func_tag]; |
3126 | 3022 | |
3127 | 3023 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_SESSION))) { |
@@ -1721,11 +1721,11 @@ void l7vs::virtualservice_tcp::release_session(const tcp_session *session_ptr) | ||
1721 | 1721 | |
1722 | 1722 | session_thread_control *stc_ptr = active_sessions.find(session_ptr); |
1723 | 1723 | if (unlikely(NULL == stc_ptr)) { |
1724 | + boost::format fmt("session release fail: " | |
1725 | + "active_sessions.find( const tcp_session* session_ptr = %d )"); | |
1726 | + fmt % session_ptr; | |
1727 | + Logger::putLogError(LOG_CAT_L7VSD_VIRTUALSERVICE, /*XXX*/999, fmt.str(), __FILE__, __LINE__); | |
1724 | 1728 | if (unlikely(LOG_LV_DEBUG == Logger::getLogLevel(LOG_CAT_L7VSD_VIRTUALSERVICE))) { |
1725 | - boost::format fmt("session release fail: " | |
1726 | - "active_sessions.find( const tcp_session* session_ptr = %d )"); | |
1727 | - fmt % session_ptr; | |
1728 | - Logger::putLogDebug(LOG_CAT_L7VSD_VIRTUALSERVICE, 87, fmt.str(), __FILE__, __LINE__); | |
1729 | 1729 | Logger::putLogDebug(LOG_CAT_L7VSD_VIRTUALSERVICE, 88, "out_function: " |
1730 | 1730 | "void virtualservice_tcp::release_session( " |
1731 | 1731 | "const boost::thread::id thread_id )", __FILE__, __LINE__); |