mirror of
https://github.com/awslabs/aws-crt-php.git
synced 2026-08-19 02:23:09 +00:00
aws-crt-ffi v0.3.7 -> v0.3.8 (#112)
Also: replace uses of `aws_promise` (removed in https://github.com/awslabs/aws-c-common/pull/1110) with `aws_future`
This commit is contained in:
+9
-9
@@ -268,7 +268,7 @@ PHP_FUNCTION(aws_crt_signing_result_apply_to_http_request) {
|
||||
}
|
||||
|
||||
typedef struct _signing_state {
|
||||
struct aws_promise *promise;
|
||||
struct aws_future_void *future;
|
||||
zval *on_complete;
|
||||
aws_crt_signing_result *signing_result;
|
||||
int error_code;
|
||||
@@ -284,7 +284,7 @@ static void s_sign_aws_complete(void *data) {
|
||||
/* called from signing process in aws_sign_request_aws */
|
||||
static void s_on_sign_request_aws_complete(aws_crt_signing_result *result, int error_code, void *user_data) {
|
||||
signing_state *state = user_data;
|
||||
struct aws_promise *promise = state->promise;
|
||||
struct aws_future_void *future = state->future;
|
||||
|
||||
state->signing_result = result;
|
||||
state->error_code = error_code;
|
||||
@@ -301,9 +301,9 @@ static void s_on_sign_request_aws_complete(aws_crt_signing_result *result, int e
|
||||
aws_php_thread_queue_yield(&s_aws_php_main_thread_queue);
|
||||
|
||||
if (error_code) {
|
||||
aws_promise_fail(promise, error_code);
|
||||
aws_future_void_set_error(future, error_code);
|
||||
} else {
|
||||
aws_promise_complete(promise, result, NULL);
|
||||
aws_future_void_set_result(future);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,23 +318,23 @@ PHP_FUNCTION(aws_crt_sign_request_aws) {
|
||||
aws_crt_signable *signable = (void *)php_signable;
|
||||
aws_crt_signing_config_aws *signing_config = (void *)php_signing_config;
|
||||
|
||||
struct aws_promise *promise = aws_promise_new(aws_crt_default_allocator());
|
||||
struct aws_future_void *future = aws_future_void_new(aws_crt_default_allocator());
|
||||
signing_state state = {
|
||||
.promise = promise,
|
||||
.future = future,
|
||||
.on_complete = php_on_complete,
|
||||
};
|
||||
int ret = aws_crt_sign_request_aws(signable, signing_config, s_on_sign_request_aws_complete, &state);
|
||||
if (ret != 0) {
|
||||
int last_error = aws_crt_last_error();
|
||||
aws_promise_fail(promise, last_error);
|
||||
aws_future_void_set_error(future, last_error);
|
||||
aws_php_throw_exception(
|
||||
"aws_crt_sign_request_aws: error starting signing process: %s", aws_crt_error_name(last_error));
|
||||
}
|
||||
|
||||
aws_php_thread_queue_wait(&s_aws_php_main_thread_queue, promise);
|
||||
aws_php_thread_queue_wait(&s_aws_php_main_thread_queue, future);
|
||||
|
||||
done:
|
||||
aws_promise_release(promise);
|
||||
aws_future_void_release(future);
|
||||
RETURN_LONG(ret);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user