From efc23868624faa3c1f579a7d0d00725b38320a29 Mon Sep 17 00:00:00 2001 From: liuxianliang Date: Mon, 15 Nov 2021 18:41:28 +0800 Subject: [PATCH] [update] abort receive when "session->handle_function" was failed. --- samples/webclient_shard_download_sample.c | 6 +++++- src/webclient.c | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/samples/webclient_shard_download_sample.c b/samples/webclient_shard_download_sample.c index d60c283..e9b5def 100644 --- a/samples/webclient_shard_download_sample.c +++ b/samples/webclient_shard_download_sample.c @@ -114,7 +114,11 @@ int webclient_shard_download_test(int argc, char **argv) webclient_register_shard_position_function(session, shard_download_handle); /* the "memory size" that you can provide in the project and uri */ - webclient_shard_position_function(session, uri, 0, length, size); + result = webclient_shard_position_function(session, uri, 0, length, size); + if(result != WEBCLIENT_OK) + { + rt_kprintf("web shard download, test failed!\n"); + } /* clear the handle function */ webclient_register_shard_position_function(session, RT_NULL); diff --git a/src/webclient.c b/src/webclient.c index 2f60628..b92eb52 100644 --- a/src/webclient.c +++ b/src/webclient.c @@ -1043,6 +1043,7 @@ int webclient_shard_head_function(struct webclient_session *session, const char int webclient_shard_position_function(struct webclient_session *session, const char *URI, int start, int length, int mem_size) { int rc = WEBCLIENT_OK; + int result = RT_EOK; int resp_status = 0; int resp_len = 0; char *buffer = RT_NULL; @@ -1142,7 +1143,11 @@ int webclient_shard_position_function(struct webclient_session *session, const c if(data_len > 0) { start_position += mem_size; - session->handle_function(buffer, data_len); + result = session->handle_function(buffer, data_len); + if(result != RT_EOK) + { + return -WEBCLIENT_ERROR; + } } else {