| 709 | } |
| 710 | |
| 711 | void AsyncHttpClient::onDisconnect() |
| 712 | { |
| 713 | bool isConnected; |
| 714 | |
| 715 | LOG_INFO("Disconnected from %s:%u%s.", m_hostname.c_str(), m_port, m_uri.c_str()); |
| 716 | LOG_DEBUG("Available heap: %u", heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_DEFAULT)); |
| 717 | |
| 718 | /* Protect against concurrent access. */ |
| 719 | { |
| 720 | MutexGuard<Mutex> guard(m_mutex); |
| 721 | |
| 722 | isConnected = m_isConnected; |
| 723 | m_isConnected = false; |
| 724 | } |
| 725 | |
| 726 | if ((false == isConnected) && (false == m_isError)) |
| 727 | { |
| 728 | onError(ERR_CONN); |
| 729 | } |
| 730 | |
| 731 | m_isError = false; |
| 732 | clear(); |
| 733 | |
| 734 | /* It happens that during the connection establishment the SSL handshake fails. |
| 735 | * In this case, the connection is closed and no error is reported from the TCP client. |
| 736 | */ |
| 737 | if (false == isConnected) |
| 738 | { |
| 739 | onError(ERR_CONN); |
| 740 | } |
| 741 | |
| 742 | notifyClosed(); |
| 743 | |
| 744 | giveGlobalMutex(); |
| 745 | } |
| 746 | |
| 747 | void AsyncHttpClient::onError(int8_t error) |
| 748 | { |
no test coverage detected