diff options
author | 2017-12-06 09:47:49 -0800 | |
---|---|---|
committer | 2017-12-06 09:47:49 -0800 | |
commit | 1d4e99508409be052bd129ba507bae1fbe7eb7fa (patch) | |
tree | 6a657f8c6179d873b34505cdc24bce9462ca68eb /src/core/tsi | |
parent | a3df36cc2505a89c2f481eea4a66a87b3002844a (diff) | |
parent | ad4d2dde0052efbbf49d64b0843c45f0381cfeb3 (diff) |
Merge pull request #13658 from grpc/revert-13058-execctx
Revert "All instances of exec_ctx being passed around in src/core removed"
Diffstat (limited to 'src/core/tsi')
-rw-r--r-- | src/core/tsi/fake_transport_security.cc | 17 | ||||
-rw-r--r-- | src/core/tsi/transport_security.h | 2 | ||||
-rw-r--r-- | src/core/tsi/transport_security_grpc.cc | 29 | ||||
-rw-r--r-- | src/core/tsi/transport_security_grpc.h | 22 |
4 files changed, 42 insertions, 28 deletions
diff --git a/src/core/tsi/fake_transport_security.cc b/src/core/tsi/fake_transport_security.cc index b907636f9d..f2f365fc0f 100644 --- a/src/core/tsi/fake_transport_security.cc +++ b/src/core/tsi/fake_transport_security.cc @@ -399,7 +399,8 @@ static const tsi_frame_protector_vtable frame_protector_vtable = { /* --- tsi_zero_copy_grpc_protector methods implementation. ---*/ static tsi_result fake_zero_copy_grpc_protector_protect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices, + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices) { if (self == nullptr || unprotected_slices == nullptr || protected_slices == nullptr) { @@ -423,7 +424,8 @@ static tsi_result fake_zero_copy_grpc_protector_protect( } static tsi_result fake_zero_copy_grpc_protector_unprotect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* protected_slices, grpc_slice_buffer* unprotected_slices) { if (self == nullptr || unprotected_slices == nullptr || protected_slices == nullptr) { @@ -452,18 +454,18 @@ static tsi_result fake_zero_copy_grpc_protector_unprotect( impl->parsed_frame_size - TSI_FAKE_FRAME_HEADER_SIZE, unprotected_slices); impl->parsed_frame_size = 0; - grpc_slice_buffer_reset_and_unref_internal(&impl->header_sb); + grpc_slice_buffer_reset_and_unref_internal(exec_ctx, &impl->header_sb); } return TSI_OK; } static void fake_zero_copy_grpc_protector_destroy( - tsi_zero_copy_grpc_protector* self) { + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self) { if (self == nullptr) return; tsi_fake_zero_copy_grpc_protector* impl = (tsi_fake_zero_copy_grpc_protector*)self; - grpc_slice_buffer_destroy_internal(&impl->header_sb); - grpc_slice_buffer_destroy_internal(&impl->protected_sb); + grpc_slice_buffer_destroy_internal(exec_ctx, &impl->header_sb); + grpc_slice_buffer_destroy_internal(exec_ctx, &impl->protected_sb); gpr_free(impl); } @@ -495,7 +497,8 @@ static tsi_result fake_handshaker_result_extract_peer( } static tsi_result fake_handshaker_result_create_zero_copy_grpc_protector( - const tsi_handshaker_result* self, size_t* max_output_protected_frame_size, + void* exec_ctx, const tsi_handshaker_result* self, + size_t* max_output_protected_frame_size, tsi_zero_copy_grpc_protector** protector) { *protector = tsi_create_fake_zero_copy_grpc_protector(max_output_protected_frame_size); diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h index ed662d48af..bf3a776b11 100644 --- a/src/core/tsi/transport_security.h +++ b/src/core/tsi/transport_security.h @@ -90,7 +90,7 @@ struct tsi_handshaker { typedef struct { tsi_result (*extract_peer)(const tsi_handshaker_result* self, tsi_peer* peer); tsi_result (*create_zero_copy_grpc_protector)( - const tsi_handshaker_result* self, + void* exec_ctx, const tsi_handshaker_result* self, size_t* max_output_protected_frame_size, tsi_zero_copy_grpc_protector** protector); tsi_result (*create_frame_protector)(const tsi_handshaker_result* self, diff --git a/src/core/tsi/transport_security_grpc.cc b/src/core/tsi/transport_security_grpc.cc index 76f7ae782f..875d367218 100644 --- a/src/core/tsi/transport_security_grpc.cc +++ b/src/core/tsi/transport_security_grpc.cc @@ -20,16 +20,18 @@ /* This method creates a tsi_zero_copy_grpc_protector object. */ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector( - const tsi_handshaker_result* self, size_t* max_output_protected_frame_size, + grpc_exec_ctx* exec_ctx, const tsi_handshaker_result* self, + size_t* max_output_protected_frame_size, tsi_zero_copy_grpc_protector** protector) { - if (self == nullptr || self->vtable == nullptr || protector == nullptr) { + if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr || + protector == nullptr) { return TSI_INVALID_ARGUMENT; } if (self->vtable->create_zero_copy_grpc_protector == nullptr) { return TSI_UNIMPLEMENTED; } return self->vtable->create_zero_copy_grpc_protector( - self, max_output_protected_frame_size, protector); + exec_ctx, self, max_output_protected_frame_size, protector); } /* --- tsi_zero_copy_grpc_protector common implementation. --- @@ -37,28 +39,33 @@ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector( Calls specific implementation after state/input validation. */ tsi_result tsi_zero_copy_grpc_protector_protect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices, + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices) { - if (self == nullptr || self->vtable == nullptr || + if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr || unprotected_slices == nullptr || protected_slices == nullptr) { return TSI_INVALID_ARGUMENT; } if (self->vtable->protect == nullptr) return TSI_UNIMPLEMENTED; - return self->vtable->protect(self, unprotected_slices, protected_slices); + return self->vtable->protect(exec_ctx, self, unprotected_slices, + protected_slices); } tsi_result tsi_zero_copy_grpc_protector_unprotect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* protected_slices, grpc_slice_buffer* unprotected_slices) { - if (self == nullptr || self->vtable == nullptr || + if (exec_ctx == nullptr || self == nullptr || self->vtable == nullptr || protected_slices == nullptr || unprotected_slices == nullptr) { return TSI_INVALID_ARGUMENT; } if (self->vtable->unprotect == nullptr) return TSI_UNIMPLEMENTED; - return self->vtable->unprotect(self, protected_slices, unprotected_slices); + return self->vtable->unprotect(exec_ctx, self, protected_slices, + unprotected_slices); } -void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self) { +void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx* exec_ctx, + tsi_zero_copy_grpc_protector* self) { if (self == nullptr) return; - self->vtable->destroy(self); + self->vtable->destroy(exec_ctx, self); } diff --git a/src/core/tsi/transport_security_grpc.h b/src/core/tsi/transport_security_grpc.h index 0156ff1c68..9fccfd79dd 100644 --- a/src/core/tsi/transport_security_grpc.h +++ b/src/core/tsi/transport_security_grpc.h @@ -26,7 +26,8 @@ assuming there is no fatal error. The caller is responsible for destroying the protector. */ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector( - const tsi_handshaker_result* self, size_t* max_output_protected_frame_size, + grpc_exec_ctx* exec_ctx, const tsi_handshaker_result* self, + size_t* max_output_protected_frame_size, tsi_zero_copy_grpc_protector** protector); /* -- tsi_zero_copy_grpc_protector object -- */ @@ -38,8 +39,8 @@ tsi_result tsi_handshaker_result_create_zero_copy_grpc_protector( - This method returns TSI_OK in case of success or a specific error code in case of failure. */ tsi_result tsi_zero_copy_grpc_protector_protect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices, - grpc_slice_buffer* protected_slices); + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices); /* Outputs unprotected bytes. - protected_slices is the bytes of protected frames. @@ -48,21 +49,24 @@ tsi_result tsi_zero_copy_grpc_protector_protect( there is not enough data to output in which case unprotected_slices has 0 bytes. */ tsi_result tsi_zero_copy_grpc_protector_unprotect( - tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, - grpc_slice_buffer* unprotected_slices); + grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self, + grpc_slice_buffer* protected_slices, grpc_slice_buffer* unprotected_slices); /* Destroys the tsi_zero_copy_grpc_protector object. */ -void tsi_zero_copy_grpc_protector_destroy(tsi_zero_copy_grpc_protector* self); +void tsi_zero_copy_grpc_protector_destroy(grpc_exec_ctx* exec_ctx, + tsi_zero_copy_grpc_protector* self); /* Base for tsi_zero_copy_grpc_protector implementations. */ typedef struct { - tsi_result (*protect)(tsi_zero_copy_grpc_protector* self, + tsi_result (*protect)(grpc_exec_ctx* exec_ctx, + tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* unprotected_slices, grpc_slice_buffer* protected_slices); - tsi_result (*unprotect)(tsi_zero_copy_grpc_protector* self, + tsi_result (*unprotect)(grpc_exec_ctx* exec_ctx, + tsi_zero_copy_grpc_protector* self, grpc_slice_buffer* protected_slices, grpc_slice_buffer* unprotected_slices); - void (*destroy)(tsi_zero_copy_grpc_protector* self); + void (*destroy)(grpc_exec_ctx* exec_ctx, tsi_zero_copy_grpc_protector* self); } tsi_zero_copy_grpc_protector_vtable; struct tsi_zero_copy_grpc_protector { |