Skip to content

Commit 6742813

Browse files
plskeggsbjarki-andreasen
authored andcommitted
[nrf fromlist] net: lib: http: ensure SYS_FOREVER_MS behavior
The http_client_req() function's timeout parameter is allowed to be SYS_FOREVER_MS. However, K_MSEC() does not convert this to a proper k_timeout_t, so sys_timepoint_calc() ends up returning 0, which is causes immediate timeouts. Check for this case specifically and force value passed to sys_timepoint_calc() to be correct. Upstream PR: a1610770f590ae7e6e625cfee6a6ca3058990959 Signed-off-by: Pete Skeggs <[email protected]>
1 parent 26313d8 commit 6742813

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

subsys/net/lib/http/http_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ int http_client_req(int sock, struct http_request *req,
562562
int total_sent = 0;
563563
int ret, total_recv, i;
564564
const char *method;
565-
k_timeout_t req_timeout = K_MSEC(timeout);
565+
k_timeout_t req_timeout = (timeout == SYS_FOREVER_MS) ? K_FOREVER : K_MSEC(timeout);
566566
k_timepoint_t req_end_timepoint = sys_timepoint_calc(req_timeout);
567567

568568
if (sock < 0 || req == NULL || req->response == NULL ||

0 commit comments

Comments
 (0)