@@ -191,8 +191,10 @@ size_t channel_callback_ipc(void *streamdata, size_t size, size_t nmemb,
return 0;
}
- if (data->channel_data->checkdwl && data->channel_data->checkdwl())
- return 0;
+ if (data->channel_data->dwlwrdata) {
+ return data->channel_data->dwlwrdata(streamdata, size, nmemb, data->channel_data);
+ }
+
/*
* Now check if there is a callback from the server
* during the download
@@ -68,7 +68,8 @@ typedef struct {
bool nocheckanswer;
long http_response_code;
bool nofollow;
- int (*checkdwl)(void);
+ size_t (*dwlwrdata)(char *streamdata, size_t size, size_t nmemb,
+ void *data);
struct swupdate_digest *dgst;
char sha1hash[SWUPDATE_SHA_DIGEST_LENGTH * 2 + 1];
sourcetype source;
@@ -545,7 +545,7 @@ server_op_res_t server_install_update(void)
channel_data.nofollow = false;
channel_data.nocheckanswer = false;
- channel_data.checkdwl = NULL;
+ channel_data.dwlwrdata = NULL;
channel_data.url = strdup(url);
@@ -651,12 +651,15 @@ cleanup:
return result;
}
-static int server_check_during_dwl(void)
+static size_t server_check_during_dwl(char __attribute__ ((__unused__)) *streamdata,
+ size_t size,
+ size_t nmemb,
+ void __attribute__ ((__unused__)) *data)
{
struct timeval now;
channel_data_t channel_data = channel_data_defaults;
int action_id;
- int ret = 0;
+ int ret = size * nmemb;
const char *update_action;
server_get_current_time(&now);
@@ -668,7 +671,7 @@ static int server_check_during_dwl(void)
* was requested
*/
if ((now.tv_sec - server_time.tv_sec) < ((int)server_get_polling_interval()))
- return 0;
+ return ret;
/* Update current server time */
server_time = now;
@@ -685,7 +688,7 @@ static int server_check_during_dwl(void)
* go on downloading
*/
free(channel);
- return 0;
+ return ret;
}
/*
@@ -696,13 +699,13 @@ static int server_check_during_dwl(void)
if (result == SERVER_UPDATE_CANCELED) {
/* Mark that an update was cancelled by the server */
server_hawkbit.cancelDuringUpdate = true;
- ret = -1;
+ ret = 0;
}
update_action = json_get_deployment_update_action(channel_data.json_reply);
/* if the deployment is skipped then stop downloading */
if (update_action == deployment_update_action.skip)
- ret = -1;
+ ret = 0;
check_action_changed(action_id, update_action);
@@ -1146,7 +1149,7 @@ server_op_res_t server_process_update_artifact(int action_id,
goto cleanup_loop;
}
- channel_data.checkdwl = server_check_during_dwl;
+ channel_data.dwlwrdata = server_check_during_dwl;
/*
* There is no authorizytion token when file is loaded, because SWU
The "checkdwl" callback is used up now only by the Hawkbit backend to check if there is a cancel request on the server. It is called by the curl WRITEFUNCTION callback, but the callback in channel_curl.c changes the signature and does not send parameters to checkdwl. Rename checkdwl in a more generic "dwlwrdata" and pass all parameters foreseen by Curl for the callback. This allows to get access to the incoming stream and the channel can be used in other cases without sending data to to installer. Signed-off-by: Stefano Babic <sbabic@denx.de> --- corelib/channel_curl.c | 6 ++++-- include/channel_curl.h | 3 ++- suricatta/server_general.c | 2 +- suricatta/server_hawkbit.c | 17 ++++++++++------- 4 files changed, 17 insertions(+), 11 deletions(-)