Skip to content

Commit 0dacdb0

Browse files
eivindj-nordicnordicjm
authored andcommitted
net: lib: downloader: avoid continous loop on error event
* The downloader expects an error to be returned from the error handler to abort the download. If not, the download will be retried indefinitely. * Add missing break to stopped event switch case. * Add dl_ prefix to internal downloader files. * Set progress to false when download is done. Signed-off-by: Eivind Jølsgard <[email protected]>
1 parent 65ece6a commit 0dacdb0

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ Libraries for networking
662662

663663
* Fixed an issue where the results from the :c:func:`zsock_getaddrinfo` function were not freed when the CoAP protocol was used for connection establishment.
664664

665+
* :ref:`lib_downloader` library:
666+
667+
* Fixed:
668+
669+
* A bug in the shell implementation causing endless download retries on errors.
670+
* A bug in the shell to allow multiple downloads.
671+
665672
Libraries for NFC
666673
-----------------
667674

subsys/net/lib/downloader/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ zephyr_library_sources(
88
src/dl_parse.c
99
src/dl_socket.c
1010
src/downloader.c
11-
src/sanity.c
11+
src/dl_sanity.c
1212
)
1313

1414
zephyr_library_sources_ifdef(
@@ -23,7 +23,7 @@ zephyr_library_sources_ifdef(
2323

2424
zephyr_library_sources_ifdef(
2525
CONFIG_DOWNLOADER_SHELL
26-
src/shell.c
26+
src/dl_shell.c
2727
)
2828

2929
zephyr_include_directories(./include)

subsys/net/lib/downloader/src/shell.c renamed to subsys/net/lib/downloader/src/dl_shell.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,23 @@ static int dl_callback(const struct downloader_evt *event)
5555
break;
5656
case DOWNLOADER_EVT_DONE:
5757
shell_print(shell_instance, "done (%d bytes)", downloaded);
58+
in_progress = false;
5859
downloaded = 0;
5960
break;
6061
case DOWNLOADER_EVT_ERROR:
6162
shell_error(shell_instance, "error %d during download", event->error);
62-
downloaded = 0;
63-
in_progress = false;
64-
break;
63+
if (event->error == -ECONNRESET) {
64+
/* Allow the downloader to retry. */
65+
return 0;
66+
}
67+
68+
/* Abort the download by returning an error. */
69+
return event->error;
6570
case DOWNLOADER_EVT_STOPPED:
6671
shell_print(shell_instance, "download client closed");
6772
in_progress = false;
73+
downloaded = 0;
74+
break;
6875
case DOWNLOADER_EVT_DEINITIALIZED:
6976
shell_print(shell_instance, "client deinitialized");
7077
in_progress = false;

tests/subsys/net/lib/downloader/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ target_sources(app
1919
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/downloader.c
2020
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/dl_socket.c
2121
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/dl_parse.c
22-
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/sanity.c
22+
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/dl_sanity.c
2323
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/transports/coap.c
2424
${ZEPHYR_NRF_MODULE_DIR}/subsys/net/lib/downloader/src/transports/http.c
2525
)

0 commit comments

Comments
 (0)