esp_http_client: Fix crash in async mode

Closes https://github.com/espressif/esp-idf/issues/2624
This commit is contained in:
Jitin George 2018-10-24 13:02:47 +05:30 committed by bot
parent 97e3542947
commit 3551b84c3a
3 changed files with 6 additions and 2 deletions

View file

@ -943,6 +943,10 @@ static esp_err_t esp_http_client_connect(esp_http_client_handle_t client)
int ret = esp_transport_connect_async(client->transport, client->connection_info.host, client->connection_info.port, client->timeout_ms);
if (ret == ASYNC_TRANS_CONNECT_FAIL) {
ESP_LOGE(TAG, "Connection failed");
if (strcasecmp(client->connection_info.scheme, "http") == 0) {
ESP_LOGE(TAG, "Asynchronous mode doesn't work for HTTP based connection");
return ESP_ERR_INVALID_ARG;
}
return ESP_ERR_HTTP_CONNECT;
} else if (ret == ASYNC_TRANS_CONNECTING) {
ESP_LOGD(TAG, "Connection not yet established");

View file

@ -114,7 +114,7 @@ typedef struct {
esp_http_client_transport_t transport_type; /*!< HTTP transport type, see `esp_http_client_transport_t` */
int buffer_size; /*!< HTTP buffer size (both send and receive) */
void *user_data; /*!< HTTP user_data context */
bool is_async; /*!< Set asynchronous mode */
bool is_async; /*!< Set asynchronous mode, only supported with HTTPS for now */
} esp_http_client_config_t;

View file

@ -156,7 +156,7 @@ int esp_transport_connect(esp_transport_handle_t t, const char *host, int port,
int esp_transport_connect_async(esp_transport_handle_t t, const char *host, int port, int timeout_ms)
{
int ret = -1;
if (t && t->_connect) {
if (t && t->_connect_async) {
return t->_connect_async(t, host, port, timeout_ms);
}
return ret;