samples: net: sockets: coap_download: Cancel requests before closing

Call coap_client_cancel_requests() before closing the client socket so
that all activities on that socket are ceased before close. This
prevents POLLNVAL error from being thrown by the coap_client thread and
error being printed in the sample output.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2025-02-14 12:25:20 +01:00 committed by Benjamin Cabé
commit b8614607d4

View file

@ -82,6 +82,8 @@ static void do_coap_download(struct sockaddr *sa)
/* Wait for CoAP request to complete */
k_sem_take(&coap_done_sem, K_FOREVER);
coap_client_cancel_requests(&client);
zsock_close(sockfd);
}