Skip to content

Commit 54d5c38

Browse files
committed
address comments
1 parent 287b507 commit 54d5c38

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

include/aws/s3/private/s3_request.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ struct aws_s3_request_metrics {
172172
bool memory_allocated_from_pool;
173173
} crt_info_metrics;
174174

175+
/* TODO: align the part info metrics with the others, eg: `aws_s3_mpu_part_info`. */
175176
struct {
176177
/* Beginning range of this part. */
177178
uint64_t part_range_start;

include/aws/s3/private/s3_util.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ int aws_s3_parse_content_range_response_header(
255255
uint64_t *out_object_size);
256256

257257
/* Given a Content-Range header value as a byte cursor, parses the range-start, range-end and
258-
* object-size. All output arguments are optional. This is an optimized version that doesn't
259-
* require string allocation. */
258+
* object-size. All output arguments are optional. */
260259
AWS_S3_API
261260
int aws_s3_parse_content_range_cursor(
262261
struct aws_byte_cursor content_range_cursor,

source/s3_auto_ranged_get.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -821,15 +821,14 @@ static void s_s3_auto_ranged_get_request_finished(
821821
/* No part size has been set from user. Now we use the optimal part size based on the throughput and memory
822822
* limit */
823823
uint64_t out_request_optimal_range_size = 0;
824-
int error = aws_s3_calculate_request_optimal_range_size(
825-
meta_request->client->optimal_range_size,
826-
auto_ranged_get->estimated_object_stored_part_size,
827-
&out_request_optimal_range_size);
828-
if (!error) {
824+
if (aws_s3_calculate_request_optimal_range_size(
825+
meta_request->client->optimal_range_size,
826+
auto_ranged_get->estimated_object_stored_part_size,
827+
&out_request_optimal_range_size) == AWS_OP_SUCCESS) {
829828
/* Override the part size to be optimal */
830829
*((size_t *)&meta_request->part_size) = (size_t)out_request_optimal_range_size;
831830
if (request->request_tag == AWS_S3_AUTO_RANGE_GET_REQUEST_TYPE_HEAD_OBJECT) {
832-
/* Update the first part size as well */
831+
/* Update the first part size as well, if we haven't made the request yet. */
833832
first_part_size = meta_request->part_size;
834833
}
835834
}

source/s3_util.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ int aws_s3_calculate_client_optimal_range_size(
844844
uint32_t max_connections,
845845
uint64_t *out_client_optimal_range_size) {
846846

847-
AWS_PRECONDITION(out_client_optimal_range_size);
847+
AWS_ERROR_PRECONDITION(out_client_optimal_range_size);
848848

849849
/* Validate input parameters */
850850
if (memory_limit_in_bytes == 0 || max_connections == 0) {
@@ -898,7 +898,7 @@ int aws_s3_calculate_request_optimal_range_size(
898898
uint64_t estimated_object_stored_part_size,
899899
uint64_t *out_request_optimal_range_size) {
900900

901-
AWS_PRECONDITION(out_request_optimal_range_size);
901+
AWS_ERROR_PRECONDITION(out_request_optimal_range_size);
902902

903903
/* Validate input parameters */
904904
if (client_optimal_range_size == 0) {
@@ -944,7 +944,7 @@ static bool s_is_quote_or_space_char(uint8_t c) {
944944

945945
int aws_s3_extract_parts_from_etag(struct aws_byte_cursor etag_header_value, uint32_t *out_num_parts) {
946946

947-
AWS_PRECONDITION(out_num_parts);
947+
AWS_ERROR_PRECONDITION(out_num_parts);
948948
/* Strip quotes if present (ETags often come wrapped in quotes) */
949949
struct aws_byte_cursor etag_cursor = aws_byte_cursor_trim_pred(&etag_header_value, s_is_quote_or_space_char);
950950

@@ -964,7 +964,10 @@ int aws_s3_extract_parts_from_etag(struct aws_byte_cursor etag_header_value, uin
964964
while (aws_byte_cursor_next_split(&remaining_cursor, '-', &substr)) {
965965
split_count++;
966966
if (split_count == 2) {
967-
/* The ETag should follow the pattern <hash>-<parts_count>, so the second part is the parts count. */
967+
/**
968+
* The ETag should follow the pattern <hash>-<parts_count>, so the second part is the parts count.
969+
* The S3 ETag will not have `-` in the hash value, as it's a HEX string.
970+
**/
968971
parts_count = substr;
969972
}
970973
if (split_count > 2) {

0 commit comments

Comments
 (0)