From fcb5e2b1ee95b503aaa46dcbb5bce2fbd0286f51 Mon Sep 17 00:00:00 2001 From: Michael Scott Date: Tue, 27 Feb 2018 17:08:55 -0800 Subject: [PATCH] net: http: honor CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT setting We should not use the user suppied timeout setting in http_client_send_req() for the connection timeout. In the previous API the call to tcp_connect() used CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT as the timeout setting. Let's do that here too. This fixes -ETIMEDOUT error generation when using K_NO_WAIT for http_client_send_req(). NOTE: This patch was previously applied but was lost when commit d1675bf3e658 ("net: http: Remove the old legacy API") moved code around. Signed-off-by: Michael Scott --- subsys/net/lib/http/http_client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/subsys/net/lib/http/http_client.c b/subsys/net/lib/http/http_client.c index c76b6287e53..9563f052e88 100644 --- a/subsys/net/lib/http/http_client.c +++ b/subsys/net/lib/http/http_client.c @@ -38,6 +38,9 @@ #define HTTP_CONTENT_LEN "Content-Length" #define HTTP_CONT_LEN_SIZE 6 +/* Default network activity timeout in seconds */ +#define HTTP_NETWORK_TIMEOUT K_SECONDS(CONFIG_HTTP_CLIENT_NETWORK_TIMEOUT) + int client_reset(struct http_ctx *ctx) { http_parser_init(&ctx->http.parser, HTTP_RESPONSE); @@ -235,7 +238,7 @@ int http_client_send_req(struct http_ctx *ctx, ctx->http.rsp.cb = cb; - ret = net_app_connect(&ctx->app_ctx, timeout); + ret = net_app_connect(&ctx->app_ctx, HTTP_NETWORK_TIMEOUT); if (ret < 0) { NET_DBG("Cannot connect to server (%d)", ret); return ret; @@ -244,7 +247,7 @@ int http_client_send_req(struct http_ctx *ctx, /* We might wait longer than timeout if the first connection * establishment takes long time (like with HTTPS) */ - if (k_sem_take(&ctx->http.connect_wait, timeout)) { + if (k_sem_take(&ctx->http.connect_wait, HTTP_NETWORK_TIMEOUT)) { NET_DBG("Connection timed out"); ret = -ETIMEDOUT; goto out;