Skip to content

Commit

Permalink
Removing need for lock for stream read (#69)
Browse files Browse the repository at this point in the history
* Moving stream read to next_request for now where it doesn't require a lock.

* Fixing up meta request cancel.

* Changing part size constants to be multiples of 8.

* Fixing pending request counter bug

* Fixing log reading from synced_data

* Fixing stream read bugs for default meta request.

* Adding mock bad input stream

Co-authored-by: Dengke Tang <[email protected]>
Co-authored-by: Dengke Tang <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2021
1 parent 5e34a65 commit ad7bb45
Show file tree
Hide file tree
Showing 12 changed files with 681 additions and 375 deletions.
16 changes: 9 additions & 7 deletions include/aws/s3/private/s3_auto_ranged_put.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,24 @@ enum aws_s3_auto_ranged_put_request_tag {
struct aws_s3_auto_ranged_put {
struct aws_s3_meta_request base;

/* Useable after the Create Multipart Upload request succeeds. */
struct aws_string *upload_id;

struct {
/* Only meant for use in the next_request function, which is never called concurrently. */
uint32_t next_part_number;
} threaded_next_request_data;

struct {
enum aws_s3_auto_ranged_put_state state;
struct aws_array_list etag_list;

uint32_t total_num_parts;
uint32_t next_part_number;
uint32_t num_parts_sent;
uint32_t num_parts_completed;

struct aws_string *upload_id;
struct aws_http_headers *needed_response_headers;

struct aws_s3_request *failed_request;
int finish_status_code;
int error_code;

struct aws_s3_meta_request_finish_options *cached_finish_options;
} synced_data;
};

Expand Down
2 changes: 1 addition & 1 deletion include/aws/s3/private/s3_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ void aws_s3_client_notify_connection_finished(
int error_code,
enum aws_s3_vip_connection_finish_code finish_code);

void aws_s3_client_notify_request_destroyed(struct aws_s3_client *client);
void aws_s3_client_notify_request_destroyed(struct aws_s3_client *client, struct aws_s3_request *request);

void aws_s3_client_stream_response_body(
struct aws_s3_client *client,
Expand Down
37 changes: 24 additions & 13 deletions include/aws/s3/private/s3_meta_request_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ typedef void(aws_s3_request_finished_callback_fn)(void *user_data);

enum aws_s3_meta_request_state {
AWS_S3_META_REQUEST_STATE_ACTIVE,
AWS_S3_META_REQUEST_STATE_CANCELLING,
AWS_S3_META_REQUEST_STATE_CANCELING,
AWS_S3_META_REQUEST_STATE_CANCELED,
AWS_S3_META_REQUEST_STATE_FINISHED,
};

Expand Down Expand Up @@ -107,6 +108,22 @@ struct aws_s3_request {
int response_status;

} send_data;

struct {
bool in_flight;
} client_data;
};

/* Options for finishing the meta request. */
struct aws_s3_meta_request_finish_options {

struct aws_http_headers *error_response_headers;

struct aws_byte_buf *error_response_body;

int response_status;

int error_code;
};

struct aws_s3_meta_request_vtable {
Expand Down Expand Up @@ -157,11 +174,7 @@ struct aws_s3_meta_request_vtable {
void (*notify_request_destroyed)(struct aws_s3_meta_request *meta_request, struct aws_s3_request *request);

/* Finish the meta request either succeed or failed. */
void (*finish)(
struct aws_s3_meta_request *,
struct aws_s3_request *failed_request,
int response_status,
int error_code);
void (*finish)(struct aws_s3_meta_request *meta_request, const struct aws_s3_meta_request_finish_options *options);

/* Handle de-allocation of the meta request. */
void (*destroy)(struct aws_s3_meta_request *);
Expand Down Expand Up @@ -204,10 +217,6 @@ struct aws_s3_meta_request {
* this reference is removed. */
struct aws_s3_client *client;

/* Body of stream of the initial_request_message. We store this here so that parts can take turns seeking to
* their own specific position (which should be in close proximity of one another). */
struct aws_input_stream *initial_body_stream;

/* Priority queue for pending streaming requests. We use a priority queue to keep parts in order so that we
* can stream them to the caller in order. */
struct aws_priority_queue pending_body_streaming_requests;
Expand Down Expand Up @@ -279,6 +288,10 @@ void aws_s3_meta_request_finish(
int response_status,
int error_code);

void aws_s3_meta_request_finish_with_options(
struct aws_s3_meta_request *meta_request,
const struct aws_s3_meta_request_finish_options *finish_options);

AWS_EXTERN_C_BEGIN

AWS_S3_API
Expand Down Expand Up @@ -349,9 +362,7 @@ int aws_s3_meta_request_sign_request_default(
AWS_S3_API
void aws_s3_meta_request_finish_default(
struct aws_s3_meta_request *meta_request,
struct aws_s3_request *failed_request,
int response_status,
int error_code);
const struct aws_s3_meta_request_finish_options *options);

AWS_S3_API
void aws_s3_meta_request_send_request_finish_default(
Expand Down
Loading

0 comments on commit ad7bb45

Please sign in to comment.