Skip to content

Commit 108503e

Browse files
committed
Revert "Revert "DMC-1133: avoid trying streamed transfers if disabled, add copy mode to error messages""
This reverts commit 7e013ff.
1 parent 7e013ff commit 108503e

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/plugins/http/gfal_http_copy.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -646,22 +646,31 @@ int gfal_http_copy(plugin_handle plugin_data, gfal2_context_t context,
646646
set_copy_mode_from_urls(context,src_full, dst_full);
647647
// Initial copy mode
648648
CopyMode copy_mode = get_default_copy_mode(context);
649-
649+
650+
bool only_streaming = false;
650651
// If source is not even http, go straight to streamed
651652
// or if third party copy is disabled, go straight to streamed
652653
if (!is_http_scheme(src) || !is_http_3rdcopy_enabled(context)) {
653654
copy_mode = HTTP_COPY_STREAM;
655+
only_streaming = true;
654656
}
655657

656658
// Re-try different approaches
657659
int ret = 0;
660+
661+
CopyMode end_copy_mode = HTTP_COPY_END;
662+
663+
//if streaming is disabled stop the loop before
664+
if (!is_http_streamed_enabled(context)) {
665+
end_copy_mode = HTTP_COPY_STREAM;
666+
}
667+
658668
do {
659669
// The real, actual, copy
660670
plugin_trigger_event(params, http_plugin_domain,
661671
GFAL_EVENT_NONE, GFAL_EVENT_TRANSFER_ENTER,
662672
"%s => %s", src_full, dst_full);
663-
gfal2_log(G_LOG_LEVEL_MESSAGE,
664-
"Trying copying with mode %s",
673+
gfal2_log(G_LOG_LEVEL_MESSAGE, "Trying copying with mode %s",
665674
CopyModeStr[copy_mode]);
666675
plugin_trigger_event(params, http_plugin_domain,
667676
GFAL_EVENT_NONE, GFAL_EVENT_TRANSFER_TYPE,
@@ -675,7 +684,8 @@ int gfal_http_copy(plugin_handle plugin_data, gfal2_context_t context,
675684
checksum_mode, checksum_type, user_checksum,
676685
params, &nested_error);
677686
}
678-
else {
687+
else if (only_streaming) {
688+
ret = -1;
679689
gfalt_set_error(&nested_error, http_plugin_domain, EIO, __func__,
680690
GFALT_ERROR_TRANSFER, "STREAMED DISABLED",
681691
"Trying to fallback to a streamed copy, but they are disabled");
@@ -691,18 +701,17 @@ int gfal_http_copy(plugin_handle plugin_data, gfal2_context_t context,
691701
break;
692702
}
693703
else if (ret < 0) {
694-
695-
plugin_trigger_event(params, http_plugin_domain,
696-
GFAL_EVENT_NONE, GFAL_EVENT_TRANSFER_EXIT,
697-
"ERROR: Copy failed with mode %s, with error: %s",
698-
CopyModeStr[copy_mode], nested_error->message);
704+
g_prefix_error(&nested_error, "ERROR: Copy failed with mode %s, with error: ",CopyModeStr[copy_mode]);
705+
plugin_trigger_event(params, http_plugin_domain,
706+
GFAL_EVENT_NONE, GFAL_EVENT_TRANSFER_EXIT,
707+
nested_error->message);
699708
// Delete any potential destination file.
700-
gfal_http_copy_cleanup(plugin_data, dst, &nested_error);
709+
gfal_http_copy_cleanup(plugin_data, dst, &nested_error);
701710
}
702711

703712
copy_mode = (CopyMode)((int)copy_mode + 1);
704713

705-
} while ((copy_mode < HTTP_COPY_END) && is_http_3rdcopy_fallback_enabled(context));
714+
} while ((copy_mode < end_copy_mode) && is_http_3rdcopy_fallback_enabled(context));
706715

707716

708717
plugin_trigger_event(params, http_plugin_domain,

0 commit comments

Comments
 (0)