*response_code = http_code;
if (res != CURLE_OK) {
- pr_val_err("Error requesting URL %s: %s. (HTTP code: %ld)",
- uri, curl_err_string(handler, res), http_code);
+ pr_val_err("Error requesting URL: %s. (HTTP code: %ld)",
+ curl_err_string(handler, res), http_code);
if (log_operation)
- pr_op_err("Error requesting URL %s: %s. (HTTP code: %ld)",
- uri, curl_err_string(handler, res), http_code);
+ pr_op_err("Error requesting URL: %s. (HTTP code: %ld)",
+ curl_err_string(handler, res), http_code);
switch (res) {
case CURLE_FILESIZE_EXCEEDED:
if (retries == config_get_http_retry_count()) {
if (retries > 0)
- pr_val_warn("Max HTTP retries (%u) reached requesting for '%s', won't retry again.",
- retries, uri_get_global(uri));
+ pr_val_warn("Max HTTP retries (%u) reached. Won't retry again.",
+ retries);
break;
}
- pr_val_warn("Retrying HTTP request '%s' in %u seconds, %u attempts remaining.",
- uri_get_global(uri),
+ pr_val_warn("Retrying HTTP request in %u seconds. %u attempts remaining.",
config_get_http_retry_interval(),
config_get_http_retry_count() - retries);
retries++;
if (error)
goto upd_end;
- /* No updates at the file (yet), didn't pushed to fnstack */
if (upd_notification == NULL) {
pr_val_debug("The Update Notification has not changed.");
goto upd_end;
uri_get_global(uri));
db_rrdp_uris_set_last_update(uri_get_global(uri));
upd_destroy:
- if (upd_notification != NULL) {
+ if (upd_notification != NULL)
update_notification_destroy(upd_notification);
- fnstack_pop(); /* Pop from rrdp_parse_notification */
- }
upd_end:
/* Just return on success */
if (!error) {
if (error)
return error;
+ fnstack_push_uri(uri);
+
error = download_file(uri, 0, args->log_operation);
if (error)
goto release_uri;
delete_from_uri(uri, NULL);
/* Error 0 its ok */
release_uri:
+ fnstack_pop();
uri_refput(uri);
return error;
}
if (uri == NULL || uri_is_rsync(uri))
pr_crit("Wrong call, trying to parse a non HTTPS URI");
- pr_val_debug("Processing notification '%s'.", uri_get_global(uri));
+ fnstack_push_uri(uri);
+ pr_val_debug("Processing notification.");
+
last_update = 0;
if (!force) {
error = db_rrdp_uris_get_last_update(uri_get_global(uri), &last_update);
if (error && error != -ENOENT)
- return error;
+ goto end;
}
error = download_file(uri, last_update, log_operation);
if (error < 0)
- return error;
+ goto end;
/* Request error, stop processing to handle as such */
if (error == EREQFAILED)
- return error;
+ goto end;
/*
* Mark as visited, if it doesn't exists yet, there's no problem since
*/
vis_err = db_rrdp_uris_set_request_status(uri_get_global(uri),
RRDP_URI_REQ_VISITED);
- if (vis_err && vis_err != -ENOENT)
- return pr_val_err("Couldn't mark '%s' as visited",
- uri_get_global(uri));
+ if (vis_err && vis_err != -ENOENT) {
+ error = pr_val_err("Couldn't mark file as visited.");
+ goto end;
+ }
/* No updates yet */
if (error > 0) {
delete_from_uri(uri, NULL);
*result = NULL;
- return 0;
+ error = 0;
+ goto end;
}
- fnstack_push_uri(uri);
error = parse_notification(uri, result);
- delete_from_uri(uri, NULL);
- if (error) {
- fnstack_pop();
- return error;
- }
- return 0;
+ delete_from_uri(uri, NULL);
+end: fnstack_pop();
+ return error;
}
int
if (error)
return error;
+ fnstack_push_uri(uri);
+
error = download_file(uri, 0, log_operation);
if (error)
goto release_uri;
delete_from_uri(uri, NULL);
/* Error 0 is ok */
release_uri:
+ fnstack_pop();
uri_refput(uri);
return error;
}
* Any pr_op_err()s and friends will now include the new file name.
* Use fnstack_pop() to revert back to the previously stacked file name.
* @file is not cloned; it's expected to outlive the push/pop operation.
+ *
+ * Sample usage:
+ *
+ * void
+ * test_fnstack(void)
+ * {
+ * fnstack_push("text.txt");
+ * pr_val_info("Message 1");
+ * fnstack_push("image.png");
+ * pr_val_info("Message 2");
+ * fnstack_pop();
+ * pr_val_info("Message 3");
+ * fnstack_pop();
+ * }
+ *
+ * Prints
+ *
+ * text.txt: Message 1
+ * image.png: Message 2
+ * text.txt: Message 3
*/
void
fnstack_push(char const *file)