Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shutdown_callback or returning NULL contract for meta_request #440

Merged
merged 18 commits into from
Jun 20, 2024
7 changes: 6 additions & 1 deletion source/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,13 @@ struct aws_s3_meta_request *aws_s3_client_make_meta_request(
aws_error_str(aws_last_error()));

meta_request = aws_s3_meta_request_release(meta_request);
} else {
} else if (meta_request != NULL) {
waahm7 marked this conversation as resolved.
Show resolved Hide resolved
AWS_LOGF_INFO(AWS_LS_S3_CLIENT, "id=%p: Created meta request %p", (void *)client, (void *)meta_request);
/**
* shutdown_callback must be the last thing that gets set on the meta_request so that we don’t return NULL and
* trigger the shutdown_callback.
*/
meta_request->shutdown_callback = options->shutdown_callback;
graebm marked this conversation as resolved.
Show resolved Hide resolved
}

return meta_request;
Expand Down
1 change: 0 additions & 1 deletion source/s3_meta_request.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ int aws_s3_meta_request_init_base(

meta_request->meta_request_level_running_response_sum = NULL;
meta_request->user_data = options->user_data;
meta_request->shutdown_callback = options->shutdown_callback;
meta_request->progress_callback = options->progress_callback;
meta_request->telemetry_callback = options->telemetry_callback;
meta_request->upload_review_callback = options->upload_review_callback;
Expand Down
1 change: 1 addition & 0 deletions tests/s3_data_plane_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -5960,6 +5960,7 @@ static int s_test_s3_invalid_start_range_greator_than_end_range(struct aws_alloc

ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &options, &results));
ASSERT_INT_EQUALS(results.finished_error_code, AWS_ERROR_S3_INVALID_RANGE_HEADER);
ASSERT_INT_EQUALS(0, tester.synced_data.meta_request_finish_count);

aws_s3_meta_request_test_results_clean_up(&results);

Expand Down
3 changes: 2 additions & 1 deletion tests/s3_mock_server_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ TEST_CASE(endpoint_override_mock_server) {
.client = client,
.put_options =
{
.object_size_mb = 5, /* Make sure we have exactly 4 parts */
.object_size_mb = 5,
.object_path_override = object_path,
},
.mock_server = true,
Expand All @@ -956,6 +956,7 @@ TEST_CASE(endpoint_override_mock_server) {
put_options.message = message;
put_options.validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_FAILURE;
ASSERT_SUCCESS(aws_s3_tester_send_meta_request_with_options(&tester, &put_options, NULL));
ASSERT_INT_EQUALS(2, tester.synced_data.meta_request_shutdown_count);

/* Clean up */
aws_http_message_destroy(message);
Expand Down
4 changes: 3 additions & 1 deletion tests/s3_tester.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,9 +1686,11 @@ int aws_s3_tester_send_meta_request_with_options(
if (options->meta_request_type == AWS_S3_META_REQUEST_TYPE_PUT_OBJECT) {
/* Figure out how much is being uploaded from pre-existing message */
struct aws_input_stream *mystery_stream = aws_http_message_get_body_stream(meta_request_options.message);
int64_t mystery_stream_length = 0;
if (mystery_stream != NULL) {
ASSERT_SUCCESS(aws_input_stream_get_length(mystery_stream, (int64_t *)&upload_size_bytes));
ASSERT_SUCCESS(aws_input_stream_get_length(mystery_stream, (int64_t *)&mystery_stream_length));
}
upload_size_bytes = (size_t)mystery_stream_length;
}
}

Expand Down