diff options
author | dvshkurko <dvshkurko@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:45:52 +0300 |
commit | c768a99151e47c3a4bb7b92c514d256abd301c4d (patch) | |
tree | 1a2c5ffcf89eb53ecd79dbc9bc0a195c27404d0c /contrib/libs/grpc/include | |
parent | 321ee9bce31ec6e238be26dbcbe539cffa2c3309 (diff) | |
download | ydb-c768a99151e47c3a4bb7b92c514d256abd301c4d.tar.gz |
Restoring authorship annotation for <dvshkurko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/grpc/include')
58 files changed, 2198 insertions, 2198 deletions
diff --git a/contrib/libs/grpc/include/grpc/grpc.h b/contrib/libs/grpc/include/grpc/grpc.h index 847cc6fceb..6001117521 100644 --- a/contrib/libs/grpc/include/grpc/grpc.h +++ b/contrib/libs/grpc/include/grpc/grpc.h @@ -76,11 +76,11 @@ GRPCAPI void grpc_init(void); Before it's called, there should haven been a matching invocation to grpc_init(). - The last call to grpc_shutdown will initiate cleaning up of grpc library - internals, which can happen in another thread. Once the clean-up is done, - no memory is used by grpc, nor are any instructions executing within the - grpc library. Prior to calling, all application owned grpc objects must - have been destroyed. */ + The last call to grpc_shutdown will initiate cleaning up of grpc library + internals, which can happen in another thread. Once the clean-up is done, + no memory is used by grpc, nor are any instructions executing within the + grpc library. Prior to calling, all application owned grpc objects must + have been destroyed. */ GRPCAPI void grpc_shutdown(void); /** EXPERIMENTAL. Returns 1 if the grpc library has been initialized. @@ -89,10 +89,10 @@ GRPCAPI void grpc_shutdown(void); https://github.com/grpc/grpc/issues/15334 */ GRPCAPI int grpc_is_initialized(void); -/** EXPERIMENTAL. Blocking shut down grpc library. - This is only for wrapped language to use now. */ -GRPCAPI void grpc_shutdown_blocking(void); - +/** EXPERIMENTAL. Blocking shut down grpc library. + This is only for wrapped language to use now. */ +GRPCAPI void grpc_shutdown_blocking(void); + /** Return a string representing the current version of grpc */ GRPCAPI const char* grpc_version_string(void); @@ -222,7 +222,7 @@ GRPCAPI grpc_call* grpc_channel_create_call( grpc_completion_queue* completion_queue, grpc_slice method, const grpc_slice* host, gpr_timespec deadline, void* reserved); -/** Pre-register a method/host pair on a channel. +/** Pre-register a method/host pair on a channel. method and host are not owned and must remain alive while the channel is alive. */ GRPCAPI void* grpc_channel_register_call(grpc_channel* channel, @@ -323,14 +323,14 @@ GRPCAPI void grpc_channel_destroy(grpc_channel* channel); If a grpc_call fails, it's guaranteed that no change to the call state has been made. */ -/** Cancel an RPC. +/** Cancel an RPC. Can be called multiple times, from any thread. THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status are thread-safe, and can be called at any point before grpc_call_unref is called.*/ GRPCAPI grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved); -/** Cancel an RPC. +/** Cancel an RPC. Can be called multiple times, from any thread. If a status has not been received for the call, set it to the status code and description passed in. diff --git a/contrib/libs/grpc/include/grpc/grpc_security.h b/contrib/libs/grpc/include/grpc/grpc_security.h index 3e79c1a33a..1810681b76 100644 --- a/contrib/libs/grpc/include/grpc/grpc_security.h +++ b/contrib/libs/grpc/include/grpc/grpc_security.h @@ -191,28 +191,28 @@ typedef struct { const char* cert_chain; } grpc_ssl_pem_key_cert_pair; -/** Deprecated in favor of grpc_ssl_verify_peer_options. It will be removed - after all of its call sites are migrated to grpc_ssl_verify_peer_options. - Object that holds additional peer-verification options on a secure - channel. */ -typedef struct { - /** If non-NULL this callback will be invoked with the expected - target_name, the peer's certificate (in PEM format), and whatever - userdata pointer is set below. If a non-zero value is returned by this - callback then it is treated as a verification failure. Invocation of - the callback is blocking, so any implementation should be light-weight. - */ - int (*verify_peer_callback)(const char* target_name, const char* peer_pem, - void* userdata); - /** Arbitrary userdata that will be passed as the last argument to - verify_peer_callback. */ - void* verify_peer_callback_userdata; - /** A destruct callback that will be invoked when the channel is being - cleaned up. The userdata argument will be passed to it. The intent is - to perform any cleanup associated with that userdata. */ - void (*verify_peer_destruct)(void* userdata); -} verify_peer_options; - +/** Deprecated in favor of grpc_ssl_verify_peer_options. It will be removed + after all of its call sites are migrated to grpc_ssl_verify_peer_options. + Object that holds additional peer-verification options on a secure + channel. */ +typedef struct { + /** If non-NULL this callback will be invoked with the expected + target_name, the peer's certificate (in PEM format), and whatever + userdata pointer is set below. If a non-zero value is returned by this + callback then it is treated as a verification failure. Invocation of + the callback is blocking, so any implementation should be light-weight. + */ + int (*verify_peer_callback)(const char* target_name, const char* peer_pem, + void* userdata); + /** Arbitrary userdata that will be passed as the last argument to + verify_peer_callback. */ + void* verify_peer_callback_userdata; + /** A destruct callback that will be invoked when the channel is being + cleaned up. The userdata argument will be passed to it. The intent is + to perform any cleanup associated with that userdata. */ + void (*verify_peer_destruct)(void* userdata); +} verify_peer_options; + /** Object that holds additional peer-verification options on a secure channel. */ typedef struct { @@ -231,11 +231,11 @@ typedef struct { cleaned up. The userdata argument will be passed to it. The intent is to perform any cleanup associated with that userdata. */ void (*verify_peer_destruct)(void* userdata); -} grpc_ssl_verify_peer_options; +} grpc_ssl_verify_peer_options; -/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be - removed after all of its call sites are migrated to - grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object. +/** Deprecated in favor of grpc_ssl_server_credentials_create_ex. It will be + removed after all of its call sites are migrated to + grpc_ssl_server_credentials_create_ex. Creates an SSL credentials object. The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - pem_root_certs is the NULL-terminated string containing the PEM encoding of the server root certificates. If this parameter is NULL, the @@ -244,15 +244,15 @@ typedef struct { try to get the roots set by grpc_override_ssl_default_roots. Eventually, if all these fail, it will try to get the roots from a well-known place on disk (in the grpc install directory). - - gRPC has implemented root cache if the underlying OpenSSL library supports - it. The gRPC root certificates cache is only applicable on the default - root certificates, which is used when this parameter is nullptr. If user - provides their own pem_root_certs, when creating an SSL credential object, - gRPC would not be able to cache it, and each subchannel will generate a - copy of the root store. So it is recommended to avoid providing large room - pem with pem_root_certs parameter to avoid excessive memory consumption, - particularly on mobile platforms such as iOS. + + gRPC has implemented root cache if the underlying OpenSSL library supports + it. The gRPC root certificates cache is only applicable on the default + root certificates, which is used when this parameter is nullptr. If user + provides their own pem_root_certs, when creating an SSL credential object, + gRPC would not be able to cache it, and each subchannel will generate a + copy of the root store. So it is recommended to avoid providing large room + pem with pem_root_certs parameter to avoid excessive memory consumption, + particularly on mobile platforms such as iOS. - pem_key_cert_pair is a pointer on the object containing client's private key and certificate chain. This parameter can be NULL if the client does not have such a key/cert pair. @@ -267,38 +267,38 @@ GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, const verify_peer_options* verify_options, void* reserved); -/* Creates an SSL credentials object. +/* Creates an SSL credentials object. The security level of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - - pem_root_certs is the NULL-terminated string containing the PEM encoding - of the server root certificates. If this parameter is NULL, the - implementation will first try to dereference the file pointed by the - GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, - try to get the roots set by grpc_override_ssl_default_roots. Eventually, - if all these fail, it will try to get the roots from a well-known place on - disk (in the grpc install directory). - - gRPC has implemented root cache if the underlying OpenSSL library supports - it. The gRPC root certificates cache is only applicable on the default - root certificates, which is used when this parameter is nullptr. If user - provides their own pem_root_certs, when creating an SSL credential object, - gRPC would not be able to cache it, and each subchannel will generate a - copy of the root store. So it is recommended to avoid providing large room - pem with pem_root_certs parameter to avoid excessive memory consumption, - particularly on mobile platforms such as iOS. - - pem_key_cert_pair is a pointer on the object containing client's private - key and certificate chain. This parameter can be NULL if the client does - not have such a key/cert pair. - - verify_options is an optional verify_peer_options object which holds - additional options controlling how peer certificates are verified. For - example, you can supply a callback which receives the peer's certificate - with which you can do additional verification. Can be NULL, in which - case verification will retain default behavior. Any settings in - verify_options are copied during this call, so the verify_options - object can be released afterwards. */ -GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create_ex( - const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, - const grpc_ssl_verify_peer_options* verify_options, void* reserved); - + - pem_root_certs is the NULL-terminated string containing the PEM encoding + of the server root certificates. If this parameter is NULL, the + implementation will first try to dereference the file pointed by the + GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment variable, and if that fails, + try to get the roots set by grpc_override_ssl_default_roots. Eventually, + if all these fail, it will try to get the roots from a well-known place on + disk (in the grpc install directory). + + gRPC has implemented root cache if the underlying OpenSSL library supports + it. The gRPC root certificates cache is only applicable on the default + root certificates, which is used when this parameter is nullptr. If user + provides their own pem_root_certs, when creating an SSL credential object, + gRPC would not be able to cache it, and each subchannel will generate a + copy of the root store. So it is recommended to avoid providing large room + pem with pem_root_certs parameter to avoid excessive memory consumption, + particularly on mobile platforms such as iOS. + - pem_key_cert_pair is a pointer on the object containing client's private + key and certificate chain. This parameter can be NULL if the client does + not have such a key/cert pair. + - verify_options is an optional verify_peer_options object which holds + additional options controlling how peer certificates are verified. For + example, you can supply a callback which receives the peer's certificate + with which you can do additional verification. Can be NULL, in which + case verification will retain default behavior. Any settings in + verify_options are copied during this call, so the verify_options + object can be released afterwards. */ +GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + const grpc_ssl_verify_peer_options* verify_options, void* reserved); + /** Creates a composite channel credentials object. The security level of * resulting connection is determined by channel_creds. */ GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create( @@ -340,7 +340,7 @@ GRPCAPI grpc_call_credentials* grpc_google_refresh_token_credentials_create( const char* json_refresh_token, void* reserved); /** Creates an Oauth2 Access Token credentials with an access token that was - acquired by an out of band mechanism. */ + acquired by an out of band mechanism. */ GRPCAPI grpc_call_credentials* grpc_access_token_credentials_create( const char* access_token, void* reserved); @@ -349,31 +349,31 @@ GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( const char* authorization_token, const char* authority_selector, void* reserved); -/** Options for creating STS Oauth Token Exchange credentials following the IETF - draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - Optional fields may be set to NULL or empty string. It is the responsibility - of the caller to ensure that the subject and actor tokens are refreshed on - disk at the specified paths. This API is used for experimental purposes for - now and may change in the future. */ -typedef struct { - const char* token_exchange_service_uri; /* Required. */ - const char* resource; /* Optional. */ - const char* audience; /* Optional. */ - const char* scope; /* Optional. */ - const char* requested_token_type; /* Optional. */ - const char* subject_token_path; /* Required. */ - const char* subject_token_type; /* Required. */ - const char* actor_token_path; /* Optional. */ - const char* actor_token_type; /* Optional. */ -} grpc_sts_credentials_options; - -/** Creates an STS credentials following the STS Token Exchanged specifed in the - IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. - This API is used for experimental purposes for now and may change in the - future. */ -GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( - const grpc_sts_credentials_options* options, void* reserved); - +/** Options for creating STS Oauth Token Exchange credentials following the IETF + draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + Optional fields may be set to NULL or empty string. It is the responsibility + of the caller to ensure that the subject and actor tokens are refreshed on + disk at the specified paths. This API is used for experimental purposes for + now and may change in the future. */ +typedef struct { + const char* token_exchange_service_uri; /* Required. */ + const char* resource; /* Optional. */ + const char* audience; /* Optional. */ + const char* scope; /* Optional. */ + const char* requested_token_type; /* Optional. */ + const char* subject_token_path; /* Required. */ + const char* subject_token_type; /* Required. */ + const char* actor_token_path; /* Optional. */ + const char* actor_token_type; /* Optional. */ +} grpc_sts_credentials_options; + +/** Creates an STS credentials following the STS Token Exchanged specifed in the + IETF draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. + This API is used for experimental purposes for now and may change in the + future. */ +GRPCAPI grpc_call_credentials* grpc_sts_credentials_create( + const grpc_sts_credentials_options* options, void* reserved); + /** Callback function to be called by the metadata credentials plugin implementation when the metadata is ready. - user_data is the opaque pointer that was passed in the get_metadata method @@ -550,7 +550,7 @@ GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create( /** Deprecated in favor of grpc_ssl_server_credentials_create_with_options. Same as grpc_ssl_server_credentials_create method except uses grpc_ssl_client_certificate_request_type enum to support more ways to - authenticate client certificates.*/ + authenticate client certificates.*/ GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex( const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, @@ -763,7 +763,7 @@ typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; /** Create an empty TLS credentials options. It is used for * experimental purpose for now and subject to change. */ -GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void); +GRPCAPI grpc_tls_credentials_options* grpc_tls_credentials_options_create(void); /** Set grpc_ssl_client_certificate_request_type field in credentials options with the provided type. options should not be NULL. @@ -818,8 +818,8 @@ GRPCAPI int grpc_tls_credentials_options_set_server_authorization_check_config( /** Create an empty grpc_tls_key_materials_config instance. * It is used for experimental purpose for now and subject to change. */ -GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create( - void); +GRPCAPI grpc_tls_key_materials_config* grpc_tls_key_materials_config_create( + void); /** Set grpc_tls_key_materials_config instance with provided a TLS certificate. It's valid for the caller to provide nullptr pem_root_certs, in which case @@ -835,21 +835,21 @@ GRPCAPI int grpc_tls_key_materials_config_set_key_materials( const grpc_ssl_pem_key_cert_pair** pem_key_cert_pairs, size_t num_key_cert_pairs); -/** Set grpc_tls_key_materials_config instance with a provided version number, - which is used to keep track of the version of key materials. - It returns 1 on success and 0 on failure. It is used for - experimental purpose for now and subject to change. - */ -GRPCAPI int grpc_tls_key_materials_config_set_version( - grpc_tls_key_materials_config* config, int version); - -/** Get the version number of a grpc_tls_key_materials_config instance. - It returns the version number on success and -1 on failure. - It is used for experimental purpose for now and subject to change. - */ -GRPCAPI int grpc_tls_key_materials_config_get_version( - grpc_tls_key_materials_config* config); - +/** Set grpc_tls_key_materials_config instance with a provided version number, + which is used to keep track of the version of key materials. + It returns 1 on success and 0 on failure. It is used for + experimental purpose for now and subject to change. + */ +GRPCAPI int grpc_tls_key_materials_config_set_version( + grpc_tls_key_materials_config* config, int version); + +/** Get the version number of a grpc_tls_key_materials_config instance. + It returns the version number on success and -1 on failure. + It is used for experimental purpose for now and subject to change. + */ +GRPCAPI int grpc_tls_key_materials_config_get_version( + grpc_tls_key_materials_config* config); + /** --- TLS credential reload config. --- It is used for experimental purpose for now and subject to change.*/ @@ -862,34 +862,34 @@ typedef struct grpc_tls_credential_reload_arg grpc_tls_credential_reload_arg; typedef void (*grpc_tls_on_credential_reload_done_cb)( grpc_tls_credential_reload_arg* arg); -/** A struct containing all information necessary to schedule/cancel a - credential reload request. - - cb and cb_user_data represent a gRPC-provided - callback and an argument passed to it. - - key_materials_config is an in/output parameter containing currently +/** A struct containing all information necessary to schedule/cancel a + credential reload request. + - cb and cb_user_data represent a gRPC-provided + callback and an argument passed to it. + - key_materials_config is an in/output parameter containing currently used/newly reloaded credentials. If credential reload does not result in a new credential, key_materials_config should not be modified. The same key_materials_config object can be updated if new key materials is available. - - status and error_details are used to hold information about - errors occurred when a credential reload request is scheduled/cancelled. - - config is a pointer to the unique grpc_tls_credential_reload_config - instance that this argument corresponds to. - - context is a pointer to a wrapped language implementation of this - grpc_tls_credential_reload_arg instance. - - destroy_context is a pointer to a caller-provided method that cleans - up any data associated with the context pointer. - It is used for experimental purposes for now and subject to change. -*/ + - status and error_details are used to hold information about + errors occurred when a credential reload request is scheduled/cancelled. + - config is a pointer to the unique grpc_tls_credential_reload_config + instance that this argument corresponds to. + - context is a pointer to a wrapped language implementation of this + grpc_tls_credential_reload_arg instance. + - destroy_context is a pointer to a caller-provided method that cleans + up any data associated with the context pointer. + It is used for experimental purposes for now and subject to change. +*/ struct grpc_tls_credential_reload_arg { grpc_tls_on_credential_reload_done_cb cb; void* cb_user_data; grpc_tls_key_materials_config* key_materials_config; - grpc_ssl_certificate_config_reload_status status; + grpc_ssl_certificate_config_reload_status status; grpc_tls_error_details* error_details; - grpc_tls_credential_reload_config* config; - void* context; - void (*destroy_context)(void* ctx); + grpc_tls_credential_reload_config* config; + void* context; + void (*destroy_context)(void* ctx); }; /** Create a grpc_tls_credential_reload_config instance. @@ -935,39 +935,39 @@ typedef void (*grpc_tls_on_server_authorization_check_done_cb)( grpc_tls_server_authorization_check_arg* arg); /** A struct containing all information necessary to schedule/cancel a server - authorization check request. - - cb and cb_user_data represent a gRPC-provided callback and an argument - passed to it. - - success will store the result of server authorization check. That is, - if success returns a non-zero value, it means the authorization check - passes and if returning zero, it means the check fails. - - target_name is the name of an endpoint the channel is connecting to. - - peer_cert represents a complete certificate chain including both - signing and leaf certificates. - - status and error_details contain information - about errors occurred when a server authorization check request is - scheduled/cancelled. - - config is a pointer to the unique - grpc_tls_server_authorization_check_config instance that this argument - corresponds to. - - context is a pointer to a wrapped language implementation of this - grpc_tls_server_authorization_check_arg instance. - - destroy_context is a pointer to a caller-provided method that cleans - up any data associated with the context pointer. - It is used for experimental purpose for now and subject to change. -*/ + authorization check request. + - cb and cb_user_data represent a gRPC-provided callback and an argument + passed to it. + - success will store the result of server authorization check. That is, + if success returns a non-zero value, it means the authorization check + passes and if returning zero, it means the check fails. + - target_name is the name of an endpoint the channel is connecting to. + - peer_cert represents a complete certificate chain including both + signing and leaf certificates. + - status and error_details contain information + about errors occurred when a server authorization check request is + scheduled/cancelled. + - config is a pointer to the unique + grpc_tls_server_authorization_check_config instance that this argument + corresponds to. + - context is a pointer to a wrapped language implementation of this + grpc_tls_server_authorization_check_arg instance. + - destroy_context is a pointer to a caller-provided method that cleans + up any data associated with the context pointer. + It is used for experimental purpose for now and subject to change. +*/ struct grpc_tls_server_authorization_check_arg { grpc_tls_on_server_authorization_check_done_cb cb; void* cb_user_data; - int success; + int success; const char* target_name; const char* peer_cert; const char* peer_cert_full_chain; grpc_status_code status; grpc_tls_error_details* error_details; - grpc_tls_server_authorization_check_config* config; - void* context; - void (*destroy_context)(void* ctx); + grpc_tls_server_authorization_check_config* config; + void* context; + void (*destroy_context)(void* ctx); }; /** Create a grpc_tls_server_authorization_check_config instance. @@ -999,36 +999,36 @@ grpc_tls_server_authorization_check_config_create( grpc_tls_server_authorization_check_arg* arg), void (*destruct)(void* config_user_data)); -/** +/** * This method creates a TLS channel credential object. * It takes ownership of the options parameter. The security level * of the resulting connection is GRPC_PRIVACY_AND_INTEGRITY. - * - * - options: grpc TLS credentials options instance. - * - * It returns the created credential object. - * - * It is used for experimental purpose for now and subject - * to change. - */ - + * + * - options: grpc TLS credentials options instance. + * + * It returns the created credential object. + * + * It is used for experimental purpose for now and subject + * to change. + */ + grpc_channel_credentials* grpc_tls_credentials_create( - grpc_tls_credentials_options* options); - -/** - * This method creates a TLS server credential object. - * It takes ownership of the options parameter. - * - * - options: grpc TLS credentials options instance. - * - * It returns the created credential object. - * - * It is used for experimental purpose for now and subject - * to change. - */ + grpc_tls_credentials_options* options); + +/** + * This method creates a TLS server credential object. + * It takes ownership of the options parameter. + * + * - options: grpc TLS credentials options instance. + * + * It returns the created credential object. + * + * It is used for experimental purpose for now and subject + * to change. + */ grpc_server_credentials* grpc_tls_server_credentials_create( - grpc_tls_credentials_options* options); - + grpc_tls_credentials_options* options); + /** * EXPERIMENTAL API - Subject to change * diff --git a/contrib/libs/grpc/include/grpc/grpc_security_constants.h b/contrib/libs/grpc/include/grpc/grpc_security_constants.h index 47619ca4da..a62f76753b 100644 --- a/contrib/libs/grpc/include/grpc/grpc_security_constants.h +++ b/contrib/libs/grpc/include/grpc/grpc_security_constants.h @@ -99,7 +99,7 @@ typedef enum { /** Server requests client certificate and enforces that the client presents a certificate. - The certificate presented by the client is verified by the gRPC framework. + The certificate presented by the client is verified by the gRPC framework. (For a successful connection the client needs to present a certificate that can be verified against the root certificate configured by the server) diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/byte_buffer.h b/contrib/libs/grpc/include/grpc/impl/codegen/byte_buffer.h index 540243d478..1247906815 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/byte_buffer.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/byte_buffer.h @@ -73,19 +73,19 @@ GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader); GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, grpc_slice* slice); -/** EXPERIMENTAL API - This function may be removed and changed, in the future. - * - * Updates \a slice with the next piece of data from from \a reader and returns - * 1. Returns 0 at the end of the stream. Caller is responsible for making sure - * the slice pointer remains valid when accessed. - * - * NOTE: Do not use this function unless the caller can guarantee that the - * underlying grpc_byte_buffer outlasts the use of the slice. This is only - * safe when the underlying grpc_byte_buffer remains immutable while slice - * is being accessed. */ -GRPCAPI int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, - grpc_slice** slice); - +/** EXPERIMENTAL API - This function may be removed and changed, in the future. + * + * Updates \a slice with the next piece of data from from \a reader and returns + * 1. Returns 0 at the end of the stream. Caller is responsible for making sure + * the slice pointer remains valid when accessed. + * + * NOTE: Do not use this function unless the caller can guarantee that the + * underlying grpc_byte_buffer outlasts the use of the slice. This is only + * safe when the underlying grpc_byte_buffer remains immutable while slice + * is being accessed. */ +GRPCAPI int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, + grpc_slice** slice); + /** Merge all data from \a reader into single slice */ GRPCAPI grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader); diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/gpr_types.h b/contrib/libs/grpc/include/grpc/impl/codegen/gpr_types.h index 87ace73eb0..6daf339861 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/gpr_types.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/gpr_types.h @@ -48,7 +48,7 @@ typedef struct gpr_timespec { int64_t tv_sec; int32_t tv_nsec; /** Against which clock was this time measured? (or GPR_TIMESPAN if - this is a relative time measure) */ + this is a relative time measure) */ gpr_clock_type clock_type; } gpr_timespec; diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/grpc_types.h b/contrib/libs/grpc/include/grpc/impl/codegen/grpc_types.h index e3ca197c5d..07066f0e1d 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/grpc_types.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/grpc_types.h @@ -157,9 +157,9 @@ typedef struct { /** Maximum message length that the channel can send. Int valued, bytes. -1 means unlimited. */ #define GRPC_ARG_MAX_SEND_MESSAGE_LENGTH "grpc.max_send_message_length" -/** Maximum time that a channel may have no outstanding rpcs, after which the - * server will close the connection. Int valued, milliseconds. INT_MAX means - * unlimited. */ +/** Maximum time that a channel may have no outstanding rpcs, after which the + * server will close the connection. Int valued, milliseconds. INT_MAX means + * unlimited. */ #define GRPC_ARG_MAX_CONNECTION_IDLE_MS "grpc.max_connection_idle_ms" /** Maximum time that a channel may exist. Int valued, milliseconds. * INT_MAX means unlimited. */ @@ -167,10 +167,10 @@ typedef struct { /** Grace period after the channel reaches its max age. Int valued, milliseconds. INT_MAX means unlimited. */ #define GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS "grpc.max_connection_age_grace_ms" -/** Timeout after the last RPC finishes on the client channel at which the - * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means - * unlimited. The default value is 30 minutes and the min value is 1 second. */ -#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" +/** Timeout after the last RPC finishes on the client channel at which the + * channel goes back into IDLE state. Int valued, milliseconds. INT_MAX means + * unlimited. The default value is 30 minutes and the min value is 1 second. */ +#define GRPC_ARG_CLIENT_IDLE_TIMEOUT_MS "grpc.client_idle_timeout_ms" /** Enable/disable support for per-message compression. Defaults to 1, unless GRPC_ARG_MINIMAL_STACK is enabled, in which case it defaults to 0. */ #define GRPC_ARG_ENABLE_PER_MESSAGE_COMPRESSION "grpc.per_message_compression" @@ -273,14 +273,14 @@ typedef struct { grpc_ssl_session_cache*). (use grpc_ssl_session_cache_arg_vtable() to fetch an appropriate pointer arg vtable) */ #define GRPC_SSL_SESSION_CACHE_ARG "grpc.ssl_session_cache" -/** If non-zero, it will determine the maximum frame size used by TSI's frame - * protector. - * - * NOTE: Be aware that using a large "max_frame_size" is memory inefficient - * for non-zerocopy protectors. Also, increasing this value above 1MiB - * can break old binaries that don't support larger than 1MiB frame - * size. */ -#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" +/** If non-zero, it will determine the maximum frame size used by TSI's frame + * protector. + * + * NOTE: Be aware that using a large "max_frame_size" is memory inefficient + * for non-zerocopy protectors. Also, increasing this value above 1MiB + * can break old binaries that don't support larger than 1MiB frame + * size. */ +#define GRPC_ARG_TSI_MAX_FRAME_SIZE "grpc.tsi.max_frame_size" /** Maximum metadata size, in bytes. Note this limit applies to the max sum of all metadata key-value entries in a batch of headers. */ #define GRPC_ARG_MAX_METADATA_SIZE "grpc.max_metadata_size" @@ -348,7 +348,7 @@ typedef struct { #define GRPC_ARG_GRPCLB_CALL_TIMEOUT_MS "grpc.grpclb_call_timeout_ms" /* Timeout in milliseconds to wait for the serverlist from the grpclb load balancer before using fallback backend addresses from the resolver. - If 0, enter fallback mode immediately. Default value is 10000. */ + If 0, enter fallback mode immediately. Default value is 10000. */ #define GRPC_ARG_GRPCLB_FALLBACK_TIMEOUT_MS "grpc.grpclb_fallback_timeout_ms" /* Timeout in milliseconds to wait for the child of a specific priority to complete its initial connection attempt before the priority LB policy fails @@ -396,12 +396,12 @@ typedef struct { * load balancing policy. Note that this only works with the "ares" * DNS resolver, and isn't supported by the "native" DNS resolver. */ #define GRPC_ARG_DNS_ENABLE_SRV_QUERIES "grpc.dns_enable_srv_queries" -/** If set, determines an upper bound on the number of milliseconds that the - * c-ares based DNS resolver will wait on queries before cancelling them. - * The default value is 120,000. Setting this to "0" will disable the - * overall timeout entirely. Note that this doesn't include internal c-ares - * timeouts/backoff/retry logic, and so the actual DNS resolution may time out - * sooner than the value specified here. */ +/** If set, determines an upper bound on the number of milliseconds that the + * c-ares based DNS resolver will wait on queries before cancelling them. + * The default value is 120,000. Setting this to "0" will disable the + * overall timeout entirely. Note that this doesn't include internal c-ares + * timeouts/backoff/retry logic, and so the actual DNS resolution may time out + * sooner than the value specified here. */ #define GRPC_ARG_DNS_ARES_QUERY_TIMEOUT_MS "grpc.dns_ares_query_timeout" /** If set, uses a local subchannel pool within the channel. Otherwise, uses the * global subchannel pool. */ @@ -533,8 +533,8 @@ typedef struct grpc_event { field is guaranteed to be 0 */ int success; /** The tag passed to grpc_call_start_batch etc to start this operation. - *Only* GRPC_OP_COMPLETE has a tag. For all other grpc_completion_type - values, tag is uninitialized. */ + *Only* GRPC_OP_COMPLETE has a tag. For all other grpc_completion_type + values, tag is uninitialized. */ void* tag; } grpc_event; @@ -740,10 +740,10 @@ typedef struct grpc_experimental_completion_queue_functor { operation succeeded (non-zero) or failed (zero) */ void (*functor_run)(struct grpc_experimental_completion_queue_functor*, int); - /** The inlineable member specifies whether this functor can be run inline. - This should only be used for trivial internally-defined functors. */ - int inlineable; - + /** The inlineable member specifies whether this functor can be run inline. + This should only be used for trivial internally-defined functors. */ + int inlineable; + /** The following fields are not API. They are meant for internal use. */ int internal_success; struct grpc_experimental_completion_queue_functor* internal_next; diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/port_platform.h b/contrib/libs/grpc/include/grpc/impl/codegen/port_platform.h index bc9246307a..35419f017b 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/port_platform.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/port_platform.h @@ -27,7 +27,7 @@ * - some syscalls to be made directly */ -/* +/* * Defines GPR_ABSEIL_SYNC to use synchronization features from Abseil */ #ifndef GPR_ABSEIL_SYNC @@ -132,7 +132,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #define GPR_SUPPORT_CHANNELS_FROM_FD 1 #elif defined(__linux__) @@ -159,7 +159,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 @@ -173,26 +173,26 @@ #else /* musl libc */ #define GPR_MUSL_LIBC_COMPAT 1 #endif -#elif defined(__ASYLO__) -#define GPR_ARCH_64 1 -#define GPR_CPU_POSIX 1 -#define GPR_GCC_TLS 1 -#define GPR_PLATFORM_STRING "asylo" -#define GPR_GCC_SYNC 1 -#define GPR_POSIX_SYNC 1 -#define GPR_POSIX_STRING 1 -#define GPR_POSIX_LOG 1 -#define GPR_POSIX_TIME 1 -#define GPR_POSIX_ENV 1 -#define GPR_ASYLO 1 -#define GRPC_POSIX_SOCKET 1 -#define GRPC_POSIX_SOCKETADDR -#define GRPC_POSIX_SOCKETUTILS 1 -#define GRPC_TIMER_USE_GENERIC 1 -#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 -#define GRPC_POSIX_WAKEUP_FD 1 -#define GRPC_ARES 0 -#define GPR_NO_AUTODETECT_PLATFORM 1 +#elif defined(__ASYLO__) +#define GPR_ARCH_64 1 +#define GPR_CPU_POSIX 1 +#define GPR_GCC_TLS 1 +#define GPR_PLATFORM_STRING "asylo" +#define GPR_GCC_SYNC 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_STRING 1 +#define GPR_POSIX_LOG 1 +#define GPR_POSIX_TIME 1 +#define GPR_POSIX_ENV 1 +#define GPR_ASYLO 1 +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKETADDR +#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_TIMER_USE_GENERIC 1 +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#define GRPC_POSIX_WAKEUP_FD 1 +#define GRPC_ARES 0 +#define GPR_NO_AUTODETECT_PLATFORM 1 #elif defined(__APPLE__) #include <Availability.h> #include <TargetConditionals.h> @@ -203,8 +203,8 @@ #define GPR_PLATFORM_STRING "ios" #define GPR_CPU_IPHONE 1 #define GPR_PTHREAD_TLS 1 -#define GRPC_CFSTREAM 1 -/* the c-ares resolver isn't safe to enable on iOS */ +#define GRPC_CFSTREAM 1 +/* the c-ares resolver isn't safe to enable on iOS */ #define GRPC_ARES 0 #else /* TARGET_OS_IPHONE */ #define GPR_PLATFORM_STRING "osx" @@ -245,7 +245,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifndef GRPC_CFSTREAM #define GPR_SUPPORT_CHANNELS_FROM_FD 1 @@ -271,7 +271,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #define GPR_SUPPORT_CHANNELS_FROM_FD 1 #ifdef _LP64 @@ -295,7 +295,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #define GPR_SUPPORT_CHANNELS_FROM_FD 1 #ifdef _LP64 @@ -316,7 +316,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 @@ -339,7 +339,7 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 @@ -368,52 +368,52 @@ #define GPR_POSIX_SUBPROCESS 1 #define GPR_POSIX_SYNC 1 #define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 +#define GPR_HAS_PTHREAD_H 1 #define GPR_GETPID_IN_UNISTD_H 1 #ifdef _LP64 #define GPR_ARCH_64 1 #else /* _LP64 */ #define GPR_ARCH_32 1 #endif /* _LP64 */ -#elif defined(__Fuchsia__) -#define GPR_FUCHSIA 1 -#define GPR_ARCH_64 1 -#define GPR_PLATFORM_STRING "fuchsia" -#include <features.h> -// Specifying musl libc affects wrap_memcpy.c. It causes memmove() to be -// invoked. -#define GPR_MUSL_LIBC_COMPAT 1 -#define GPR_CPU_POSIX 1 -#define GPR_GCC_ATOMIC 1 -#define GPR_PTHREAD_TLS 1 -#define GPR_POSIX_LOG 1 -#define GPR_POSIX_SYNC 1 -#define GPR_POSIX_ENV 1 -#define GPR_POSIX_TMPFILE 1 -#define GPR_POSIX_SUBPROCESS 1 -#define GPR_POSIX_SYNC 1 -#define GPR_POSIX_STRING 1 -#define GPR_POSIX_TIME 1 -#define GPR_HAS_PTHREAD_H 1 -#define GPR_GETPID_IN_UNISTD_H 1 +#elif defined(__Fuchsia__) +#define GPR_FUCHSIA 1 +#define GPR_ARCH_64 1 +#define GPR_PLATFORM_STRING "fuchsia" +#include <features.h> +// Specifying musl libc affects wrap_memcpy.c. It causes memmove() to be +// invoked. +#define GPR_MUSL_LIBC_COMPAT 1 +#define GPR_CPU_POSIX 1 +#define GPR_GCC_ATOMIC 1 +#define GPR_PTHREAD_TLS 1 +#define GPR_POSIX_LOG 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_ENV 1 +#define GPR_POSIX_TMPFILE 1 +#define GPR_POSIX_SUBPROCESS 1 +#define GPR_POSIX_SYNC 1 +#define GPR_POSIX_STRING 1 +#define GPR_POSIX_TIME 1 +#define GPR_HAS_PTHREAD_H 1 +#define GPR_GETPID_IN_UNISTD_H 1 #else #error "Could not auto-detect platform" #endif #endif /* GPR_NO_AUTODETECT_PLATFORM */ -#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) +#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE) +/* + * For backward compatibility mode, reset _FORTIFY_SOURCE to prevent + * a library from having non-standard symbols such as __asprintf_chk. + * This helps non-glibc systems such as alpine using musl to find symbols. + */ +#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 +#undef _FORTIFY_SOURCE +#define _FORTIFY_SOURCE 0 +#endif +#endif + /* - * For backward compatibility mode, reset _FORTIFY_SOURCE to prevent - * a library from having non-standard symbols such as __asprintf_chk. - * This helps non-glibc systems such as alpine using musl to find symbols. - */ -#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 -#undef _FORTIFY_SOURCE -#define _FORTIFY_SOURCE 0 -#endif -#endif - -/* * There are platforms for which TLS should not be used even though the * compiler makes it seem like it's supported (Android NDK < r12b for example). * This is primarily because of linker problems and toolchain misconfiguration: @@ -470,23 +470,23 @@ typedef unsigned __int64 uint64_t; #include <stdint.h> #endif /* _MSC_VER */ -/* Type of cycle clock implementation */ -#ifdef GPR_LINUX -/* Disable cycle clock by default. - TODO(soheil): enable when we support fallback for unstable cycle clocks. -#if defined(__i386__) -#define GPR_CYCLE_COUNTER_RDTSC_32 1 -#elif defined(__x86_64__) || defined(__amd64__) -#define GPR_CYCLE_COUNTER_RDTSC_64 1 -#else -#define GPR_CYCLE_COUNTER_FALLBACK 1 -#endif -*/ -#define GPR_CYCLE_COUNTER_FALLBACK 1 -#else -#define GPR_CYCLE_COUNTER_FALLBACK 1 -#endif /* GPR_LINUX */ - +/* Type of cycle clock implementation */ +#ifdef GPR_LINUX +/* Disable cycle clock by default. + TODO(soheil): enable when we support fallback for unstable cycle clocks. +#if defined(__i386__) +#define GPR_CYCLE_COUNTER_RDTSC_32 1 +#elif defined(__x86_64__) || defined(__amd64__) +#define GPR_CYCLE_COUNTER_RDTSC_64 1 +#else +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#endif +*/ +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#else +#define GPR_CYCLE_COUNTER_FALLBACK 1 +#endif /* GPR_LINUX */ + /* Cache line alignment */ #ifndef GPR_CACHELINE_SIZE_LOG #if defined(__i386__) || defined(__x86_64__) @@ -600,14 +600,14 @@ typedef unsigned __int64 uint64_t; #endif #endif /* GPR_HAS_ATTRIBUTE */ -#ifndef GPR_HAS_FEATURE -#ifdef __has_feature -#define GPR_HAS_FEATURE(a) __has_feature(a) -#else -#define GPR_HAS_FEATURE(a) 0 -#endif -#endif /* GPR_HAS_FEATURE */ - +#ifndef GPR_HAS_FEATURE +#ifdef __has_feature +#define GPR_HAS_FEATURE(a) __has_feature(a) +#else +#define GPR_HAS_FEATURE(a) 0 +#endif +#endif /* GPR_HAS_FEATURE */ + #ifndef GPR_ATTRIBUTE_NOINLINE #if GPR_HAS_ATTRIBUTE(noinline) || (defined(__GNUC__) && !defined(__clang__)) #define GPR_ATTRIBUTE_NOINLINE __attribute__((noinline)) @@ -630,9 +630,9 @@ typedef unsigned __int64 uint64_t; #endif /* GPR_ATTRIBUTE_WEAK */ #ifndef GPR_ATTRIBUTE_NO_TSAN /* (1) */ -#if GPR_HAS_FEATURE(thread_sanitizer) +#if GPR_HAS_FEATURE(thread_sanitizer) #define GPR_ATTRIBUTE_NO_TSAN __attribute__((no_sanitize("thread"))) -#endif /* GPR_HAS_FEATURE */ +#endif /* GPR_HAS_FEATURE */ #ifndef GPR_ATTRIBUTE_NO_TSAN /* (2) */ #define GPR_ATTRIBUTE_NO_TSAN #endif /* GPR_ATTRIBUTE_NO_TSAN (2) */ @@ -642,30 +642,30 @@ typedef unsigned __int64 uint64_t; #ifndef GRPC_TSAN_SUPPRESSED #if defined(__SANITIZE_THREAD__) #define GRPC_TSAN_ENABLED -#elif GPR_HAS_FEATURE(thread_sanitizer) +#elif GPR_HAS_FEATURE(thread_sanitizer) #define GRPC_TSAN_ENABLED #endif #endif - -/* GRPC_ASAN_ENABLED will be defined, when compiled with address sanitizer. */ + +/* GRPC_ASAN_ENABLED will be defined, when compiled with address sanitizer. */ #ifndef GRPC_ASAN_SUPPRESSED -#if defined(__SANITIZE_ADDRESS__) -#define GRPC_ASAN_ENABLED -#elif GPR_HAS_FEATURE(address_sanitizer) -#define GRPC_ASAN_ENABLED +#if defined(__SANITIZE_ADDRESS__) +#define GRPC_ASAN_ENABLED +#elif GPR_HAS_FEATURE(address_sanitizer) +#define GRPC_ASAN_ENABLED #endif #endif /* GRPC_ALLOW_EXCEPTIONS should be 0 or 1 if exceptions are allowed or not */ #ifndef GRPC_ALLOW_EXCEPTIONS #ifdef GPR_WINDOWS -#if defined(_MSC_VER) && defined(_CPPUNWIND) +#if defined(_MSC_VER) && defined(_CPPUNWIND) +#define GRPC_ALLOW_EXCEPTIONS 1 +#elif defined(__EXCEPTIONS) #define GRPC_ALLOW_EXCEPTIONS 1 -#elif defined(__EXCEPTIONS) -#define GRPC_ALLOW_EXCEPTIONS 1 -#else -#define GRPC_ALLOW_EXCEPTIONS 0 -#endif +#else +#define GRPC_ALLOW_EXCEPTIONS 0 +#endif #else /* GPR_WINDOWS */ #ifdef __EXCEPTIONS #define GRPC_ALLOW_EXCEPTIONS 1 diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/slice.h b/contrib/libs/grpc/include/grpc/impl/codegen/slice.h index 8c6d29ef1d..3567b1e88b 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/slice.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/slice.h @@ -47,7 +47,7 @@ typedef struct grpc_slice grpc_slice; #define GRPC_SLICE_INLINED_SIZE \ (sizeof(size_t) + sizeof(uint8_t*) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE) -struct grpc_slice_refcount; +struct grpc_slice_refcount; /** A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/status.h b/contrib/libs/grpc/include/grpc/impl/codegen/status.h index 15c8f8271e..dec3b8f340 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/status.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/status.h @@ -128,8 +128,8 @@ typedef enum { /** The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with - a backoff. Note that it is not always safe to retry non-idempotent - operations. + a backoff. Note that it is not always safe to retry non-idempotent + operations. WARNING: Although data MIGHT not have been transmitted when this status occurs, there is NOT A GUARANTEE that the server has not seen diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/sync_generic.h b/contrib/libs/grpc/include/grpc/impl/codegen/sync_generic.h index 3970bb0fe9..eabdc513f4 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/sync_generic.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/sync_generic.h @@ -18,7 +18,7 @@ #ifndef GRPC_IMPL_CODEGEN_SYNC_GENERIC_H #define GRPC_IMPL_CODEGEN_SYNC_GENERIC_H -/* Generic type definitions for gpr_sync. */ +/* Generic type definitions for gpr_sync. */ #include <grpc/impl/codegen/port_platform.h> diff --git a/contrib/libs/grpc/include/grpc/impl/codegen/sync_posix.h b/contrib/libs/grpc/include/grpc/impl/codegen/sync_posix.h index 8436855d0b..2aec3a3f8d 100644 --- a/contrib/libs/grpc/include/grpc/impl/codegen/sync_posix.h +++ b/contrib/libs/grpc/include/grpc/impl/codegen/sync_posix.h @@ -25,26 +25,26 @@ #include <pthread.h> -#ifdef GRPC_ASAN_ENABLED -/* The member |leak_checker| is used to check whether there is a memory leak - * caused by upper layer logic that's missing the |gpr_xx_destroy| call - * to the object before freeing it. - * This issue was reported at https://github.com/grpc/grpc/issues/17563 - * and discussed at https://github.com/grpc/grpc/pull/17586 - */ -typedef struct { - pthread_mutex_t mutex; - int* leak_checker; -} gpr_mu; - -typedef struct { - pthread_cond_t cond_var; - int* leak_checker; -} gpr_cv; -#else +#ifdef GRPC_ASAN_ENABLED +/* The member |leak_checker| is used to check whether there is a memory leak + * caused by upper layer logic that's missing the |gpr_xx_destroy| call + * to the object before freeing it. + * This issue was reported at https://github.com/grpc/grpc/issues/17563 + * and discussed at https://github.com/grpc/grpc/pull/17586 + */ +typedef struct { + pthread_mutex_t mutex; + int* leak_checker; +} gpr_mu; + +typedef struct { + pthread_cond_t cond_var; + int* leak_checker; +} gpr_cv; +#else typedef pthread_mutex_t gpr_mu; typedef pthread_cond_t gpr_cv; -#endif +#endif typedef pthread_once_t gpr_once; #define GPR_ONCE_INIT PTHREAD_ONCE_INIT diff --git a/contrib/libs/grpc/include/grpc/slice.h b/contrib/libs/grpc/include/grpc/slice.h index 1c6283dba6..51fc62b44d 100644 --- a/contrib/libs/grpc/include/grpc/slice.h +++ b/contrib/libs/grpc/include/grpc/slice.h @@ -107,7 +107,7 @@ GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end); /** Splits s into two: modifies s to be s[0:split], and returns a new slice, sharing a refcount with s, that contains s[split:s.length]. - Requires s initialized, split <= s.length */ + Requires s initialized, split <= s.length */ GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split); typedef enum { @@ -124,7 +124,7 @@ GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* s, size_t split, /** Splits s into two: modifies s to be s[split:s.length], and returns a new slice, sharing a refcount with s, that contains s[0:split]. - Requires s initialized, split <= s.length */ + Requires s initialized, split <= s.length */ GPRAPI grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split); GPRAPI grpc_slice grpc_empty_slice(void); @@ -147,7 +147,7 @@ GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t blen); GPRAPI int grpc_slice_rchr(grpc_slice s, char c); GPRAPI int grpc_slice_chr(grpc_slice s, char c); -/** return the index of the first occurrence of \a needle in \a haystack, or -1 +/** return the index of the first occurrence of \a needle in \a haystack, or -1 if it's not found */ GPRAPI int grpc_slice_slice(grpc_slice haystack, grpc_slice needle); diff --git a/contrib/libs/grpc/include/grpcpp/channel.h b/contrib/libs/grpc/include/grpcpp/channel.h index 6b1ca6f8b5..6a31ff7aa9 100644 --- a/contrib/libs/grpc/include/grpcpp/channel.h +++ b/contrib/libs/grpc/include/grpcpp/channel.h @@ -32,7 +32,7 @@ struct grpc_channel; -namespace grpc { +namespace grpc { namespace testing { class ChannelTestPeer; } // namespace testing diff --git a/contrib/libs/grpc/include/grpcpp/create_channel_posix.h b/contrib/libs/grpc/include/grpcpp/create_channel_posix.h index 23747d34a8..c6755b0aa6 100644 --- a/contrib/libs/grpc/include/grpcpp/create_channel_posix.h +++ b/contrib/libs/grpc/include/grpcpp/create_channel_posix.h @@ -55,7 +55,7 @@ namespace experimental { /// \param args Options for channel creation. /// \param interceptor_creators Vector of interceptor factory objects. std::shared_ptr<grpc::Channel> -CreateCustomInsecureChannelWithInterceptorsFromFd( +CreateCustomInsecureChannelWithInterceptorsFromFd( const TString& target, int fd, const grpc::ChannelArguments& args, std::unique_ptr<std::vector< std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>>> diff --git a/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin.h b/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin.h index 05e5a78004..95cb93e321 100644 --- a/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin.h +++ b/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin.h @@ -19,15 +19,15 @@ #ifndef GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H #define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_H -#include <grpcpp/ext/channelz_service_plugin_impl.h> +#include <grpcpp/ext/channelz_service_plugin_impl.h> namespace grpc { namespace channelz { namespace experimental { -static inline void InitChannelzService() { - ::grpc_impl::channelz::experimental::InitChannelzService(); -} +static inline void InitChannelzService() { + ::grpc_impl::channelz::experimental::InitChannelzService(); +} } // namespace experimental } // namespace channelz diff --git a/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin_impl.h b/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin_impl.h index e0fe7b79ae..3a5f3c4b99 100644 --- a/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin_impl.h +++ b/contrib/libs/grpc/include/grpcpp/ext/channelz_service_plugin_impl.h @@ -1,41 +1,41 @@ -/* - * - * Copyright 2018 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H -#define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H - -#include <grpc/support/port_platform.h> - -#include <grpcpp/impl/server_builder_plugin.h> -#include <grpcpp/impl/server_initializer.h> -#include <grpcpp/support/config.h> - -namespace grpc_impl { -namespace channelz { -namespace experimental { - -/// Add channelz server plugin to \a ServerBuilder. This function should -/// be called at static initialization time. This service is experimental -/// for now. Track progress in https://github.com/grpc/grpc/issues/15988. -void InitChannelzService(); - -} // namespace experimental -} // namespace channelz -} // namespace grpc_impl - -#endif // GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H +/* + * + * Copyright 2018 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H +#define GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H + +#include <grpc/support/port_platform.h> + +#include <grpcpp/impl/server_builder_plugin.h> +#include <grpcpp/impl/server_initializer.h> +#include <grpcpp/support/config.h> + +namespace grpc_impl { +namespace channelz { +namespace experimental { + +/// Add channelz server plugin to \a ServerBuilder. This function should +/// be called at static initialization time. This service is experimental +/// for now. Track progress in https://github.com/grpc/grpc/issues/15988. +void InitChannelzService(); + +} // namespace experimental +} // namespace channelz +} // namespace grpc_impl + +#endif // GRPCPP_EXT_CHANNELZ_SERVICE_PLUGIN_IMPL_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/async_generic_service.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/async_generic_service.h index 48f3eea31d..a812b086a2 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/async_generic_service.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/async_generic_service.h @@ -24,7 +24,7 @@ #include <grpcpp/impl/codegen/async_stream.h> #include <grpcpp/impl/codegen/byte_buffer.h> #include <grpcpp/impl/codegen/server_callback.h> -#include <grpcpp/impl/codegen/server_callback_handlers.h> +#include <grpcpp/impl/codegen/server_callback_handlers.h> struct grpc_server; @@ -80,62 +80,62 @@ class AsyncGenericService final { }; #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL -namespace experimental { +namespace experimental { #endif - -/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs -/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with -/// ByteBuffer arguments. + +/// \a ServerGenericBidiReactor is the reactor class for bidi streaming RPCs +/// invoked on a CallbackGenericService. It is just a ServerBidi reactor with +/// ByteBuffer arguments. using ServerGenericBidiReactor = ServerBidiReactor<ByteBuffer, ByteBuffer>; - + class GenericCallbackServerContext final : public grpc::CallbackServerContext { - public: + public: const TString& method() const { return method_; } const TString& host() const { return host_; } - - private: + + private: friend class ::grpc::Server; - + TString method_; TString host_; -}; - -/// \a CallbackGenericService is the base class for generic services implemented -/// using the callback API and registered through the ServerBuilder using -/// RegisterCallbackGenericService. -class CallbackGenericService { - public: - CallbackGenericService() {} - virtual ~CallbackGenericService() {} - - /// The "method handler" for the generic API. This function should be - /// overridden to provide a ServerGenericBidiReactor that implements the - /// application-level interface for this RPC. Unimplemented by default. - virtual ServerGenericBidiReactor* CreateReactor( - GenericCallbackServerContext* /*ctx*/) { - class Reactor : public ServerGenericBidiReactor { - public: - Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } - void OnDone() override { delete this; } - }; - return new Reactor; - } - - private: +}; + +/// \a CallbackGenericService is the base class for generic services implemented +/// using the callback API and registered through the ServerBuilder using +/// RegisterCallbackGenericService. +class CallbackGenericService { + public: + CallbackGenericService() {} + virtual ~CallbackGenericService() {} + + /// The "method handler" for the generic API. This function should be + /// overridden to provide a ServerGenericBidiReactor that implements the + /// application-level interface for this RPC. Unimplemented by default. + virtual ServerGenericBidiReactor* CreateReactor( + GenericCallbackServerContext* /*ctx*/) { + class Reactor : public ServerGenericBidiReactor { + public: + Reactor() { this->Finish(Status(StatusCode::UNIMPLEMENTED, "")); } + void OnDone() override { delete this; } + }; + return new Reactor; + } + + private: friend class grpc::Server; - + internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>* Handler() { return new internal::CallbackBidiHandler<ByteBuffer, ByteBuffer>( [this](::grpc::CallbackServerContext* ctx) { - return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx)); - }); - } - + return CreateReactor(static_cast<GenericCallbackServerContext*>(ctx)); + }); + } + grpc::Server* server_{nullptr}; -}; +}; #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL -} // namespace experimental +} // namespace experimental #endif } // namespace grpc diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/async_unary_call.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/async_unary_call.h index abbd645b06..3deeda8c7f 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/async_unary_call.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/async_unary_call.h @@ -30,7 +30,7 @@ namespace grpc { /// An interface relevant for async client side unary RPCs (which send /// one request message to a server and receive one response message). -template <class R> +template <class R> class ClientAsyncResponseReaderInterface { public: virtual ~ClientAsyncResponseReaderInterface() {} diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/byte_buffer.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/byte_buffer.h index d8b63e33af..6e64ec9981 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/byte_buffer.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/byte_buffer.h @@ -35,22 +35,22 @@ class ServerInterface; class ByteBuffer; class ServerInterface; -namespace internal { -template <class RequestType, class ResponseType> -class CallbackUnaryHandler; -template <class RequestType, class ResponseType> -class CallbackServerStreamingHandler; -template <class ServiceType, class RequestType, class ResponseType> -class RpcMethodHandler; -template <class ServiceType, class RequestType, class ResponseType> -class ServerStreamingHandler; -template <::grpc::StatusCode code> -class ErrorMethodHandler; +namespace internal { +template <class RequestType, class ResponseType> +class CallbackUnaryHandler; +template <class RequestType, class ResponseType> +class CallbackServerStreamingHandler; +template <class ServiceType, class RequestType, class ResponseType> +class RpcMethodHandler; +template <class ServiceType, class RequestType, class ResponseType> +class ServerStreamingHandler; +template <::grpc::StatusCode code> +class ErrorMethodHandler; class CallOpSendMessage; template <class R> class CallOpRecvMessage; class CallOpGenericRecvMessage; -class ExternalConnectionAcceptorImpl; +class ExternalConnectionAcceptorImpl; template <class R> class DeserializeFuncType; class GrpcByteBufferPeer; @@ -92,7 +92,7 @@ class ByteBuffer final { /// \a buf. Wrapper of core function grpc_byte_buffer_copy . This is not /// a deep copy; it is just a referencing. As a result, its performance is /// size-independent. - ByteBuffer(const ByteBuffer& buf) : buffer_(nullptr) { operator=(buf); } + ByteBuffer(const ByteBuffer& buf) : buffer_(nullptr) { operator=(buf); } ~ByteBuffer() { if (buffer_) { @@ -103,16 +103,16 @@ class ByteBuffer final { /// Wrapper of core function grpc_byte_buffer_copy . This is not /// a deep copy; it is just a referencing. As a result, its performance is /// size-independent. - ByteBuffer& operator=(const ByteBuffer& buf) { - if (this != &buf) { - Clear(); // first remove existing data - } - if (buf.buffer_) { - // then copy - buffer_ = g_core_codegen_interface->grpc_byte_buffer_copy(buf.buffer_); - } - return *this; - } + ByteBuffer& operator=(const ByteBuffer& buf) { + if (this != &buf) { + Clear(); // first remove existing data + } + if (buf.buffer_) { + // then copy + buffer_ = g_core_codegen_interface->grpc_byte_buffer_copy(buf.buffer_); + } + return *this; + } /// Dump (read) the buffer contents into \a slices. Status Dump(std::vector<Slice>* slices) const; @@ -177,7 +177,7 @@ class ByteBuffer final { friend class ProtoBufferReader; friend class ProtoBufferWriter; friend class internal::GrpcByteBufferPeer; - friend class internal::ExternalConnectionAcceptorImpl; + friend class internal::ExternalConnectionAcceptorImpl; grpc_byte_buffer* buffer_; @@ -217,7 +217,7 @@ class SerializationTraits<ByteBuffer, void> { bool* own_buffer) { *buffer = source; *own_buffer = true; - return g_core_codegen_interface->ok(); + return g_core_codegen_interface->ok(); } }; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/call_op_set.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/call_op_set.h index f47b20eab4..379333164a 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/call_op_set.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/call_op_set.h @@ -27,8 +27,8 @@ #include <map> #include <memory> -#include <grpc/impl/codegen/compression_types.h> -#include <grpc/impl/codegen/grpc_types.h> +#include <grpc/impl/codegen/compression_types.h> +#include <grpc/impl/codegen/grpc_types.h> #include <grpcpp/impl/codegen/byte_buffer.h> #include <grpcpp/impl/codegen/call.h> #include <grpcpp/impl/codegen/call_hook.h> @@ -86,9 +86,9 @@ class WriteOptions { WriteOptions(const WriteOptions& other) : flags_(other.flags_), last_message_(other.last_message_) {} - /// Default assignment operator - WriteOptions& operator=(const WriteOptions& other) = default; - + /// Default assignment operator + WriteOptions& operator=(const WriteOptions& other) = default; + /// Clear all flags. inline void Clear() { flags_ = 0; } @@ -208,14 +208,14 @@ namespace internal { template <int Unused> class CallNoOp { protected: - void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {} - void FinishOp(bool* /*status*/) {} + void AddOp(grpc_op* /*ops*/, size_t* /*nops*/) {} + void FinishOp(bool* /*status*/) {} void SetInterceptionHookPoint( - InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { - } + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + } }; class CallOpSendInitialMetadata { @@ -255,7 +255,7 @@ class CallOpSendInitialMetadata { maybe_compression_level_.level; } } - void FinishOp(bool* /*status*/) { + void FinishOp(bool* /*status*/) { if (!send_ || hijacked_) return; g_core_codegen_interface->gpr_free(initial_metadata_); send_ = false; @@ -270,9 +270,9 @@ class CallOpSendInitialMetadata { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -366,7 +366,7 @@ class CallOpSendMessage { nullptr); } - void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -592,7 +592,7 @@ class CallOpGenericRecvMessage { interceptor_methods->AddInterceptionHookPoint( experimental::InterceptionHookPoints::POST_RECV_MESSAGE); if (!got_message) interceptor_methods->SetRecvMessage(nullptr, nullptr); - deserialize_.reset(); + deserialize_.reset(); } void SetHijackingState(InterceptorBatchMethodsImpl* interceptor_methods) { hijacked_ = true; @@ -633,7 +633,7 @@ class CallOpClientSendClose { op->flags = 0; op->reserved = NULL; } - void FinishOp(bool* /*status*/) { send_ = false; } + void FinishOp(bool* /*status*/) { send_ = false; } void SetInterceptionHookPoint( InterceptorBatchMethodsImpl* interceptor_methods) { @@ -643,9 +643,9 @@ class CallOpClientSendClose { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -686,7 +686,7 @@ class CallOpServerSendStatus { op->reserved = NULL; } - void FinishOp(bool* /*status*/) { + void FinishOp(bool* /*status*/) { if (!send_status_available_ || hijacked_) return; g_core_codegen_interface->gpr_free(trailing_metadata_); send_status_available_ = false; @@ -703,9 +703,9 @@ class CallOpServerSendStatus { } void SetFinishInterceptionHookPoint( - InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} + InterceptorBatchMethodsImpl* /*interceptor_methods*/) {} - void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { + void SetHijackingState(InterceptorBatchMethodsImpl* /*interceptor_methods*/) { hijacked_ = true; } @@ -740,7 +740,7 @@ class CallOpRecvInitialMetadata { op->reserved = NULL; } - void FinishOp(bool* /*status*/) { + void FinishOp(bool* /*status*/) { if (metadata_map_ == nullptr || hijacked_) return; } @@ -794,26 +794,26 @@ class CallOpClientRecvStatus { op->reserved = NULL; } - void FinishOp(bool* /*status*/) { + void FinishOp(bool* /*status*/) { if (recv_status_ == nullptr || hijacked_) return; - if (static_cast<StatusCode>(status_code_) == StatusCode::OK) { - *recv_status_ = Status(); - GPR_CODEGEN_DEBUG_ASSERT(debug_error_string_ == nullptr); - } else { - *recv_status_ = - Status(static_cast<StatusCode>(status_code_), - GRPC_SLICE_IS_EMPTY(error_message_) + if (static_cast<StatusCode>(status_code_) == StatusCode::OK) { + *recv_status_ = Status(); + GPR_CODEGEN_DEBUG_ASSERT(debug_error_string_ == nullptr); + } else { + *recv_status_ = + Status(static_cast<StatusCode>(status_code_), + GRPC_SLICE_IS_EMPTY(error_message_) ? TString() : TString(reinterpret_cast<const char*>GRPC_SLICE_START_PTR(error_message_), reinterpret_cast<const char*>GRPC_SLICE_END_PTR(error_message_)), - metadata_map_->GetBinaryErrorDetails()); - if (debug_error_string_ != nullptr) { - client_context_->set_debug_error_string(debug_error_string_); - g_core_codegen_interface->gpr_free((void*)debug_error_string_); - } - } - // TODO(soheil): Find callers that set debug string even for status OK, - // and fix them. + metadata_map_->GetBinaryErrorDetails()); + if (debug_error_string_ != nullptr) { + client_context_->set_debug_error_string(debug_error_string_); + g_core_codegen_interface->gpr_free((void*)debug_error_string_); + } + } + // TODO(soheil): Find callers that set debug string even for status OK, + // and fix them. g_core_codegen_interface->grpc_slice_unref(error_message_); } @@ -964,29 +964,29 @@ class CallOpSet : public CallOpSetInterface, this->Op4::AddOp(ops, &nops); this->Op5::AddOp(ops, &nops); this->Op6::AddOp(ops, &nops); - - grpc_call_error err = g_core_codegen_interface->grpc_call_start_batch( - call_.call(), ops, nops, core_cq_tag(), nullptr); - - if (err != GRPC_CALL_OK) { - // A failure here indicates an API misuse; for example, doing a Write - // while another Write is already pending on the same RPC or invoking - // WritesDone multiple times - // gpr_log(GPR_ERROR, "API misuse of type %s observed", - // g_core_codegen_interface->grpc_call_error_to_string(err)); - GPR_CODEGEN_ASSERT(false); - } + + grpc_call_error err = g_core_codegen_interface->grpc_call_start_batch( + call_.call(), ops, nops, core_cq_tag(), nullptr); + + if (err != GRPC_CALL_OK) { + // A failure here indicates an API misuse; for example, doing a Write + // while another Write is already pending on the same RPC or invoking + // WritesDone multiple times + // gpr_log(GPR_ERROR, "API misuse of type %s observed", + // g_core_codegen_interface->grpc_call_error_to_string(err)); + GPR_CODEGEN_ASSERT(false); + } } // Should be called after interceptors are done running on the finalize result // path void ContinueFinalizeResultAfterInterception() override { done_intercepting_ = true; - // The following call_start_batch is internally-generated so no need for an - // explanatory log on failure. - GPR_CODEGEN_ASSERT(g_core_codegen_interface->grpc_call_start_batch( - call_.call(), nullptr, 0, core_cq_tag(), nullptr) == - GRPC_CALL_OK); + // The following call_start_batch is internally-generated so no need for an + // explanatory log on failure. + GPR_CODEGEN_ASSERT(g_core_codegen_interface->grpc_call_start_batch( + call_.call(), nullptr, 0, core_cq_tag(), nullptr) == + GRPC_CALL_OK); } private: diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/callback_common.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/callback_common.h index 6253e48b20..3c3bfd7e76 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/callback_common.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/callback_common.h @@ -51,8 +51,8 @@ void CatchingCallback(Func&& func, Args&&... args) { #endif // GRPC_ALLOW_EXCEPTIONS } -template <class Reactor, class Func, class... Args> -Reactor* CatchingReactorGetter(Func&& func, Args&&... args) { +template <class Reactor, class Func, class... Args> +Reactor* CatchingReactorGetter(Func&& func, Args&&... args) { #if GRPC_ALLOW_EXCEPTIONS try { return func(std::forward<Args>(args)...); @@ -73,8 +73,8 @@ class CallbackWithStatusTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* /*ptr*/, std::size_t size) { - GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithStatusTag)); + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithStatusTag)); } // This operator should never be called as the memory should be freed as part @@ -82,17 +82,17 @@ class CallbackWithStatusTag // delete to the operator new so that some compilers will not complain (see // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } CallbackWithStatusTag(grpc_call* call, std::function<void(Status)> f, CompletionQueueTag* ops) : call_(call), func_(std::move(f)), ops_(ops) { g_core_codegen_interface->grpc_call_ref(call); functor_run = &CallbackWithStatusTag::StaticRun; - // A client-side callback should never be run inline since they will always - // have work to do from the user application. So, set the parent's - // inlineable field to false - inlineable = false; + // A client-side callback should never be run inline since they will always + // have work to do from the user application. So, set the parent's + // inlineable field to false + inlineable = false; } ~CallbackWithStatusTag() {} Status* status_ptr() { return &status_; } @@ -141,8 +141,8 @@ class CallbackWithSuccessTag : public grpc_experimental_completion_queue_functor { public: // always allocated against a call arena, no memory free required - static void operator delete(void* /*ptr*/, std::size_t size) { - GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithSuccessTag)); + static void operator delete(void* /*ptr*/, std::size_t size) { + GPR_CODEGEN_ASSERT(size == sizeof(CallbackWithSuccessTag)); } // This operator should never be called as the memory should be freed as part @@ -150,7 +150,7 @@ class CallbackWithSuccessTag // delete to the operator new so that some compilers will not complain (see // https://github.com/grpc/grpc/issues/11301) Note at the time of adding this // there are no tests catching the compiler warning. - static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } + static void operator delete(void*, void*) { GPR_CODEGEN_ASSERT(false); } CallbackWithSuccessTag() : call_(nullptr) {} @@ -162,18 +162,18 @@ class CallbackWithSuccessTag // Set can only be called on a default-constructed or Clear'ed tag. // It should never be called on a tag that was constructed with arguments // or on a tag that has been Set before unless the tag has been cleared. - // can_inline indicates that this particular callback can be executed inline - // (without needing a thread hop) and is only used for library-provided server - // callbacks. + // can_inline indicates that this particular callback can be executed inline + // (without needing a thread hop) and is only used for library-provided server + // callbacks. void Set(grpc_call* call, std::function<void(bool)> f, - CompletionQueueTag* ops, bool can_inline) { + CompletionQueueTag* ops, bool can_inline) { GPR_CODEGEN_ASSERT(call_ == nullptr); g_core_codegen_interface->grpc_call_ref(call); call_ = call; func_ = std::move(f); ops_ = ops; functor_run = &CallbackWithSuccessTag::StaticRun; - inlineable = can_inline; + inlineable = can_inline; } void Clear() { @@ -208,11 +208,11 @@ class CallbackWithSuccessTag void* ignored = ops_; // Allow a "false" return value from FinalizeResult to silence the // callback, just as it silences a CQ tag in the async cases -#ifndef NDEBUG +#ifndef NDEBUG auto* ops = ops_; -#endif +#endif bool do_callback = ops_->FinalizeResult(&ignored, &ok); - GPR_CODEGEN_DEBUG_ASSERT(ignored == ops); + GPR_CODEGEN_DEBUG_ASSERT(ignored == ops); if (do_callback) { CatchingCallback(func_, ok); diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/channel_interface.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/channel_interface.h index 4ac1270989..ea0752d90e 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/channel_interface.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/channel_interface.h @@ -52,24 +52,24 @@ template <class R> class ClientCallbackReaderFactory; template <class W> class ClientCallbackWriterFactory; -class ClientCallbackUnaryFactory; -} // namespace internal - -class ChannelInterface; +class ClientCallbackUnaryFactory; +} // namespace internal + +class ChannelInterface; class ClientContext; class CompletionQueue; - -namespace experimental { -class DelegatingChannel; -} - -namespace internal { -class Call; -class CallOpSetInterface; -class RpcMethod; + +namespace experimental { +class DelegatingChannel; +} + +namespace internal { +class Call; +class CallOpSetInterface; +class RpcMethod; class InterceptedChannel; -template <class InputMessage, class OutputMessage> -class BlockingUnaryCallImpl; +template <class InputMessage, class OutputMessage> +class BlockingUnaryCallImpl; } // namespace internal /// Codegen interface for \a grpc::Channel. @@ -134,7 +134,7 @@ class ChannelInterface { template <class InputMessage, class OutputMessage> friend class ::grpc::internal::CallbackUnaryCallImpl; friend class ::grpc::internal::RpcMethod; - friend class ::grpc::experimental::DelegatingChannel; + friend class ::grpc::experimental::DelegatingChannel; friend class ::grpc::internal::InterceptedChannel; virtual internal::Call CreateCall(const internal::RpcMethod& method, ::grpc::ClientContext* context, @@ -145,7 +145,7 @@ class ChannelInterface { virtual void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline, ::grpc::CompletionQueue* cq, - void* tag) = 0; + void* tag) = 0; virtual bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, gpr_timespec deadline) = 0; @@ -156,7 +156,7 @@ class ChannelInterface { // Returns an empty Call object (rather than being pure) since this is a new // method and adding a new pure method to an interface would be a breaking // change (even though this is private and non-API) - virtual internal::Call CreateCallInternal( + virtual internal::Call CreateCallInternal( const internal::RpcMethod& /*method*/, ::grpc::ClientContext* /*context*/, ::grpc::CompletionQueue* /*cq*/, size_t /*interceptor_pos*/) { return internal::Call(); diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_callback.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_callback.h index dbb90a5b06..90c817ceaa 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_callback.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_callback.h @@ -1194,12 +1194,12 @@ namespace experimental { template <class Response> using ClientCallbackReader = ::grpc::ClientCallbackReader<Response>; - + template <class Request> using ClientCallbackWriter = ::grpc::ClientCallbackWriter<Request>; template <class Request, class Response> -using ClientCallbackReaderWriter = +using ClientCallbackReaderWriter = ::grpc::ClientCallbackReaderWriter<Request, Response>; template <class Response> diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_interceptor.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_interceptor.h index ed995a8ce4..78be1f7597 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_interceptor.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_interceptor.h @@ -28,7 +28,7 @@ namespace grpc { -class Channel; +class Channel; class ClientContext; namespace internal { @@ -76,7 +76,7 @@ class ClientRpcInfo { UNKNOWN // UNKNOWN is not API and will be removed later }; - ~ClientRpcInfo() {} + ~ClientRpcInfo() {} // Delete copy constructor but allow default move constructor ClientRpcInfo(const ClientRpcInfo&) = delete; @@ -141,8 +141,8 @@ class ClientRpcInfo { // No interceptors to register return; } - // NOTE: The following is not a range-based for loop because it will only - // iterate over a portion of the creators vector. + // NOTE: The following is not a range-based for loop because it will only + // iterate over a portion of the creators vector. for (auto it = creators.begin() + interceptor_pos; it != creators.end(); ++it) { auto* interceptor = (*it)->CreateClientInterceptor(this); @@ -174,16 +174,16 @@ class ClientRpcInfo { // PLEASE DO NOT USE THIS. ALWAYS PREFER PER CHANNEL INTERCEPTORS OVER A GLOBAL // INTERCEPTOR. IF USAGE IS ABSOLUTELY NECESSARY, PLEASE READ THE SAFETY NOTES. // Registers a global client interceptor factory object, which is used for all -// RPCs made in this process. The application is responsible for maintaining the -// life of the object while gRPC operations are in progress. The global -// interceptor factory should only be registered once at the start of the -// process before any gRPC operations have begun. +// RPCs made in this process. The application is responsible for maintaining the +// life of the object while gRPC operations are in progress. The global +// interceptor factory should only be registered once at the start of the +// process before any gRPC operations have begun. void RegisterGlobalClientInterceptorFactory( ClientInterceptorFactoryInterface* factory); -// For testing purposes only -void TestOnlyResetGlobalClientInterceptorFactory(); - +// For testing purposes only +void TestOnlyResetGlobalClientInterceptorFactory(); + } // namespace experimental } // namespace grpc diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_unary_call.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_unary_call.h index 3baba87ab3..098bb50ee2 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/client_unary_call.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/client_unary_call.h @@ -34,7 +34,7 @@ class RpcMethod; template <class InputMessage, class OutputMessage> Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, grpc::ClientContext* context, - const InputMessage& request, OutputMessage* result) { + const InputMessage& request, OutputMessage* result) { return BlockingUnaryCallImpl<InputMessage, OutputMessage>( channel, method, context, request, result) .status(); @@ -45,11 +45,11 @@ class BlockingUnaryCallImpl { public: BlockingUnaryCallImpl(ChannelInterface* channel, const RpcMethod& method, grpc::ClientContext* context, - const InputMessage& request, OutputMessage* result) { + const InputMessage& request, OutputMessage* result) { ::grpc::CompletionQueue cq(grpc_completion_queue_attributes{ GRPC_CQ_CURRENT_VERSION, GRPC_CQ_PLUCK, GRPC_CQ_DEFAULT_POLLING, nullptr}); // Pluckable completion queue - ::grpc::internal::Call call(channel->CreateCall(method, context, &cq)); + ::grpc::internal::Call call(channel->CreateCall(method, context, &cq)); CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpRecvInitialMetadata, CallOpRecvMessage<OutputMessage>, CallOpClientSendClose, CallOpClientRecvStatus> diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h index e0d87704f7..c4012fb00c 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/config_protobuf.h @@ -25,11 +25,11 @@ #ifdef GRPC_USE_PROTO_LITE #include <google/protobuf/message_lite.h> #define GRPC_CUSTOM_MESSAGE ::google::protobuf::MessageLite -#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #else #include <google/protobuf/message.h> #define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message -#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #endif #endif @@ -73,7 +73,7 @@ namespace grpc { namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; -typedef GRPC_CUSTOM_MESSAGELITE MessageLite; +typedef GRPC_CUSTOM_MESSAGELITE MessageLite; typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; typedef GRPC_CUSTOM_DESCRIPTORPOOL DescriptorPool; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen.h index f7ac555f76..50c8da4ffe 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen.h @@ -73,8 +73,8 @@ class CoreCodegen final : public CoreCodegenInterface { void* reserved) override; void grpc_call_ref(grpc_call* call) override; void grpc_call_unref(grpc_call* call) override; - void* grpc_call_arena_alloc(grpc_call* call, size_t length) override; - const char* grpc_call_error_to_string(grpc_call_error error) override; + void* grpc_call_arena_alloc(grpc_call* call, size_t length) override; + const char* grpc_call_error_to_string(grpc_call_error error) override; grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override; void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override; @@ -86,8 +86,8 @@ class CoreCodegen final : public CoreCodegenInterface { grpc_byte_buffer_reader* reader) override; int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, grpc_slice* slice) override; - int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, - grpc_slice** slice) override; + int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, + grpc_slice** slice) override; grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, size_t nslices) override; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen_interface.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen_interface.h index 637ef69874..c08cf6c683 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen_interface.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/core_codegen_interface.h @@ -19,7 +19,7 @@ #ifndef GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H #define GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H -#include <grpc/impl/codegen/byte_buffer.h> +#include <grpc/impl/codegen/byte_buffer.h> #include <grpc/impl/codegen/byte_buffer_reader.h> #include <grpc/impl/codegen/grpc_types.h> #include <grpc/impl/codegen/sync.h> @@ -93,8 +93,8 @@ class CoreCodegenInterface { grpc_byte_buffer_reader* reader) = 0; virtual int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, grpc_slice* slice) = 0; - virtual int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, - grpc_slice** slice) = 0; + virtual int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader, + grpc_slice** slice) = 0; virtual grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, size_t nslices) = 0; @@ -114,7 +114,7 @@ class CoreCodegenInterface { virtual void grpc_call_ref(grpc_call* call) = 0; virtual void grpc_call_unref(grpc_call* call) = 0; virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) = 0; - virtual const char* grpc_call_error_to_string(grpc_call_error error) = 0; + virtual const char* grpc_call_error_to_string(grpc_call_error error) = 0; virtual grpc_slice grpc_empty_slice() = 0; virtual grpc_slice grpc_slice_malloc(size_t length) = 0; virtual void grpc_slice_unref(grpc_slice slice) = 0; @@ -145,7 +145,7 @@ extern CoreCodegenInterface* g_core_codegen_interface; /// Codegen specific version of \a GPR_ASSERT. #define GPR_CODEGEN_ASSERT(x) \ do { \ - if (GPR_UNLIKELY(!(x))) { \ + if (GPR_UNLIKELY(!(x))) { \ grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \ } \ } while (0) diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h index 52e10e36e3..1a3bbd3349 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/delegating_channel.h @@ -1,87 +1,87 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H -#define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H - -namespace grpc { -namespace experimental { - -class DelegatingChannel : public ::grpc::ChannelInterface { - public: - virtual ~DelegatingChannel() {} - - DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel) - : delegate_channel_(delegate_channel) {} - - grpc_connectivity_state GetState(bool try_to_connect) override { - return delegate_channel()->GetState(try_to_connect); - } - - std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { - return delegate_channel_; - } - - private: - internal::Call CreateCall(const internal::RpcMethod& method, - ClientContext* context, +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H +#define GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H + +namespace grpc { +namespace experimental { + +class DelegatingChannel : public ::grpc::ChannelInterface { + public: + virtual ~DelegatingChannel() {} + + DelegatingChannel(std::shared_ptr<::grpc::ChannelInterface> delegate_channel) + : delegate_channel_(delegate_channel) {} + + grpc_connectivity_state GetState(bool try_to_connect) override { + return delegate_channel()->GetState(try_to_connect); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel() { + return delegate_channel_; + } + + private: + internal::Call CreateCall(const internal::RpcMethod& method, + ClientContext* context, ::grpc::CompletionQueue* cq) final { - return delegate_channel()->CreateCall(method, context, cq); - } - - void PerformOpsOnCall(internal::CallOpSetInterface* ops, - internal::Call* call) final { - delegate_channel()->PerformOpsOnCall(ops, call); - } - - void* RegisterMethod(const char* method) final { - return delegate_channel()->RegisterMethod(method); - } - - void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, + return delegate_channel()->CreateCall(method, context, cq); + } + + void PerformOpsOnCall(internal::CallOpSetInterface* ops, + internal::Call* call) final { + delegate_channel()->PerformOpsOnCall(ops, call); + } + + void* RegisterMethod(const char* method) final { + return delegate_channel()->RegisterMethod(method); + } + + void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline, ::grpc::CompletionQueue* cq, - void* tag) override { - delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq, - tag); - } - - bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline) override { - return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline); - } - - internal::Call CreateCallInternal(const internal::RpcMethod& method, - ClientContext* context, + void* tag) override { + delegate_channel()->NotifyOnStateChangeImpl(last_observed, deadline, cq, + tag); + } + + bool WaitForStateChangeImpl(grpc_connectivity_state last_observed, + gpr_timespec deadline) override { + return delegate_channel()->WaitForStateChangeImpl(last_observed, deadline); + } + + internal::Call CreateCallInternal(const internal::RpcMethod& method, + ClientContext* context, ::grpc::CompletionQueue* cq, - size_t interceptor_pos) final { - return delegate_channel()->CreateCallInternal(method, context, cq, - interceptor_pos); - } - + size_t interceptor_pos) final { + return delegate_channel()->CreateCallInternal(method, context, cq, + interceptor_pos); + } + ::grpc::CompletionQueue* CallbackCQ() final { - return delegate_channel()->CallbackCQ(); - } - - std::shared_ptr<::grpc::ChannelInterface> delegate_channel_; -}; - -} // namespace experimental -} // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H + return delegate_channel()->CallbackCQ(); + } + + std::shared_ptr<::grpc::ChannelInterface> delegate_channel_; +}; + +} // namespace experimental +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_DELEGATING_CHANNEL_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/intercepted_channel.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/intercepted_channel.h index edb5c2c87f..c729970ca8 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/intercepted_channel.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/intercepted_channel.h @@ -22,8 +22,8 @@ #include <grpcpp/impl/codegen/channel_interface.h> namespace grpc { -class CompletionQueue; - +class CompletionQueue; + namespace internal { class InterceptorBatchMethodsImpl; @@ -59,7 +59,7 @@ class InterceptedChannel : public ChannelInterface { } void NotifyOnStateChangeImpl(grpc_connectivity_state last_observed, - gpr_timespec deadline, + gpr_timespec deadline, ::grpc::CompletionQueue* cq, void* tag) override { return channel_->NotifyOnStateChangeImpl(last_observed, deadline, cq, tag); @@ -70,8 +70,8 @@ class InterceptedChannel : public ChannelInterface { } ::grpc::CompletionQueue* CallbackCQ() override { - return channel_->CallbackCQ(); - } + return channel_->CallbackCQ(); + } ChannelInterface* channel_; size_t interceptor_pos_; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor.h index 83223dad94..d0afa03a17 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor.h @@ -92,7 +92,7 @@ enum class InterceptionHookPoints { /// 5. Set some fields of an RPC at each interception point, when possible class InterceptorBatchMethods { public: - virtual ~InterceptorBatchMethods() {} + virtual ~InterceptorBatchMethods() {} /// Determine whether the current batch has an interception hook point /// of type \a type virtual bool QueryInterceptionHookPoint(InterceptionHookPoints type) = 0; @@ -175,22 +175,22 @@ class InterceptorBatchMethods { /// Returns a pointer to the modifiable received message. Note that the /// message is already deserialized but the type is not set; the interceptor /// should static_cast to the appropriate type before using it. This is valid - /// for PRE_RECV_MESSAGE and POST_RECV_MESSAGE interceptions; nullptr for not - /// valid + /// for PRE_RECV_MESSAGE and POST_RECV_MESSAGE interceptions; nullptr for not + /// valid virtual void* GetRecvMessage() = 0; /// Returns a modifiable multimap of the received initial metadata. - /// Valid for PRE_RECV_INITIAL_METADATA and POST_RECV_INITIAL_METADATA - /// interceptions; nullptr if not valid + /// Valid for PRE_RECV_INITIAL_METADATA and POST_RECV_INITIAL_METADATA + /// interceptions; nullptr if not valid virtual std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvInitialMetadata() = 0; - /// Returns a modifiable view of the received status on PRE_RECV_STATUS and - /// POST_RECV_STATUS interceptions; nullptr if not valid. + /// Returns a modifiable view of the received status on PRE_RECV_STATUS and + /// POST_RECV_STATUS interceptions; nullptr if not valid. virtual Status* GetRecvStatus() = 0; /// Returns a modifiable multimap of the received trailing metadata on - /// PRE_RECV_STATUS and POST_RECV_STATUS interceptions; nullptr if not valid + /// PRE_RECV_STATUS and POST_RECV_STATUS interceptions; nullptr if not valid virtual std::multimap<grpc::string_ref, grpc::string_ref>* GetRecvTrailingMetadata() = 0; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor_common.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor_common.h index 49d63aee1b..714351f543 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor_common.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/interceptor_common.h @@ -468,7 +468,7 @@ class CancelInterceptorBatchMethods return nullptr; } - void ModifySendMessage(const void* /*message*/) override { + void ModifySendMessage(const void* /*message*/) override { GPR_CODEGEN_ASSERT( false && "It is illegal to call ModifySendMessage on a method which " @@ -489,7 +489,7 @@ class CancelInterceptorBatchMethods return Status(); } - void ModifySendStatus(const Status& /*status*/) override { + void ModifySendStatus(const Status& /*status*/) override { GPR_CODEGEN_ASSERT(false && "It is illegal to call ModifySendStatus on a method " "which has a Cancel notification"); diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/message_allocator.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/message_allocator.h index 8e4513c223..4048ea1197 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/message_allocator.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/message_allocator.h @@ -1,76 +1,76 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H -#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H - -namespace grpc { +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H +#define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H + +namespace grpc { #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL -namespace experimental { +namespace experimental { #endif - -// NOTE: This is an API for advanced users who need custom allocators. -// Per rpc struct for the allocator. This is the interface to return to user. -class RpcAllocatorState { - public: - virtual ~RpcAllocatorState() = default; - // Optionally deallocate request early to reduce the size of working set. - // A custom MessageAllocator needs to be registered to make use of this. - // This is not abstract because implementing it is optional. - virtual void FreeRequest() {} -}; - -// This is the interface returned by the allocator. -// grpc library will call the methods to get request/response pointers and to -// release the object when it is done. -template <typename RequestT, typename ResponseT> -class MessageHolder : public RpcAllocatorState { - public: - // Release this object. For example, if the custom allocator's - // AllocateMessasge creates an instance of a subclass with new, the Release() - // should do a "delete this;". - virtual void Release() = 0; - RequestT* request() { return request_; } - ResponseT* response() { return response_; } - - protected: - void set_request(RequestT* request) { request_ = request; } - void set_response(ResponseT* response) { response_ = response; } - - private: - // NOTE: subclasses should set these pointers. - RequestT* request_; - ResponseT* response_; -}; - -// A custom allocator can be set via the generated code to a callback unary -// method, such as SetMessageAllocatorFor_Echo(custom_allocator). The allocator -// needs to be alive for the lifetime of the server. -// Implementations need to be thread-safe. -template <typename RequestT, typename ResponseT> -class MessageAllocator { - public: - virtual ~MessageAllocator() = default; - virtual MessageHolder<RequestT, ResponseT>* AllocateMessages() = 0; -}; - + +// NOTE: This is an API for advanced users who need custom allocators. +// Per rpc struct for the allocator. This is the interface to return to user. +class RpcAllocatorState { + public: + virtual ~RpcAllocatorState() = default; + // Optionally deallocate request early to reduce the size of working set. + // A custom MessageAllocator needs to be registered to make use of this. + // This is not abstract because implementing it is optional. + virtual void FreeRequest() {} +}; + +// This is the interface returned by the allocator. +// grpc library will call the methods to get request/response pointers and to +// release the object when it is done. +template <typename RequestT, typename ResponseT> +class MessageHolder : public RpcAllocatorState { + public: + // Release this object. For example, if the custom allocator's + // AllocateMessasge creates an instance of a subclass with new, the Release() + // should do a "delete this;". + virtual void Release() = 0; + RequestT* request() { return request_; } + ResponseT* response() { return response_; } + + protected: + void set_request(RequestT* request) { request_ = request; } + void set_response(ResponseT* response) { response_ = response; } + + private: + // NOTE: subclasses should set these pointers. + RequestT* request_; + ResponseT* response_; +}; + +// A custom allocator can be set via the generated code to a callback unary +// method, such as SetMessageAllocatorFor_Echo(custom_allocator). The allocator +// needs to be alive for the lifetime of the server. +// Implementations need to be thread-safe. +template <typename RequestT, typename ResponseT> +class MessageAllocator { + public: + virtual ~MessageAllocator() = default; + virtual MessageHolder<RequestT, ResponseT>* AllocateMessages() = 0; +}; + #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL -} // namespace experimental +} // namespace experimental #endif // TODO(vjpai): Remove namespace experimental when de-experimentalized fully. @@ -88,6 +88,6 @@ using MessageAllocator = ::grpc::MessageAllocator<RequestT, ResponseT>; } // namespace experimental #endif -} // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler.h index c4fe9c3aee..0033936b04 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/method_handler.h @@ -1,33 +1,33 @@ -/* - * +/* + * * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H -#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H - + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H +#define GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H + #include <grpcpp/impl/codegen/byte_buffer.h> #include <grpcpp/impl/codegen/core_codegen_interface.h> #include <grpcpp/impl/codegen/rpc_service_method.h> #include <grpcpp/impl/codegen/sync_stream.h> - -namespace grpc { - -namespace internal { - + +namespace grpc { + +namespace internal { + // Invoke the method handler, fill in the status, and // return whether or not we finished safely (without an exception). // Note that exception handling is 0-cost in most compiler/library @@ -48,9 +48,9 @@ template <class Callable> return handler(); #endif // GRPC_ALLOW_EXCEPTIONS } - + /// A wrapper class of an application provided rpc method handler. -template <class ServiceType, class RequestType, class ResponseType> +template <class ServiceType, class RequestType, class ResponseType> class RpcMethodHandler : public ::grpc::internal::MethodHandler { public: RpcMethodHandler( @@ -59,7 +59,7 @@ class RpcMethodHandler : public ::grpc::internal::MethodHandler { func, ServiceType* service) : func_(func), service_(service) {} - + void RunHandler(const HandlerParameter& param) final { ResponseType rsp; ::grpc::Status status = param.status; @@ -117,7 +117,7 @@ class RpcMethodHandler : public ::grpc::internal::MethodHandler { }; /// A wrapper class of an application provided client streaming handler. -template <class ServiceType, class RequestType, class ResponseType> +template <class ServiceType, class RequestType, class ResponseType> class ClientStreamingHandler : public ::grpc::internal::MethodHandler { public: ClientStreamingHandler( @@ -126,7 +126,7 @@ class ClientStreamingHandler : public ::grpc::internal::MethodHandler { func, ServiceType* service) : func_(func), service_(service) {} - + void RunHandler(const HandlerParameter& param) final { ServerReader<RequestType> reader( param.call, static_cast<::grpc::ServerContext*>(param.server_context)); @@ -165,7 +165,7 @@ class ClientStreamingHandler : public ::grpc::internal::MethodHandler { }; /// A wrapper class of an application provided server streaming handler. -template <class ServiceType, class RequestType, class ResponseType> +template <class ServiceType, class RequestType, class ResponseType> class ServerStreamingHandler : public ::grpc::internal::MethodHandler { public: ServerStreamingHandler(std::function<::grpc::Status( @@ -174,7 +174,7 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler { func, ServiceType* service) : func_(func), service_(service) {} - + void RunHandler(const HandlerParameter& param) final { ::grpc::Status status = param.status; if (status.ok()) { @@ -238,13 +238,13 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler { /// Since this is used by more than 1 class, the service is not passed in. /// Instead, it is expected to be an implicitly-captured argument of func /// (through bind or something along those lines) -template <class Streamer, bool WriteNeeded> +template <class Streamer, bool WriteNeeded> class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { public: TemplatedBidiStreamingHandler( std::function<::grpc::Status(::grpc::ServerContext*, Streamer*)> func) : func_(func), write_needed_(WriteNeeded) {} - + void RunHandler(const HandlerParameter& param) final { Streamer stream(param.call, static_cast<::grpc::ServerContext*>(param.server_context)); @@ -302,7 +302,7 @@ class BidiStreamingHandler }) {} }; -template <class RequestType, class ResponseType> +template <class RequestType, class ResponseType> class StreamedUnaryHandler : public TemplatedBidiStreamingHandler< ServerUnaryStreamer<RequestType, ResponseType>, true> { @@ -316,8 +316,8 @@ class StreamedUnaryHandler ServerUnaryStreamer<RequestType, ResponseType>, true>( std::move(func)) {} }; - -template <class RequestType, class ResponseType> + +template <class RequestType, class ResponseType> class SplitServerStreamingHandler : public TemplatedBidiStreamingHandler< ServerSplitStreamer<RequestType, ResponseType>, false> { @@ -331,7 +331,7 @@ class SplitServerStreamingHandler ServerSplitStreamer<RequestType, ResponseType>, false>( std::move(func)) {} }; - + /// General method handler class for errors that prevent real method use /// e.g., handle unknown method by returning UNIMPLEMENTED error. template <::grpc::StatusCode code> @@ -350,7 +350,7 @@ class ErrorMethodHandler : public ::grpc::internal::MethodHandler { } ops->ServerSendStatus(&context->trailing_metadata_, status); } - + void RunHandler(const HandlerParameter& param) final { ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpServerSendStatus> @@ -359,7 +359,7 @@ class ErrorMethodHandler : public ::grpc::internal::MethodHandler { param.call->PerformOps(&ops); param.call->cq()->Pluck(&ops); } - + void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, ::grpc::Status* /*status*/, void** /*handler_data*/) final { // We have to destroy any request payload @@ -369,13 +369,13 @@ class ErrorMethodHandler : public ::grpc::internal::MethodHandler { return nullptr; } }; - + typedef ErrorMethodHandler<::grpc::StatusCode::UNIMPLEMENTED> UnknownMethodHandler; typedef ErrorMethodHandler<::grpc::StatusCode::RESOURCE_EXHAUSTED> ResourceExhaustedHandler; -} // namespace internal -} // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_METHOD_HANDLER_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_reader.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_reader.h index c43ebd0aa5..487471290d 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_reader.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_reader.h @@ -73,7 +73,7 @@ class ProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { } /// If we have backed up previously, we need to return the backed-up slice if (backup_count_ > 0) { - *data = GRPC_SLICE_START_PTR(*slice_) + GRPC_SLICE_LENGTH(*slice_) - + *data = GRPC_SLICE_START_PTR(*slice_) + GRPC_SLICE_LENGTH(*slice_) - backup_count_; GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX); *size = (int)backup_count_; @@ -81,14 +81,14 @@ class ProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { return true; } /// Otherwise get the next slice from the byte buffer reader - if (!g_core_codegen_interface->grpc_byte_buffer_reader_peek(&reader_, + if (!g_core_codegen_interface->grpc_byte_buffer_reader_peek(&reader_, &slice_)) { return false; } - *data = GRPC_SLICE_START_PTR(*slice_); + *data = GRPC_SLICE_START_PTR(*slice_); // On win x64, int is only 32bit - GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(*slice_) <= INT_MAX); - byte_count_ += * size = (int)GRPC_SLICE_LENGTH(*slice_); + GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(*slice_) <= INT_MAX); + byte_count_ += * size = (int)GRPC_SLICE_LENGTH(*slice_); return true; } @@ -99,7 +99,7 @@ class ProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { /// bytes that have already been returned by the last call of Next. /// So do the backup and have that ready for a later Next. void BackUp(int count) override { - GPR_CODEGEN_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(*slice_))); + GPR_CODEGEN_ASSERT(count <= static_cast<int>(GRPC_SLICE_LENGTH(*slice_))); backup_count_ = count; } @@ -132,15 +132,15 @@ class ProtoBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { int64_t backup_count() { return backup_count_; } void set_backup_count(int64_t backup_count) { backup_count_ = backup_count; } grpc_byte_buffer_reader* reader() { return &reader_; } - grpc_slice* slice() { return slice_; } - grpc_slice** mutable_slice_ptr() { return &slice_; } + grpc_slice* slice() { return slice_; } + grpc_slice** mutable_slice_ptr() { return &slice_; } private: int64_t byte_count_; ///< total bytes read since object creation int64_t backup_count_; ///< how far backed up in the stream we are grpc_byte_buffer_reader reader_; ///< internal object to read \a grpc_slice ///< from the \a grpc_byte_buffer - grpc_slice* slice_; ///< current slice passed back to the caller + grpc_slice* slice_; ///< current slice passed back to the caller Status status_; ///< status of the entire object }; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_writer.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_writer.h index a8cc302f2d..0af4616e50 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_writer.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_buffer_writer.h @@ -86,7 +86,7 @@ class ProtoBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { // or our maximum allocation size // 3. Provide the slice start and size available // 4. Add the slice being returned to the slice buffer - size_t remain = static_cast<size_t>(total_size_ - byte_count_); + size_t remain = static_cast<size_t>(total_size_ - byte_count_); if (have_backup_) { /// If we have a backup slice, we should use it first slice_ = backup_slice_; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_utils.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_utils.h index b1ac427453..2e102135a3 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_utils.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/proto_utils.h @@ -42,7 +42,7 @@ extern CoreCodegenInterface* g_core_codegen_interface; // ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream. template <class ProtoBufferWriter, class T> -Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, +Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer) { static_assert(std::is_base_of<protobuf::io::ZeroCopyOutputStream, ProtoBufferWriter>::value, @@ -68,8 +68,8 @@ Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. template <class ProtoBufferReader, class T> -Status GenericDeserialize(ByteBuffer* buffer, - grpc::protobuf::MessageLite* msg) { +Status GenericDeserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { static_assert(std::is_base_of<protobuf::io::ZeroCopyInputStream, ProtoBufferReader>::value, "ProtoBufferReader must be a subclass of " @@ -83,7 +83,7 @@ Status GenericDeserialize(ByteBuffer* buffer, if (!reader.status().ok()) { return reader.status(); } - if (!msg->ParseFromZeroCopyStream(&reader)) { + if (!msg->ParseFromZeroCopyStream(&reader)) { result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); } } @@ -98,17 +98,17 @@ Status GenericDeserialize(ByteBuffer* buffer, // objects and grpc_byte_buffers. More information about SerializationTraits can // be found in include/grpcpp/impl/codegen/serialization_traits.h. template <class T> -class SerializationTraits< - T, typename std::enable_if< - std::is_base_of<grpc::protobuf::MessageLite, T>::value>::type> { +class SerializationTraits< + T, typename std::enable_if< + std::is_base_of<grpc::protobuf::MessageLite, T>::value>::type> { public: - static Status Serialize(const grpc::protobuf::MessageLite& msg, - ByteBuffer* bb, bool* own_buffer) { + static Status Serialize(const grpc::protobuf::MessageLite& msg, + ByteBuffer* bb, bool* own_buffer) { return GenericSerialize<ProtoBufferWriter, T>(msg, bb, own_buffer); } - static Status Deserialize(ByteBuffer* buffer, - grpc::protobuf::MessageLite* msg) { + static Status Deserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { return GenericDeserialize<ProtoBufferReader, T>(buffer, msg); } }; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/rpc_service_method.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/rpc_service_method.h index f86def7fa7..4fcc211243 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/rpc_service_method.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/rpc_service_method.h @@ -32,7 +32,7 @@ #include <grpcpp/impl/codegen/status.h> namespace grpc { -class ServerContextBase; +class ServerContextBase; namespace internal { /// Base class for running an RPC handler. class MethodHandler { @@ -45,26 +45,26 @@ class MethodHandler { /// \param context : the ServerContext structure for this server call /// \param req : the request payload, if appropriate for this RPC /// \param req_status : the request status after any interceptors have run - /// \param handler_data: internal data for the handler. - /// \param requester : used only by the callback API. It is a function + /// \param handler_data: internal data for the handler. + /// \param requester : used only by the callback API. It is a function /// called by the RPC Controller to request another RPC (and also /// to set up the state required to make that request possible) HandlerParameter(Call* c, ::grpc::ServerContextBase* context, void* req, Status req_status, void* handler_data, - std::function<void()> requester) + std::function<void()> requester) : call(c), server_context(context), request(req), status(req_status), - internal_data(handler_data), + internal_data(handler_data), call_requester(std::move(requester)) {} ~HandlerParameter() {} - Call* const call; + Call* const call; ::grpc::ServerContextBase* const server_context; - void* const request; - const Status status; - void* const internal_data; - const std::function<void()> call_requester; + void* const request; + const Status status; + void* const internal_data; + const std::function<void()> call_requester; }; virtual void RunHandler(const HandlerParameter& param) = 0; @@ -73,8 +73,8 @@ class MethodHandler { a HandlerParameter and passed to RunHandler. It is illegal to access the pointer after calling RunHandler. Ownership of the deserialized request is retained by the handler. Returns nullptr if deserialization failed. */ - virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, - Status* /*status*/, void** /*handler_data*/) { + virtual void* Deserialize(grpc_call* /*call*/, grpc_byte_buffer* req, + Status* /*status*/, void** /*handler_data*/) { GPR_CODEGEN_ASSERT(req == nullptr); return nullptr; } diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/security/auth_context.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/security/auth_context.h index ad137001ed..220b78f2eb 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/security/auth_context.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/security/auth_context.h @@ -32,7 +32,7 @@ struct grpc_auth_property_iterator; namespace grpc { class SecureAuthContext; -typedef std::pair<string_ref, string_ref> AuthProperty; +typedef std::pair<string_ref, string_ref> AuthProperty; class AuthPropertyIterator : public std::iterator<std::input_iterator_tag, const AuthProperty> { @@ -86,7 +86,7 @@ class AuthContext { /// Mutation functions: should only be used by an AuthMetadataProcessor. virtual void AddProperty(const TString& key, const string_ref& value) = 0; - virtual bool SetPeerIdentityPropertyName(const string& name) = 0; + virtual bool SetPeerIdentityPropertyName(const string& name) = 0; }; } // namespace grpc diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_callback_handlers.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_callback_handlers.h index 9aa12fcc81..8120fcaf85 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_callback_handlers.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_callback_handlers.h @@ -1,209 +1,209 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H -#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H - -#include <grpcpp/impl/codegen/message_allocator.h> -#include <grpcpp/impl/codegen/rpc_service_method.h> +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H +#define GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H + +#include <grpcpp/impl/codegen/message_allocator.h> +#include <grpcpp/impl/codegen/rpc_service_method.h> #include <grpcpp/impl/codegen/server_callback.h> #include <grpcpp/impl/codegen/server_context.h> -#include <grpcpp/impl/codegen/status.h> - +#include <grpcpp/impl/codegen/status.h> + namespace grpc { -namespace internal { - -template <class RequestType, class ResponseType> -class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { - public: - explicit CallbackUnaryHandler( +namespace internal { + +template <class RequestType, class ResponseType> +class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackUnaryHandler( std::function<ServerUnaryReactor*(::grpc::CallbackServerContext*, - const RequestType*, ResponseType*)> - get_reactor) - : get_reactor_(std::move(get_reactor)) {} - - void SetMessageAllocator( - ::grpc::experimental::MessageAllocator<RequestType, ResponseType>* - allocator) { - allocator_ = allocator; - } - - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a controller structure (that includes request/response) - ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); - auto* allocator_state = static_cast< - ::grpc::experimental::MessageHolder<RequestType, ResponseType>*>( - param.internal_data); - - auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackUnaryImpl))) - ServerCallbackUnaryImpl( + const RequestType*, ResponseType*)> + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + + void SetMessageAllocator( + ::grpc::experimental::MessageAllocator<RequestType, ResponseType>* + allocator) { + allocator_ = allocator; + } + + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a controller structure (that includes request/response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + auto* allocator_state = static_cast< + ::grpc::experimental::MessageHolder<RequestType, ResponseType>*>( + param.internal_data); + + auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackUnaryImpl))) + ServerCallbackUnaryImpl( static_cast<::grpc::CallbackServerContext*>(param.server_context), - param.call, allocator_state, std::move(param.call_requester)); - param.server_context->BeginCompletionOp( - param.call, [call](bool) { call->MaybeDone(); }, call); - - ServerUnaryReactor* reactor = nullptr; - if (param.status.ok()) { - reactor = ::grpc::internal::CatchingReactorGetter<ServerUnaryReactor>( - get_reactor_, + param.call, allocator_state, std::move(param.call_requester)); + param.server_context->BeginCompletionOp( + param.call, [call](bool) { call->MaybeDone(); }, call); + + ServerUnaryReactor* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter<ServerUnaryReactor>( + get_reactor_, static_cast<::grpc::CallbackServerContext*>(param.server_context), - call->request(), call->response()); - } - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(UnimplementedUnaryReactor))) - UnimplementedUnaryReactor( - ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); - } - - /// Invoke SetupReactor as the last part of the handler - call->SetupReactor(reactor); - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - ::grpc::Status* status, void** handler_data) final { - ::grpc::ByteBuffer buf; - buf.set_buffer(req); - RequestType* request = nullptr; - ::grpc::experimental::MessageHolder<RequestType, ResponseType>* - allocator_state = nullptr; - if (allocator_ != nullptr) { - allocator_state = allocator_->AllocateMessages(); - } else { - allocator_state = - new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(DefaultMessageHolder<RequestType, ResponseType>))) - DefaultMessageHolder<RequestType, ResponseType>(); - } - *handler_data = allocator_state; - request = allocator_state->request(); - *status = - ::grpc::SerializationTraits<RequestType>::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - // Clean up on deserialization failure. - allocator_state->Release(); - return nullptr; - } - - private: + call->request(), call->response()); + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedUnaryReactor))) + UnimplementedUnaryReactor( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + /// Invoke SetupReactor as the last part of the handler + call->SetupReactor(reactor); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** handler_data) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + RequestType* request = nullptr; + ::grpc::experimental::MessageHolder<RequestType, ResponseType>* + allocator_state = nullptr; + if (allocator_ != nullptr) { + allocator_state = allocator_->AllocateMessages(); + } else { + allocator_state = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(DefaultMessageHolder<RequestType, ResponseType>))) + DefaultMessageHolder<RequestType, ResponseType>(); + } + *handler_data = allocator_state; + request = allocator_state->request(); + *status = + ::grpc::SerializationTraits<RequestType>::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + // Clean up on deserialization failure. + allocator_state->Release(); + return nullptr; + } + + private: std::function<ServerUnaryReactor*(::grpc::CallbackServerContext*, - const RequestType*, ResponseType*)> - get_reactor_; - ::grpc::experimental::MessageAllocator<RequestType, ResponseType>* - allocator_ = nullptr; - - class ServerCallbackUnaryImpl : public ServerCallbackUnary { - public: - void Finish(::grpc::Status s) override { + const RequestType*, ResponseType*)> + get_reactor_; + ::grpc::experimental::MessageAllocator<RequestType, ResponseType>* + allocator_ = nullptr; + + class ServerCallbackUnaryImpl : public ServerCallbackUnary { + public: + void Finish(::grpc::Status s) override { // A callback that only contains a call to MaybeDone can be run as an // inline callback regardless of whether or not OnDone is inlineable // because if the actual OnDone callback needs to be scheduled, MaybeDone // is responsible for dispatching to an executor thread if needed. Thus, // when setting up the finish_tag_, we can set its own callback to // inlineable. - finish_tag_.Set( + finish_tag_.Set( call_.call(), [this](bool) { this->MaybeDone( reactor_.load(std::memory_order_relaxed)->InternalInlineable()); }, &finish_ops_, /*can_inline=*/true); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(response())); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - this->Ref(); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(response())); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); // The callback for this function should not be marked inline because it // is directly invoking a user-controlled reaction // (OnSendInitialMetadataDone). Thus it must be dispatched to an executor // thread. However, any OnDone needed after that can be inlined because it // is already running on an executor thread. - meta_tag_.Set(call_.call(), - [this](bool ok) { + meta_tag_.Set(call_.call(), + [this](bool ok) { ServerUnaryReactor* reactor = reactor_.load(std::memory_order_relaxed); reactor->OnSendInitialMetadataDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &meta_ops_, /*can_inline=*/false); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - private: - friend class CallbackUnaryHandler<RequestType, ResponseType>; - - ServerCallbackUnaryImpl( + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + private: + friend class CallbackUnaryHandler<RequestType, ResponseType>; + + ServerCallbackUnaryImpl( ::grpc::CallbackServerContext* ctx, ::grpc::internal::Call* call, - ::grpc::experimental::MessageHolder<RequestType, ResponseType>* - allocator_state, - std::function<void()> call_requester) - : ctx_(ctx), - call_(*call), - allocator_state_(allocator_state), - call_requester_(std::move(call_requester)) { - ctx_->set_message_allocator_state(allocator_state); - } - - /// SetupReactor binds the reactor (which also releases any queued - /// operations), maybe calls OnCancel if possible/needed, and maybe marks - /// the completion of the RPC. This should be the last component of the - /// handler. - void SetupReactor(ServerUnaryReactor* reactor) { - reactor_.store(reactor, std::memory_order_relaxed); - this->BindReactor(reactor); - this->MaybeCallOnCancel(reactor); + ::grpc::experimental::MessageHolder<RequestType, ResponseType>* + allocator_state, + std::function<void()> call_requester) + : ctx_(ctx), + call_(*call), + allocator_state_(allocator_state), + call_requester_(std::move(call_requester)) { + ctx_->set_message_allocator_state(allocator_state); + } + + /// SetupReactor binds the reactor (which also releases any queued + /// operations), maybe calls OnCancel if possible/needed, and maybe marks + /// the completion of the RPC. This should be the last component of the + /// handler. + void SetupReactor(ServerUnaryReactor* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); this->MaybeDone(reactor->InternalInlineable()); - } - - const RequestType* request() { return allocator_state_->request(); } - ResponseType* response() { return allocator_state_->response(); } - + } + + const RequestType* request() { return allocator_state_->request(); } + ResponseType* response() { return allocator_state_->response(); } + void CallOnDone() override { reactor_.load(std::memory_order_relaxed)->OnDone(); grpc_call* call = call_.call(); @@ -212,96 +212,96 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { this->~ServerCallbackUnaryImpl(); // explicitly call destructor ::grpc::g_core_codegen_interface->grpc_call_unref(call); call_requester(); - } - - ServerReactor* reactor() override { - return reactor_.load(std::memory_order_relaxed); - } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallbackWithSuccessTag meta_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; - ::grpc::internal::CallbackWithSuccessTag finish_tag_; - + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::CallbackServerContext* const ctx_; - ::grpc::internal::Call call_; - ::grpc::experimental::MessageHolder<RequestType, ResponseType>* const - allocator_state_; - std::function<void()> call_requester_; - // reactor_ can always be loaded/stored with relaxed memory ordering because - // its value is only set once, independently of other data in the object, - // and the loads that use it will always actually come provably later even - // though they are from different threads since they are triggered by - // actions initiated only by the setting up of the reactor_ variable. In - // a sense, it's a delayed "const": it gets its value from the SetupReactor - // method (not the constructor, so it's not a true const), but it doesn't - // change after that and it only gets used by actions caused, directly or - // indirectly, by that setup. This comment also applies to the reactor_ - // variables of the other streaming objects in this file. - std::atomic<ServerUnaryReactor*> reactor_; - // callbacks_outstanding_ follows a refcount pattern - std::atomic<intptr_t> callbacks_outstanding_{ - 3}; // reserve for start, Finish, and CompletionOp - }; -}; - -template <class RequestType, class ResponseType> -class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { - public: - explicit CallbackClientStreamingHandler( - std::function<ServerReadReactor<RequestType>*( + ::grpc::internal::Call call_; + ::grpc::experimental::MessageHolder<RequestType, ResponseType>* const + allocator_state_; + std::function<void()> call_requester_; + // reactor_ can always be loaded/stored with relaxed memory ordering because + // its value is only set once, independently of other data in the object, + // and the loads that use it will always actually come provably later even + // though they are from different threads since they are triggered by + // actions initiated only by the setting up of the reactor_ variable. In + // a sense, it's a delayed "const": it gets its value from the SetupReactor + // method (not the constructor, so it's not a true const), but it doesn't + // change after that and it only gets used by actions caused, directly or + // indirectly, by that setup. This comment also applies to the reactor_ + // variables of the other streaming objects in this file. + std::atomic<ServerUnaryReactor*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic<intptr_t> callbacks_outstanding_{ + 3}; // reserve for start, Finish, and CompletionOp + }; +}; + +template <class RequestType, class ResponseType> +class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackClientStreamingHandler( + std::function<ServerReadReactor<RequestType>*( ::grpc::CallbackServerContext*, ResponseType*)> - get_reactor) - : get_reactor_(std::move(get_reactor)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a reader structure (that includes response) - ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); - - auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderImpl))) - ServerCallbackReaderImpl( + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a reader structure (that includes response) + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderImpl))) + ServerCallbackReaderImpl( static_cast<::grpc::CallbackServerContext*>(param.server_context), - param.call, std::move(param.call_requester)); + param.call, std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there // is no read reactor that has an inlineable OnDone; this only applies to // the DefaultReactor (which is unary). - param.server_context->BeginCompletionOp( + param.server_context->BeginCompletionOp( param.call, [reader](bool) { reader->MaybeDone(/*inlineable_ondone=*/false); }, reader); - - ServerReadReactor<RequestType>* reactor = nullptr; - if (param.status.ok()) { - reactor = ::grpc::internal::CatchingReactorGetter< - ServerReadReactor<RequestType>>( - get_reactor_, + + ServerReadReactor<RequestType>* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerReadReactor<RequestType>>( + get_reactor_, static_cast<::grpc::CallbackServerContext*>(param.server_context), - reader->response()); - } - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(UnimplementedReadReactor<RequestType>))) - UnimplementedReadReactor<RequestType>( - ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); - } - - reader->SetupReactor(reactor); - } - - private: + reader->response()); + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedReadReactor<RequestType>))) + UnimplementedReadReactor<RequestType>( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + reader->SetupReactor(reactor); + } + + private: std::function<ServerReadReactor<RequestType>*(::grpc::CallbackServerContext*, ResponseType*)> - get_reactor_; - - class ServerCallbackReaderImpl : public ServerCallbackReader<RequestType> { - public: - void Finish(::grpc::Status s) override { + get_reactor_; + + class ServerCallbackReaderImpl : public ServerCallbackReader<RequestType> { + public: + void Finish(::grpc::Status s) override { // A finish tag with only MaybeDone can have its callback inlined // regardless even if OnDone is not inlineable because this callback just // checks a ref and then decides whether or not to dispatch OnDone. @@ -313,87 +313,87 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { this->MaybeDone(/*inlineable_ondone=*/false); }, &finish_ops_, /*can_inline=*/true); - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // The response is dropped if the status is not OK. - if (s.ok()) { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, - finish_ops_.SendMessagePtr(&resp_)); - } else { - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - } - finish_ops_.set_core_cq_tag(&finish_tag_); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - this->Ref(); + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // The response is dropped if the status is not OK. + if (s.ok()) { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, + finish_ops_.SendMessagePtr(&resp_)); + } else { + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + } + finish_ops_.set_core_cq_tag(&finish_tag_); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); // The callback for this function should not be inlined because it invokes // a user-controlled reaction, but any resulting OnDone can be inlined in // the executor to which this callback is dispatched. - meta_tag_.Set(call_.call(), - [this](bool ok) { + meta_tag_.Set(call_.call(), + [this](bool ok) { ServerReadReactor<RequestType>* reactor = reactor_.load(std::memory_order_relaxed); reactor->OnSendInitialMetadataDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &meta_ops_, /*can_inline=*/false); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Read(RequestType* req) override { - this->Ref(); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackClientStreamingHandler<RequestType, ResponseType>; - + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Read(RequestType* req) override { + this->Ref(); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackClientStreamingHandler<RequestType, ResponseType>; + ServerCallbackReaderImpl(::grpc::CallbackServerContext* ctx, - ::grpc::internal::Call* call, - std::function<void()> call_requester) - : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} - - void SetupReactor(ServerReadReactor<RequestType>* reactor) { - reactor_.store(reactor, std::memory_order_relaxed); + ::grpc::internal::Call* call, + std::function<void()> call_requester) + : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerReadReactor<RequestType>* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); // The callback for this function should not be inlined because it invokes // a user-controlled reaction, but any resulting OnDone can be inlined in // the executor to which this callback is dispatched. - read_tag_.Set(call_.call(), + read_tag_.Set(call_.call(), [this, reactor](bool ok) { reactor->OnReadDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &read_ops_, /*can_inline=*/false); - read_ops_.set_core_cq_tag(&read_tag_); - this->BindReactor(reactor); - this->MaybeCallOnCancel(reactor); + read_ops_.set_core_cq_tag(&read_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); // Inlineable OnDone can be false here because there is no read // reactor that has an inlineable OnDone; this only applies to the // DefaultReactor (which is unary). this->MaybeDone(/*inlineable_ondone=*/false); - } - - ~ServerCallbackReaderImpl() {} - - ResponseType* response() { return &resp_; } - + } + + ~ServerCallbackReaderImpl() {} + + ResponseType* response() { return &resp_; } + void CallOnDone() override { reactor_.load(std::memory_order_relaxed)->OnDone(); grpc_call* call = call_.call(); @@ -401,107 +401,107 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { this->~ServerCallbackReaderImpl(); // explicitly call destructor ::grpc::g_core_codegen_interface->grpc_call_unref(call); call_requester(); - } - - ServerReactor* reactor() override { - return reactor_.load(std::memory_order_relaxed); - } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallbackWithSuccessTag meta_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; - ::grpc::internal::CallbackWithSuccessTag finish_tag_; - ::grpc::internal::CallOpSet< - ::grpc::internal::CallOpRecvMessage<RequestType>> - read_ops_; - ::grpc::internal::CallbackWithSuccessTag read_tag_; - + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet< + ::grpc::internal::CallOpRecvMessage<RequestType>> + read_ops_; + ::grpc::internal::CallbackWithSuccessTag read_tag_; + ::grpc::CallbackServerContext* const ctx_; - ::grpc::internal::Call call_; - ResponseType resp_; - std::function<void()> call_requester_; - // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. - std::atomic<ServerReadReactor<RequestType>*> reactor_; - // callbacks_outstanding_ follows a refcount pattern - std::atomic<intptr_t> callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template <class RequestType, class ResponseType> -class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { - public: - explicit CallbackServerStreamingHandler( - std::function<ServerWriteReactor<ResponseType>*( + ::grpc::internal::Call call_; + ResponseType resp_; + std::function<void()> call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic<ServerReadReactor<RequestType>*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic<intptr_t> callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template <class RequestType, class ResponseType> +class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackServerStreamingHandler( + std::function<ServerWriteReactor<ResponseType>*( ::grpc::CallbackServerContext*, const RequestType*)> - get_reactor) - : get_reactor_(std::move(get_reactor)) {} - void RunHandler(const HandlerParameter& param) final { - // Arena allocate a writer structure - ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); - - auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackWriterImpl))) - ServerCallbackWriterImpl( + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + // Arena allocate a writer structure + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackWriterImpl))) + ServerCallbackWriterImpl( static_cast<::grpc::CallbackServerContext*>(param.server_context), - param.call, static_cast<RequestType*>(param.request), - std::move(param.call_requester)); + param.call, static_cast<RequestType*>(param.request), + std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there // is no write reactor that has an inlineable OnDone; this only applies to // the DefaultReactor (which is unary). - param.server_context->BeginCompletionOp( + param.server_context->BeginCompletionOp( param.call, [writer](bool) { writer->MaybeDone(/*inlineable_ondone=*/false); }, writer); - - ServerWriteReactor<ResponseType>* reactor = nullptr; - if (param.status.ok()) { - reactor = ::grpc::internal::CatchingReactorGetter< - ServerWriteReactor<ResponseType>>( - get_reactor_, + + ServerWriteReactor<ResponseType>* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerWriteReactor<ResponseType>>( + get_reactor_, static_cast<::grpc::CallbackServerContext*>(param.server_context), - writer->request()); - } - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(UnimplementedWriteReactor<ResponseType>))) - UnimplementedWriteReactor<ResponseType>( - ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); - } - - writer->SetupReactor(reactor); - } - - void* Deserialize(grpc_call* call, grpc_byte_buffer* req, - ::grpc::Status* status, void** /*handler_data*/) final { - ::grpc::ByteBuffer buf; - buf.set_buffer(req); - auto* request = - new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - call, sizeof(RequestType))) RequestType(); - *status = - ::grpc::SerializationTraits<RequestType>::Deserialize(&buf, request); - buf.Release(); - if (status->ok()) { - return request; - } - request->~RequestType(); - return nullptr; - } - - private: - std::function<ServerWriteReactor<ResponseType>*( + writer->request()); + } + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(UnimplementedWriteReactor<ResponseType>))) + UnimplementedWriteReactor<ResponseType>( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + writer->SetupReactor(reactor); + } + + void* Deserialize(grpc_call* call, grpc_byte_buffer* req, + ::grpc::Status* status, void** /*handler_data*/) final { + ::grpc::ByteBuffer buf; + buf.set_buffer(req); + auto* request = + new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + call, sizeof(RequestType))) RequestType(); + *status = + ::grpc::SerializationTraits<RequestType>::Deserialize(&buf, request); + buf.Release(); + if (status->ok()) { + return request; + } + request->~RequestType(); + return nullptr; + } + + private: + std::function<ServerWriteReactor<ResponseType>*( ::grpc::CallbackServerContext*, const RequestType*)> - get_reactor_; - - class ServerCallbackWriterImpl : public ServerCallbackWriter<ResponseType> { - public: - void Finish(::grpc::Status s) override { + get_reactor_; + + class ServerCallbackWriterImpl : public ServerCallbackWriter<ResponseType> { + public: + void Finish(::grpc::Status s) override { // A finish tag with only MaybeDone can have its callback inlined // regardless even if OnDone is not inlineable because this callback just // checks a ref and then decides whether or not to dispatch OnDone. @@ -513,85 +513,85 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { this->MaybeDone(/*inlineable_ondone=*/false); }, &finish_ops_, /*can_inline=*/true); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - this->Ref(); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); // The callback for this function should not be inlined because it invokes // a user-controlled reaction, but any resulting OnDone can be inlined in // the executor to which this callback is dispatched. - meta_tag_.Set(call_.call(), - [this](bool ok) { + meta_tag_.Set(call_.call(), + [this](bool ok) { ServerWriteReactor<ResponseType>* reactor = reactor_.load(std::memory_order_relaxed); reactor->OnSendInitialMetadataDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &meta_ops_, /*can_inline=*/false); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, - ::grpc::WriteOptions options) override { - this->Ref(); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, - ::grpc::Status s) override { - // This combines the write into the finish callback + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + this->Ref(); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { + // This combines the write into the finish callback // TODO(vjpai): don't assert GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - Finish(std::move(s)); - } - - private: - friend class CallbackServerStreamingHandler<RequestType, ResponseType>; - + Finish(std::move(s)); + } + + private: + friend class CallbackServerStreamingHandler<RequestType, ResponseType>; + ServerCallbackWriterImpl(::grpc::CallbackServerContext* ctx, - ::grpc::internal::Call* call, - const RequestType* req, - std::function<void()> call_requester) - : ctx_(ctx), - call_(*call), - req_(req), - call_requester_(std::move(call_requester)) {} - - void SetupReactor(ServerWriteReactor<ResponseType>* reactor) { - reactor_.store(reactor, std::memory_order_relaxed); + ::grpc::internal::Call* call, + const RequestType* req, + std::function<void()> call_requester) + : ctx_(ctx), + call_(*call), + req_(req), + call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerWriteReactor<ResponseType>* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); // The callback for this function should not be inlined because it invokes // a user-controlled reaction, but any resulting OnDone can be inlined in // the executor to which this callback is dispatched. @@ -601,18 +601,18 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { this->MaybeDone(/*inlineable_ondone=*/true); }, &write_ops_, /*can_inline=*/false); - write_ops_.set_core_cq_tag(&write_tag_); - this->BindReactor(reactor); - this->MaybeCallOnCancel(reactor); + write_ops_.set_core_cq_tag(&write_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); // Inlineable OnDone can be false here because there is no write // reactor that has an inlineable OnDone; this only applies to the // DefaultReactor (which is unary). this->MaybeDone(/*inlineable_ondone=*/false); - } - ~ServerCallbackWriterImpl() { req_->~RequestType(); } - - const RequestType* request() { return req_; } - + } + ~ServerCallbackWriterImpl() { req_->~RequestType(); } + + const RequestType* request() { return req_; } + void CallOnDone() override { reactor_.load(std::memory_order_relaxed)->OnDone(); grpc_call* call = call_.call(); @@ -620,90 +620,90 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { this->~ServerCallbackWriterImpl(); // explicitly call destructor ::grpc::g_core_codegen_interface->grpc_call_unref(call); call_requester(); - } - - ServerReactor* reactor() override { - return reactor_.load(std::memory_order_relaxed); - } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallbackWithSuccessTag meta_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; - ::grpc::internal::CallbackWithSuccessTag finish_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage> - write_ops_; - ::grpc::internal::CallbackWithSuccessTag write_tag_; - + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + write_ops_; + ::grpc::internal::CallbackWithSuccessTag write_tag_; + ::grpc::CallbackServerContext* const ctx_; - ::grpc::internal::Call call_; - const RequestType* req_; - std::function<void()> call_requester_; - // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. - std::atomic<ServerWriteReactor<ResponseType>*> reactor_; - // callbacks_outstanding_ follows a refcount pattern - std::atomic<intptr_t> callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -template <class RequestType, class ResponseType> -class CallbackBidiHandler : public ::grpc::internal::MethodHandler { - public: - explicit CallbackBidiHandler( - std::function<ServerBidiReactor<RequestType, ResponseType>*( + ::grpc::internal::Call call_; + const RequestType* req_; + std::function<void()> call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic<ServerWriteReactor<ResponseType>*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic<intptr_t> callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +template <class RequestType, class ResponseType> +class CallbackBidiHandler : public ::grpc::internal::MethodHandler { + public: + explicit CallbackBidiHandler( + std::function<ServerBidiReactor<RequestType, ResponseType>*( ::grpc::CallbackServerContext*)> - get_reactor) - : get_reactor_(std::move(get_reactor)) {} - void RunHandler(const HandlerParameter& param) final { - ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); - - auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) - ServerCallbackReaderWriterImpl( + get_reactor) + : get_reactor_(std::move(get_reactor)) {} + void RunHandler(const HandlerParameter& param) final { + ::grpc::g_core_codegen_interface->grpc_call_ref(param.call->call()); + + auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) + ServerCallbackReaderWriterImpl( static_cast<::grpc::CallbackServerContext*>(param.server_context), - param.call, std::move(param.call_requester)); + param.call, std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there // is no bidi reactor that has an inlineable OnDone; this only applies to // the DefaultReactor (which is unary). - param.server_context->BeginCompletionOp( + param.server_context->BeginCompletionOp( param.call, [stream](bool) { stream->MaybeDone(/*inlineable_ondone=*/false); }, stream); - - ServerBidiReactor<RequestType, ResponseType>* reactor = nullptr; - if (param.status.ok()) { - reactor = ::grpc::internal::CatchingReactorGetter< - ServerBidiReactor<RequestType, ResponseType>>( + + ServerBidiReactor<RequestType, ResponseType>* reactor = nullptr; + if (param.status.ok()) { + reactor = ::grpc::internal::CatchingReactorGetter< + ServerBidiReactor<RequestType, ResponseType>>( get_reactor_, static_cast<::grpc::CallbackServerContext*>(param.server_context)); - } - - if (reactor == nullptr) { - // if deserialization or reactor creator failed, we need to fail the call - reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( - param.call->call(), - sizeof(UnimplementedBidiReactor<RequestType, ResponseType>))) - UnimplementedBidiReactor<RequestType, ResponseType>( - ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); - } - - stream->SetupReactor(reactor); - } - - private: - std::function<ServerBidiReactor<RequestType, ResponseType>*( + } + + if (reactor == nullptr) { + // if deserialization or reactor creator failed, we need to fail the call + reactor = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( + param.call->call(), + sizeof(UnimplementedBidiReactor<RequestType, ResponseType>))) + UnimplementedBidiReactor<RequestType, ResponseType>( + ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } + + stream->SetupReactor(reactor); + } + + private: + std::function<ServerBidiReactor<RequestType, ResponseType>*( ::grpc::CallbackServerContext*)> - get_reactor_; - - class ServerCallbackReaderWriterImpl - : public ServerCallbackReaderWriter<RequestType, ResponseType> { - public: - void Finish(::grpc::Status s) override { + get_reactor_; + + class ServerCallbackReaderWriterImpl + : public ServerCallbackReaderWriter<RequestType, ResponseType> { + public: + void Finish(::grpc::Status s) override { // A finish tag with only MaybeDone can have its callback inlined // regardless even if OnDone is not inlineable because this callback just // checks a ref and then decides whether or not to dispatch OnDone. @@ -715,86 +715,86 @@ class CallbackBidiHandler : public ::grpc::internal::MethodHandler { this->MaybeDone(/*inlineable_ondone=*/false); }, &finish_ops_, /*can_inline=*/true); - finish_ops_.set_core_cq_tag(&finish_tag_); - - if (!ctx_->sent_initial_metadata_) { - finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - finish_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); - call_.PerformOps(&finish_ops_); - } - - void SendInitialMetadata() override { - GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); - this->Ref(); + finish_ops_.set_core_cq_tag(&finish_tag_); + + if (!ctx_->sent_initial_metadata_) { + finish_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + finish_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + finish_ops_.ServerSendStatus(&ctx_->trailing_metadata_, s); + call_.PerformOps(&finish_ops_); + } + + void SendInitialMetadata() override { + GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); + this->Ref(); // The callback for this function should not be inlined because it invokes // a user-controlled reaction, but any resulting OnDone can be inlined in // the executor to which this callback is dispatched. - meta_tag_.Set(call_.call(), - [this](bool ok) { + meta_tag_.Set(call_.call(), + [this](bool ok) { ServerBidiReactor<RequestType, ResponseType>* reactor = reactor_.load(std::memory_order_relaxed); reactor->OnSendInitialMetadataDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &meta_ops_, /*can_inline=*/false); - meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - meta_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - meta_ops_.set_core_cq_tag(&meta_tag_); - call_.PerformOps(&meta_ops_); - } - - void Write(const ResponseType* resp, - ::grpc::WriteOptions options) override { - this->Ref(); - if (options.is_last_message()) { - options.set_buffer_hint(); - } - if (!ctx_->sent_initial_metadata_) { - write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - if (ctx_->compression_level_set()) { - write_ops_.set_compression_level(ctx_->compression_level()); - } - ctx_->sent_initial_metadata_ = true; - } - // TODO(vjpai): don't assert - GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); - call_.PerformOps(&write_ops_); - } - - void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, - ::grpc::Status s) override { + meta_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + meta_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + meta_ops_.set_core_cq_tag(&meta_tag_); + call_.PerformOps(&meta_ops_); + } + + void Write(const ResponseType* resp, + ::grpc::WriteOptions options) override { + this->Ref(); + if (options.is_last_message()) { + options.set_buffer_hint(); + } + if (!ctx_->sent_initial_metadata_) { + write_ops_.SendInitialMetadata(&ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + if (ctx_->compression_level_set()) { + write_ops_.set_compression_level(ctx_->compression_level()); + } + ctx_->sent_initial_metadata_ = true; + } + // TODO(vjpai): don't assert + GPR_CODEGEN_ASSERT(write_ops_.SendMessagePtr(resp, options).ok()); + call_.PerformOps(&write_ops_); + } + + void WriteAndFinish(const ResponseType* resp, ::grpc::WriteOptions options, + ::grpc::Status s) override { // TODO(vjpai): don't assert GPR_CODEGEN_ASSERT(finish_ops_.SendMessagePtr(resp, options).ok()); - Finish(std::move(s)); - } - - void Read(RequestType* req) override { - this->Ref(); - read_ops_.RecvMessage(req); - call_.PerformOps(&read_ops_); - } - - private: - friend class CallbackBidiHandler<RequestType, ResponseType>; - + Finish(std::move(s)); + } + + void Read(RequestType* req) override { + this->Ref(); + read_ops_.RecvMessage(req); + call_.PerformOps(&read_ops_); + } + + private: + friend class CallbackBidiHandler<RequestType, ResponseType>; + ServerCallbackReaderWriterImpl(::grpc::CallbackServerContext* ctx, - ::grpc::internal::Call* call, - std::function<void()> call_requester) - : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} - - void SetupReactor(ServerBidiReactor<RequestType, ResponseType>* reactor) { - reactor_.store(reactor, std::memory_order_relaxed); + ::grpc::internal::Call* call, + std::function<void()> call_requester) + : ctx_(ctx), call_(*call), call_requester_(std::move(call_requester)) {} + + void SetupReactor(ServerBidiReactor<RequestType, ResponseType>* reactor) { + reactor_.store(reactor, std::memory_order_relaxed); // The callbacks for these functions should not be inlined because they // invoke user-controlled reactions, but any resulting OnDones can be // inlined in the executor to which a callback is dispatched. @@ -804,22 +804,22 @@ class CallbackBidiHandler : public ::grpc::internal::MethodHandler { this->MaybeDone(/*inlineable_ondone=*/true); }, &write_ops_, /*can_inline=*/false); - write_ops_.set_core_cq_tag(&write_tag_); - read_tag_.Set(call_.call(), + write_ops_.set_core_cq_tag(&write_tag_); + read_tag_.Set(call_.call(), [this, reactor](bool ok) { reactor->OnReadDone(ok); this->MaybeDone(/*inlineable_ondone=*/true); - }, + }, &read_ops_, /*can_inline=*/false); - read_ops_.set_core_cq_tag(&read_tag_); - this->BindReactor(reactor); - this->MaybeCallOnCancel(reactor); + read_ops_.set_core_cq_tag(&read_tag_); + this->BindReactor(reactor); + this->MaybeCallOnCancel(reactor); // Inlineable OnDone can be false here because there is no bidi // reactor that has an inlineable OnDone; this only applies to the // DefaultReactor (which is unary). this->MaybeDone(/*inlineable_ondone=*/false); - } - + } + void CallOnDone() override { reactor_.load(std::memory_order_relaxed)->OnDone(); grpc_call* call = call_.call(); @@ -827,41 +827,41 @@ class CallbackBidiHandler : public ::grpc::internal::MethodHandler { this->~ServerCallbackReaderWriterImpl(); // explicitly call destructor ::grpc::g_core_codegen_interface->grpc_call_unref(call); call_requester(); - } - - ServerReactor* reactor() override { - return reactor_.load(std::memory_order_relaxed); - } - - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> - meta_ops_; - ::grpc::internal::CallbackWithSuccessTag meta_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage, - ::grpc::internal::CallOpServerSendStatus> - finish_ops_; - ::grpc::internal::CallbackWithSuccessTag finish_tag_; - ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, - ::grpc::internal::CallOpSendMessage> - write_ops_; - ::grpc::internal::CallbackWithSuccessTag write_tag_; - ::grpc::internal::CallOpSet< - ::grpc::internal::CallOpRecvMessage<RequestType>> - read_ops_; - ::grpc::internal::CallbackWithSuccessTag read_tag_; - + } + + ServerReactor* reactor() override { + return reactor_.load(std::memory_order_relaxed); + } + + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata> + meta_ops_; + ::grpc::internal::CallbackWithSuccessTag meta_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage, + ::grpc::internal::CallOpServerSendStatus> + finish_ops_; + ::grpc::internal::CallbackWithSuccessTag finish_tag_; + ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, + ::grpc::internal::CallOpSendMessage> + write_ops_; + ::grpc::internal::CallbackWithSuccessTag write_tag_; + ::grpc::internal::CallOpSet< + ::grpc::internal::CallOpRecvMessage<RequestType>> + read_ops_; + ::grpc::internal::CallbackWithSuccessTag read_tag_; + ::grpc::CallbackServerContext* const ctx_; - ::grpc::internal::Call call_; - std::function<void()> call_requester_; - // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. - std::atomic<ServerBidiReactor<RequestType, ResponseType>*> reactor_; - // callbacks_outstanding_ follows a refcount pattern - std::atomic<intptr_t> callbacks_outstanding_{ - 3}; // reserve for OnStarted, Finish, and CompletionOp - }; -}; - -} // namespace internal + ::grpc::internal::Call call_; + std::function<void()> call_requester_; + // The memory ordering of reactor_ follows ServerCallbackUnaryImpl. + std::atomic<ServerBidiReactor<RequestType, ResponseType>*> reactor_; + // callbacks_outstanding_ follows a refcount pattern + std::atomic<intptr_t> callbacks_outstanding_{ + 3}; // reserve for OnStarted, Finish, and CompletionOp + }; +}; + +} // namespace internal } // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H + +#endif // GRPCPP_IMPL_CODEGEN_SERVER_CALLBACK_HANDLERS_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_context.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_context.h index 4a6963c382..685f006cda 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_context.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_context.h @@ -97,12 +97,12 @@ class Server; class ServerInterface; // TODO(vjpai): Remove namespace experimental when de-experimentalized fully. -namespace experimental { +namespace experimental { typedef ::grpc::ServerContextBase ServerContextBase; typedef ::grpc::CallbackServerContext CallbackServerContext; -} // namespace experimental +} // namespace experimental #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL namespace experimental { diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interceptor.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interceptor.h index 6acfa57648..7598e72a40 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interceptor.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interceptor.h @@ -27,7 +27,7 @@ #include <grpcpp/impl/codegen/string_ref.h> namespace grpc { -class ServerContextBase; +class ServerContextBase; namespace internal { class InterceptorBatchMethodsImpl; } @@ -58,7 +58,7 @@ class ServerRpcInfo { /// Type categorizes RPCs by unary or streaming type enum class Type { UNARY, CLIENT_STREAMING, SERVER_STREAMING, BIDI_STREAMING }; - ~ServerRpcInfo() {} + ~ServerRpcInfo() {} // Delete all copy and move constructors and assignments ServerRpcInfo(const ServerRpcInfo&) = delete; @@ -94,7 +94,7 @@ class ServerRpcInfo { ServerRpcInfo(ServerContextBase* ctx, const char* method, internal::RpcMethod::RpcType type) - : ctx_(ctx), method_(method), type_(static_cast<Type>(type)) {} + : ctx_(ctx), method_(method), type_(static_cast<Type>(type)) {} // Runs interceptor at pos \a pos. void RunInterceptor( @@ -116,9 +116,9 @@ class ServerRpcInfo { } } - void Ref() { ref_.fetch_add(1, std::memory_order_relaxed); } + void Ref() { ref_.fetch_add(1, std::memory_order_relaxed); } void Unref() { - if (GPR_UNLIKELY(ref_.fetch_sub(1, std::memory_order_acq_rel) == 1)) { + if (GPR_UNLIKELY(ref_.fetch_sub(1, std::memory_order_acq_rel) == 1)) { delete this; } } @@ -126,7 +126,7 @@ class ServerRpcInfo { ServerContextBase* ctx_ = nullptr; const char* method_ = nullptr; const Type type_; - std::atomic<intptr_t> ref_{1}; + std::atomic<intptr_t> ref_{1}; std::vector<std::unique_ptr<experimental::Interceptor>> interceptors_; friend class internal::InterceptorBatchMethodsImpl; diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interface.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interface.h index 41151a67f1..d97b725025 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interface.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/server_interface.h @@ -27,18 +27,18 @@ #include <grpcpp/impl/codegen/call_hook.h> #include <grpcpp/impl/codegen/completion_queue_tag.h> #include <grpcpp/impl/codegen/core_codegen_interface.h> -#include <grpcpp/impl/codegen/interceptor_common.h> +#include <grpcpp/impl/codegen/interceptor_common.h> #include <grpcpp/impl/codegen/rpc_service_method.h> #include <grpcpp/impl/codegen/server_context.h> namespace grpc { - + class AsyncGenericService; -class Channel; -class CompletionQueue; +class Channel; +class CompletionQueue; class GenericServerContext; -class ServerCompletionQueue; -class ServerCredentials; +class ServerCompletionQueue; +class ServerCredentials; class Service; extern CoreCodegenInterface* g_core_codegen_interface; @@ -51,17 +51,17 @@ class ServerAsyncStreamingInterface; } // namespace internal #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL -namespace experimental { +namespace experimental { #endif -class CallbackGenericService; +class CallbackGenericService; #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL } // namespace experimental #endif namespace experimental { -class ServerInterceptorFactoryInterface; -} // namespace experimental - +class ServerInterceptorFactoryInterface; +} // namespace experimental + class ServerInterface : public internal::CallHook { public: virtual ~ServerInterface() {} @@ -138,26 +138,26 @@ class ServerInterface : public internal::CallHook { virtual void RegisterCallbackGenericService(CallbackGenericService* /*service*/) {} #else - /// NOTE: class experimental_registration_interface is not part of the public - /// API of this class - /// TODO(vjpai): Move these contents to public API when no longer experimental - class experimental_registration_interface { - public: - virtual ~experimental_registration_interface() {} - /// May not be abstract since this is a post-1.0 API addition - virtual void RegisterCallbackGenericService( - experimental::CallbackGenericService* /*service*/) {} - }; - - /// NOTE: The function experimental_registration() is not stable public API. - /// It is a view to the experimental components of this class. It may be - /// changed or removed at any time. May not be abstract since this is a - /// post-1.0 API addition - virtual experimental_registration_interface* experimental_registration() { - return nullptr; - } + /// NOTE: class experimental_registration_interface is not part of the public + /// API of this class + /// TODO(vjpai): Move these contents to public API when no longer experimental + class experimental_registration_interface { + public: + virtual ~experimental_registration_interface() {} + /// May not be abstract since this is a post-1.0 API addition + virtual void RegisterCallbackGenericService( + experimental::CallbackGenericService* /*service*/) {} + }; + + /// NOTE: The function experimental_registration() is not stable public API. + /// It is a view to the experimental components of this class. It may be + /// changed or removed at any time. May not be abstract since this is a + /// post-1.0 API addition + virtual experimental_registration_interface* experimental_registration() { + return nullptr; + } #endif - + /// Tries to bind \a server to the given \a addr. /// /// It can be invoked multiple times. @@ -166,7 +166,7 @@ class ServerInterface : public internal::CallHook { /// 192.168.1.1:31416, [::1]:27182, etc.). /// \params creds The credentials associated with the server. /// - /// \return bound port number on success, 0 on failure. + /// \return bound port number on success, 0 on failure. /// /// \warning It's an error to call this method on an already started server. virtual int AddListeningPort(const TString& addr, @@ -220,20 +220,20 @@ class ServerInterface : public internal::CallHook { /// RegisteredAsyncRequest is not part of the C++ API class RegisteredAsyncRequest : public BaseAsyncRequest { public: - RegisteredAsyncRequest(ServerInterface* server, + RegisteredAsyncRequest(ServerInterface* server, ::grpc::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag, const char* name, - internal::RpcMethod::RpcType type); + void* tag, const char* name, + internal::RpcMethod::RpcType type); virtual bool FinalizeResult(void** tag, bool* status) override { /* If we are done intercepting, then there is nothing more for us to do */ if (done_intercepting_) { return BaseAsyncRequest::FinalizeResult(tag, status); } - call_wrapper_ = ::grpc::internal::Call( + call_wrapper_ = ::grpc::internal::Call( call_, server_, call_cq_, server_->max_receive_message_size(), context_->set_server_rpc_info(name_, type_, *server_->interceptor_creators())); @@ -250,12 +250,12 @@ class ServerInterface : public internal::CallHook { class NoPayloadAsyncRequest final : public RegisteredAsyncRequest { public: NoPayloadAsyncRequest(internal::RpcServiceMethod* registered_method, - ServerInterface* server, + ServerInterface* server, ::grpc::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag) + void* tag) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()) { @@ -273,7 +273,7 @@ class ServerInterface : public internal::CallHook { internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag, Message* request) + void* tag, Message* request) : RegisteredAsyncRequest( server, context, stream, call_cq, notification_cq, tag, registered_method->name(), registered_method->method_type()), @@ -329,7 +329,7 @@ class ServerInterface : public internal::CallHook { internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag, bool delete_on_finalize); + void* tag, bool delete_on_finalize); bool FinalizeResult(void** tag, bool* status) override; @@ -343,7 +343,7 @@ class ServerInterface : public internal::CallHook { internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag, Message* message) { + void* tag, Message* message) { GPR_CODEGEN_ASSERT(method); new PayloadAsyncRequest<Message>(method, this, context, stream, call_cq, notification_cq, tag, message); @@ -354,7 +354,7 @@ class ServerInterface : public internal::CallHook { internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag) { + void* tag) { GPR_CODEGEN_ASSERT(method); new NoPayloadAsyncRequest(method, this, context, stream, call_cq, notification_cq, tag); diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/service_type.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/service_type.h index 266d093ea6..30be904a3c 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/service_type.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/service_type.h @@ -30,8 +30,8 @@ namespace grpc { class CompletionQueue; class ServerContext; -class ServerInterface; - +class ServerInterface; + namespace internal { class Call; class ServerAsyncStreamingInterface { @@ -59,8 +59,8 @@ class Service { virtual ~Service() {} bool has_async_methods() const { - for (const auto& method : methods_) { - if (method && method->handler() == nullptr) { + for (const auto& method : methods_) { + if (method && method->handler() == nullptr) { return true; } } @@ -68,9 +68,9 @@ class Service { } bool has_synchronous_methods() const { - for (const auto& method : methods_) { - if (method && - method->api_type() == internal::RpcServiceMethod::ApiType::SYNC) { + for (const auto& method : methods_) { + if (method && + method->api_type() == internal::RpcServiceMethod::ApiType::SYNC) { return true; } } @@ -78,11 +78,11 @@ class Service { } bool has_callback_methods() const { - for (const auto& method : methods_) { - if (method && (method->api_type() == - internal::RpcServiceMethod::ApiType::CALL_BACK || - method->api_type() == - internal::RpcServiceMethod::ApiType::RAW_CALL_BACK)) { + for (const auto& method : methods_) { + if (method && (method->api_type() == + internal::RpcServiceMethod::ApiType::CALL_BACK || + method->api_type() == + internal::RpcServiceMethod::ApiType::RAW_CALL_BACK)) { return true; } } @@ -90,8 +90,8 @@ class Service { } bool has_generic_methods() const { - for (const auto& method : methods_) { - if (method.get() == nullptr) { + for (const auto& method : methods_) { + if (method.get() == nullptr) { return true; } } @@ -112,10 +112,10 @@ class Service { service_->MarkMethodRawCallbackInternal(index, handler); } - internal::MethodHandler* GetHandler(int index) { + internal::MethodHandler* GetHandler(int index) { return service_->GetHandlerInternal(index); - } - + } + private: Service* service_; }; @@ -124,11 +124,11 @@ class Service { template <class Message> void RequestAsyncUnary(int index, ::grpc::ServerContext* context, - Message* request, + Message* request, internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, - void* tag) { + void* tag) { // Typecast the index to size_t for indexing into a vector // while preserving the API that existed before a compiler // warning was first seen (grpc/grpc#11664) @@ -138,7 +138,7 @@ class Service { } void RequestAsyncClientStreaming( int index, ::grpc::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, + internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast<size_t>(index); @@ -148,7 +148,7 @@ class Service { template <class Message> void RequestAsyncServerStreaming( int index, ::grpc::ServerContext* context, Message* request, - internal::ServerAsyncStreamingInterface* stream, + internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast<size_t>(index); @@ -157,7 +157,7 @@ class Service { } void RequestAsyncBidiStreaming( int index, ::grpc::ServerContext* context, - internal::ServerAsyncStreamingInterface* stream, + internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag) { size_t idx = static_cast<size_t>(index); diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/status_code_enum.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/status_code_enum.h index f47ee068ed..bdd7ead6ad 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/status_code_enum.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/status_code_enum.h @@ -119,8 +119,8 @@ enum StatusCode { INTERNAL = 13, /// The service is currently unavailable. This is a most likely a transient - /// condition and may be corrected by retrying with a backoff. Note that it is - /// not always safe to retry non-idempotent operations. + /// condition and may be corrected by retrying with a backoff. Note that it is + /// not always safe to retry non-idempotent operations. /// /// \warning Although data MIGHT not have been transmitted when this /// status occurs, there is NOT A GUARANTEE that the server has not seen diff --git a/contrib/libs/grpc/include/grpcpp/impl/codegen/sync.h b/contrib/libs/grpc/include/grpcpp/impl/codegen/sync.h index 0d058c091f..146f182e57 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/codegen/sync.h +++ b/contrib/libs/grpc/include/grpcpp/impl/codegen/sync.h @@ -1,151 +1,151 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_IMPL_CODEGEN_SYNC_H -#define GRPCPP_IMPL_CODEGEN_SYNC_H - -#include <grpc/impl/codegen/port_platform.h> - -#ifdef GPR_HAS_PTHREAD_H -#include <pthread.h> -#endif - -#include <mutex> - -#include <grpc/impl/codegen/log.h> -#include <grpc/impl/codegen/sync.h> - -#include <grpcpp/impl/codegen/core_codegen_interface.h> - -// The core library is not accessible in C++ codegen headers, and vice versa. -// Thus, we need to have duplicate headers with similar functionality. -// Make sure any change to this file is also reflected in -// src/core/lib/gprpp/sync.h too. -// -// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file, -// since in core we do not rely on g_core_codegen_interface and hence do not -// pay the costs of virtual function calls. - -namespace grpc { -namespace internal { - -class Mutex { - public: - Mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); } - ~Mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); } - - Mutex(const Mutex&) = delete; - Mutex& operator=(const Mutex&) = delete; - - gpr_mu* get() { return &mu_; } - const gpr_mu* get() const { return &mu_; } - - private: - union { - gpr_mu mu_; - std::mutex do_not_use_sth_; -#ifdef GPR_HAS_PTHREAD_H - pthread_mutex_t do_not_use_pth_; -#endif - }; -}; - -// MutexLock is a std:: -class MutexLock { - public: - explicit MutexLock(Mutex* mu) : mu_(mu->get()) { - g_core_codegen_interface->gpr_mu_lock(mu_); - } - explicit MutexLock(gpr_mu* mu) : mu_(mu) { - g_core_codegen_interface->gpr_mu_lock(mu_); - } - ~MutexLock() { g_core_codegen_interface->gpr_mu_unlock(mu_); } - - MutexLock(const MutexLock&) = delete; - MutexLock& operator=(const MutexLock&) = delete; - - private: - gpr_mu* const mu_; -}; - -class ReleasableMutexLock { - public: - explicit ReleasableMutexLock(Mutex* mu) : mu_(mu->get()) { - g_core_codegen_interface->gpr_mu_lock(mu_); - } - explicit ReleasableMutexLock(gpr_mu* mu) : mu_(mu) { - g_core_codegen_interface->gpr_mu_lock(mu_); - } - ~ReleasableMutexLock() { - if (!released_) g_core_codegen_interface->gpr_mu_unlock(mu_); - } - - ReleasableMutexLock(const ReleasableMutexLock&) = delete; - ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; - - void Lock() { - GPR_DEBUG_ASSERT(released_); - g_core_codegen_interface->gpr_mu_lock(mu_); - released_ = false; - } - - void Unlock() { - GPR_DEBUG_ASSERT(!released_); - released_ = true; - g_core_codegen_interface->gpr_mu_unlock(mu_); - } - - private: - gpr_mu* const mu_; - bool released_ = false; -}; - -class CondVar { - public: - CondVar() { g_core_codegen_interface->gpr_cv_init(&cv_); } - ~CondVar() { g_core_codegen_interface->gpr_cv_destroy(&cv_); } - - CondVar(const CondVar&) = delete; - CondVar& operator=(const CondVar&) = delete; - - void Signal() { g_core_codegen_interface->gpr_cv_signal(&cv_); } - void Broadcast() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); } - - int Wait(Mutex* mu) { - return Wait(mu, - g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); - } - int Wait(Mutex* mu, const gpr_timespec& deadline) { - return g_core_codegen_interface->gpr_cv_wait(&cv_, mu->get(), deadline); - } - - template <typename Predicate> - void WaitUntil(Mutex* mu, Predicate pred) { - while (!pred()) { - Wait(mu, g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); - } - } - - private: - gpr_cv cv_; -}; - -} // namespace internal -} // namespace grpc - -#endif // GRPCPP_IMPL_CODEGEN_SYNC_H +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_IMPL_CODEGEN_SYNC_H +#define GRPCPP_IMPL_CODEGEN_SYNC_H + +#include <grpc/impl/codegen/port_platform.h> + +#ifdef GPR_HAS_PTHREAD_H +#include <pthread.h> +#endif + +#include <mutex> + +#include <grpc/impl/codegen/log.h> +#include <grpc/impl/codegen/sync.h> + +#include <grpcpp/impl/codegen/core_codegen_interface.h> + +// The core library is not accessible in C++ codegen headers, and vice versa. +// Thus, we need to have duplicate headers with similar functionality. +// Make sure any change to this file is also reflected in +// src/core/lib/gprpp/sync.h too. +// +// Whenever possible, prefer "src/core/lib/gprpp/sync.h" over this file, +// since in core we do not rely on g_core_codegen_interface and hence do not +// pay the costs of virtual function calls. + +namespace grpc { +namespace internal { + +class Mutex { + public: + Mutex() { g_core_codegen_interface->gpr_mu_init(&mu_); } + ~Mutex() { g_core_codegen_interface->gpr_mu_destroy(&mu_); } + + Mutex(const Mutex&) = delete; + Mutex& operator=(const Mutex&) = delete; + + gpr_mu* get() { return &mu_; } + const gpr_mu* get() const { return &mu_; } + + private: + union { + gpr_mu mu_; + std::mutex do_not_use_sth_; +#ifdef GPR_HAS_PTHREAD_H + pthread_mutex_t do_not_use_pth_; +#endif + }; +}; + +// MutexLock is a std:: +class MutexLock { + public: + explicit MutexLock(Mutex* mu) : mu_(mu->get()) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + explicit MutexLock(gpr_mu* mu) : mu_(mu) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + ~MutexLock() { g_core_codegen_interface->gpr_mu_unlock(mu_); } + + MutexLock(const MutexLock&) = delete; + MutexLock& operator=(const MutexLock&) = delete; + + private: + gpr_mu* const mu_; +}; + +class ReleasableMutexLock { + public: + explicit ReleasableMutexLock(Mutex* mu) : mu_(mu->get()) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + explicit ReleasableMutexLock(gpr_mu* mu) : mu_(mu) { + g_core_codegen_interface->gpr_mu_lock(mu_); + } + ~ReleasableMutexLock() { + if (!released_) g_core_codegen_interface->gpr_mu_unlock(mu_); + } + + ReleasableMutexLock(const ReleasableMutexLock&) = delete; + ReleasableMutexLock& operator=(const ReleasableMutexLock&) = delete; + + void Lock() { + GPR_DEBUG_ASSERT(released_); + g_core_codegen_interface->gpr_mu_lock(mu_); + released_ = false; + } + + void Unlock() { + GPR_DEBUG_ASSERT(!released_); + released_ = true; + g_core_codegen_interface->gpr_mu_unlock(mu_); + } + + private: + gpr_mu* const mu_; + bool released_ = false; +}; + +class CondVar { + public: + CondVar() { g_core_codegen_interface->gpr_cv_init(&cv_); } + ~CondVar() { g_core_codegen_interface->gpr_cv_destroy(&cv_); } + + CondVar(const CondVar&) = delete; + CondVar& operator=(const CondVar&) = delete; + + void Signal() { g_core_codegen_interface->gpr_cv_signal(&cv_); } + void Broadcast() { g_core_codegen_interface->gpr_cv_broadcast(&cv_); } + + int Wait(Mutex* mu) { + return Wait(mu, + g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); + } + int Wait(Mutex* mu, const gpr_timespec& deadline) { + return g_core_codegen_interface->gpr_cv_wait(&cv_, mu->get(), deadline); + } + + template <typename Predicate> + void WaitUntil(Mutex* mu, Predicate pred) { + while (!pred()) { + Wait(mu, g_core_codegen_interface->gpr_inf_future(GPR_CLOCK_REALTIME)); + } + } + + private: + gpr_cv cv_; +}; + +} // namespace internal +} // namespace grpc + +#endif // GRPCPP_IMPL_CODEGEN_SYNC_H diff --git a/contrib/libs/grpc/include/grpcpp/impl/server_builder_plugin.h b/contrib/libs/grpc/include/grpcpp/impl/server_builder_plugin.h index fbb178f21e..8fedca2b14 100644 --- a/contrib/libs/grpc/include/grpcpp/impl/server_builder_plugin.h +++ b/contrib/libs/grpc/include/grpcpp/impl/server_builder_plugin.h @@ -25,7 +25,7 @@ #include <memory> -#include <grpcpp/support/channel_arguments.h> +#include <grpcpp/support/channel_arguments.h> #include <grpcpp/support/config.h> namespace grpc { @@ -59,7 +59,7 @@ class ServerBuilderPlugin { /// UpdateChannelArguments will be called in ServerBuilder::BuildAndStart(), /// before the Server instance is created. - virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} + virtual void UpdateChannelArguments(ChannelArguments* /*args*/) {} virtual bool has_sync_methods() const { return false; } virtual bool has_async_methods() const { return false; } diff --git a/contrib/libs/grpc/include/grpcpp/security/credentials.h b/contrib/libs/grpc/include/grpcpp/security/credentials.h index 090886f283..339e9d4c27 100644 --- a/contrib/libs/grpc/include/grpcpp/security/credentials.h +++ b/contrib/libs/grpc/include/grpcpp/security/credentials.h @@ -58,7 +58,7 @@ std::shared_ptr<grpc::Channel> CreateCustomChannelWithInterceptors( std::vector< std::unique_ptr<grpc::experimental::ClientInterceptorFactoryInterface>> interceptor_creators); -} +} /// A channel credentials object encapsulates all the state needed by a client /// to authenticate with a server for a given channel. @@ -265,7 +265,7 @@ class MetadataCredentialsPlugin { std::shared_ptr<CallCredentials> MetadataCredentialsFromPlugin( std::unique_ptr<MetadataCredentialsPlugin> plugin); -namespace experimental { +namespace experimental { /// Options for creating STS Oauth Token Exchange credentials following the IETF /// draft https://tools.ietf.org/html/draft-ietf-oauth-token-exchange-16. @@ -314,7 +314,7 @@ std::shared_ptr<ChannelCredentials> AltsCredentials( /// Builds Local Credentials. std::shared_ptr<ChannelCredentials> LocalCredentials( grpc_local_connect_type type); - + /// Builds TLS Credentials given TLS options. std::shared_ptr<ChannelCredentials> TlsCredentials( const TlsCredentialsOptions& options); diff --git a/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h b/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h index 09f9e5ea29..7874debae8 100644 --- a/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h +++ b/contrib/libs/grpc/include/grpcpp/security/cronet_credentials.h @@ -1,33 +1,33 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SECURITY_CRONET_CREDENTIALS_H -#define GRPCPP_SECURITY_CRONET_CREDENTIALS_H - +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_CRONET_CREDENTIALS_H +#define GRPCPP_SECURITY_CRONET_CREDENTIALS_H + #include <memory> - -namespace grpc { - + +namespace grpc { + class ChannelCredentials; - + /// Credentials for a channel using Cronet. std::shared_ptr<ChannelCredentials> CronetChannelCredentials(void* engine); -} // namespace grpc - -#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_H +} // namespace grpc + +#endif // GRPCPP_SECURITY_CRONET_CREDENTIALS_H diff --git a/contrib/libs/grpc/include/grpcpp/security/server_credentials.h b/contrib/libs/grpc/include/grpcpp/security/server_credentials.h index 4b41d492b1..d0a532360a 100644 --- a/contrib/libs/grpc/include/grpcpp/security/server_credentials.h +++ b/contrib/libs/grpc/include/grpcpp/security/server_credentials.h @@ -103,10 +103,10 @@ std::shared_ptr<ServerCredentials> AltsServerCredentials( std::shared_ptr<ServerCredentials> LocalServerCredentials( grpc_local_connect_type type); -/// Builds TLS ServerCredentials given TLS options. +/// Builds TLS ServerCredentials given TLS options. std::shared_ptr<ServerCredentials> TlsServerCredentials( const experimental::TlsCredentialsOptions& options); - + } // namespace experimental } // namespace grpc diff --git a/contrib/libs/grpc/include/grpcpp/security/tls_credentials_options.h b/contrib/libs/grpc/include/grpcpp/security/tls_credentials_options.h index 20c3d7ba05..f704cf6129 100644 --- a/contrib/libs/grpc/include/grpcpp/security/tls_credentials_options.h +++ b/contrib/libs/grpc/include/grpcpp/security/tls_credentials_options.h @@ -1,283 +1,283 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H -#define GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H - -#include <grpc/grpc_security_constants.h> -#include <grpc/status.h> -#include <grpc/support/log.h> -#include <grpcpp/support/config.h> - +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H +#define GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H + +#include <grpc/grpc_security_constants.h> +#include <grpc/status.h> +#include <grpc/support/log.h> +#include <grpcpp/support/config.h> + #include <memory> #include <vector> -typedef struct grpc_tls_credential_reload_arg grpc_tls_credential_reload_arg; -typedef struct grpc_tls_credential_reload_config - grpc_tls_credential_reload_config; -typedef struct grpc_tls_server_authorization_check_arg - grpc_tls_server_authorization_check_arg; -typedef struct grpc_tls_server_authorization_check_config - grpc_tls_server_authorization_check_config; -typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; - +typedef struct grpc_tls_credential_reload_arg grpc_tls_credential_reload_arg; +typedef struct grpc_tls_credential_reload_config + grpc_tls_credential_reload_config; +typedef struct grpc_tls_server_authorization_check_arg + grpc_tls_server_authorization_check_arg; +typedef struct grpc_tls_server_authorization_check_config + grpc_tls_server_authorization_check_config; +typedef struct grpc_tls_credentials_options grpc_tls_credentials_options; + namespace grpc { -namespace experimental { - -/** TLS key materials config, wrapper for grpc_tls_key_materials_config. It is - * used for experimental purposes for now and subject to change. **/ -class TlsKeyMaterialsConfig { - public: - struct PemKeyCertPair { +namespace experimental { + +/** TLS key materials config, wrapper for grpc_tls_key_materials_config. It is + * used for experimental purposes for now and subject to change. **/ +class TlsKeyMaterialsConfig { + public: + struct PemKeyCertPair { TString private_key; TString cert_chain; - }; - - /** Getters for member fields. **/ + }; + + /** Getters for member fields. **/ const TString pem_root_certs() const { return pem_root_certs_; } - const std::vector<PemKeyCertPair>& pem_key_cert_pair_list() const { - return pem_key_cert_pair_list_; - } - int version() const { return version_; } - + const std::vector<PemKeyCertPair>& pem_key_cert_pair_list() const { + return pem_key_cert_pair_list_; + } + int version() const { return version_; } + /** Setter for key materials that will be called by the user. Ownership of the * arguments will not be transferred. **/ void set_pem_root_certs(const TString& pem_root_certs); - void add_pem_key_cert_pair(const PemKeyCertPair& pem_key_cert_pair); + void add_pem_key_cert_pair(const PemKeyCertPair& pem_key_cert_pair); void set_key_materials( const TString& pem_root_certs, const std::vector<PemKeyCertPair>& pem_key_cert_pair_list); - void set_version(int version) { version_ = version; }; - - private: - int version_ = 0; - std::vector<PemKeyCertPair> pem_key_cert_pair_list_; + void set_version(int version) { version_ = version; }; + + private: + int version_ = 0; + std::vector<PemKeyCertPair> pem_key_cert_pair_list_; TString pem_root_certs_; -}; - -/** TLS credential reload arguments, wraps grpc_tls_credential_reload_arg. It is +}; + +/** TLS credential reload arguments, wraps grpc_tls_credential_reload_arg. It is * used for experimental purposes for now and it is subject to change. - * + * * The credential reload arg contains all the info necessary to schedule/cancel * a credential reload request. The callback function must be called after * finishing the schedule operation. See the description of the * grpc_tls_credential_reload_arg struct in grpc_security.h for more details. - * **/ -class TlsCredentialReloadArg { - public: - /** TlsCredentialReloadArg does not take ownership of the C arg that is passed + * **/ +class TlsCredentialReloadArg { + public: + /** TlsCredentialReloadArg does not take ownership of the C arg that is passed * to the constructor. One must remember to free any memory allocated to the * C arg after using the setter functions below. **/ - TlsCredentialReloadArg(grpc_tls_credential_reload_arg* arg); - ~TlsCredentialReloadArg(); - + TlsCredentialReloadArg(grpc_tls_credential_reload_arg* arg); + ~TlsCredentialReloadArg(); + /** Getters for member fields. **/ - void* cb_user_data() const; - bool is_pem_key_cert_pair_list_empty() const; - grpc_ssl_certificate_config_reload_status status() const; + void* cb_user_data() const; + bool is_pem_key_cert_pair_list_empty() const; + grpc_ssl_certificate_config_reload_status status() const; TString error_details() const; - + /** Setters for member fields. Ownership of the arguments will not be * transferred. **/ - void set_cb_user_data(void* cb_user_data); + void set_cb_user_data(void* cb_user_data); void set_pem_root_certs(const TString& pem_root_certs); - void add_pem_key_cert_pair( + void add_pem_key_cert_pair( const TlsKeyMaterialsConfig::PemKeyCertPair& pem_key_cert_pair); void set_key_materials(const TString& pem_root_certs, std::vector<TlsKeyMaterialsConfig::PemKeyCertPair> pem_key_cert_pair_list); - void set_key_materials_config( - const std::shared_ptr<TlsKeyMaterialsConfig>& key_materials_config); - void set_status(grpc_ssl_certificate_config_reload_status status); + void set_key_materials_config( + const std::shared_ptr<TlsKeyMaterialsConfig>& key_materials_config); + void set_status(grpc_ssl_certificate_config_reload_status status); void set_error_details(const TString& error_details); - - /** Calls the C arg's callback function. **/ - void OnCredentialReloadDoneCallback(); - - private: - grpc_tls_credential_reload_arg* c_arg_; -}; - -/** An interface that the application derives and uses to instantiate a - * TlsCredentialReloadConfig instance. Refer to the definition of the - * grpc_tls_credential_reload_config in grpc_tls_credentials_options.h for more - * details on the expectations of the member functions of the interface. **/ -struct TlsCredentialReloadInterface { - virtual ~TlsCredentialReloadInterface() = default; - /** A callback that invokes the credential reload. **/ - virtual int Schedule(TlsCredentialReloadArg* arg) = 0; - /** A callback that cancels a credential reload request. **/ - virtual void Cancel(TlsCredentialReloadArg* /* arg */) {} -}; - -/** TLS credential reloag config, wraps grpc_tls_credential_reload_config. It is - * used for experimental purposes for now and it is subject to change. **/ -class TlsCredentialReloadConfig { - public: - TlsCredentialReloadConfig(std::shared_ptr<TlsCredentialReloadInterface> - credential_reload_interface); - ~TlsCredentialReloadConfig(); - - int Schedule(TlsCredentialReloadArg* arg) const { - if (credential_reload_interface_ == nullptr) { - gpr_log(GPR_ERROR, "credential reload interface is nullptr"); - if (arg != nullptr) { - arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); - arg->set_error_details( - "the interface of the credential reload config is nullptr"); - } - return 1; - } - return credential_reload_interface_->Schedule(arg); - } - - void Cancel(TlsCredentialReloadArg* arg) const { - if (credential_reload_interface_ == nullptr) { - gpr_log(GPR_ERROR, "credential reload interface is nullptr"); - if (arg != nullptr) { - arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); - arg->set_error_details( - "the interface of the credential reload config is nullptr"); - } - return; - } - credential_reload_interface_->Cancel(arg); - } - - /** Returns a C struct for the credential reload config. **/ - grpc_tls_credential_reload_config* c_config() const { return c_config_; } - - private: - grpc_tls_credential_reload_config* c_config_; - std::shared_ptr<TlsCredentialReloadInterface> credential_reload_interface_; -}; - -/** TLS server authorization check arguments, wraps - * grpc_tls_server_authorization_check_arg. It is used for experimental - * purposes for now and it is subject to change. - * - * The server authorization check arg contains all the info necessary to - * schedule/cancel a server authorization check request. The callback function - * must be called after finishing the schedule operation. See the description - * of the grpc_tls_server_authorization_check_arg struct in grpc_security.h for - * more details. **/ -class TlsServerAuthorizationCheckArg { - public: - /** TlsServerAuthorizationCheckArg does not take ownership of the C arg passed - * to the constructor. One must remember to free any memory allocated to the - * C arg after using the setter functions below. **/ - TlsServerAuthorizationCheckArg(grpc_tls_server_authorization_check_arg* arg); - ~TlsServerAuthorizationCheckArg(); - + + /** Calls the C arg's callback function. **/ + void OnCredentialReloadDoneCallback(); + + private: + grpc_tls_credential_reload_arg* c_arg_; +}; + +/** An interface that the application derives and uses to instantiate a + * TlsCredentialReloadConfig instance. Refer to the definition of the + * grpc_tls_credential_reload_config in grpc_tls_credentials_options.h for more + * details on the expectations of the member functions of the interface. **/ +struct TlsCredentialReloadInterface { + virtual ~TlsCredentialReloadInterface() = default; + /** A callback that invokes the credential reload. **/ + virtual int Schedule(TlsCredentialReloadArg* arg) = 0; + /** A callback that cancels a credential reload request. **/ + virtual void Cancel(TlsCredentialReloadArg* /* arg */) {} +}; + +/** TLS credential reloag config, wraps grpc_tls_credential_reload_config. It is + * used for experimental purposes for now and it is subject to change. **/ +class TlsCredentialReloadConfig { + public: + TlsCredentialReloadConfig(std::shared_ptr<TlsCredentialReloadInterface> + credential_reload_interface); + ~TlsCredentialReloadConfig(); + + int Schedule(TlsCredentialReloadArg* arg) const { + if (credential_reload_interface_ == nullptr) { + gpr_log(GPR_ERROR, "credential reload interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + arg->set_error_details( + "the interface of the credential reload config is nullptr"); + } + return 1; + } + return credential_reload_interface_->Schedule(arg); + } + + void Cancel(TlsCredentialReloadArg* arg) const { + if (credential_reload_interface_ == nullptr) { + gpr_log(GPR_ERROR, "credential reload interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_SSL_CERTIFICATE_CONFIG_RELOAD_FAIL); + arg->set_error_details( + "the interface of the credential reload config is nullptr"); + } + return; + } + credential_reload_interface_->Cancel(arg); + } + + /** Returns a C struct for the credential reload config. **/ + grpc_tls_credential_reload_config* c_config() const { return c_config_; } + + private: + grpc_tls_credential_reload_config* c_config_; + std::shared_ptr<TlsCredentialReloadInterface> credential_reload_interface_; +}; + +/** TLS server authorization check arguments, wraps + * grpc_tls_server_authorization_check_arg. It is used for experimental + * purposes for now and it is subject to change. + * + * The server authorization check arg contains all the info necessary to + * schedule/cancel a server authorization check request. The callback function + * must be called after finishing the schedule operation. See the description + * of the grpc_tls_server_authorization_check_arg struct in grpc_security.h for + * more details. **/ +class TlsServerAuthorizationCheckArg { + public: + /** TlsServerAuthorizationCheckArg does not take ownership of the C arg passed + * to the constructor. One must remember to free any memory allocated to the + * C arg after using the setter functions below. **/ + TlsServerAuthorizationCheckArg(grpc_tls_server_authorization_check_arg* arg); + ~TlsServerAuthorizationCheckArg(); + /** Getters for member fields. **/ - void* cb_user_data() const; - int success() const; + void* cb_user_data() const; + int success() const; TString target_name() const; TString peer_cert() const; TString peer_cert_full_chain() const; - grpc_status_code status() const; + grpc_status_code status() const; TString error_details() const; - + /** Setters for member fields. **/ - void set_cb_user_data(void* cb_user_data); - void set_success(int success); + void set_cb_user_data(void* cb_user_data); + void set_success(int success); void set_target_name(const TString& target_name); void set_peer_cert(const TString& peer_cert); void set_peer_cert_full_chain(const TString& peer_cert_full_chain); - void set_status(grpc_status_code status); + void set_status(grpc_status_code status); void set_error_details(const TString& error_details); - - /** Calls the C arg's callback function. **/ - void OnServerAuthorizationCheckDoneCallback(); - - private: - grpc_tls_server_authorization_check_arg* c_arg_; -}; - -/** An interface that the application derives and uses to instantiate a - * TlsServerAuthorizationCheckConfig instance. Refer to the definition of the - * grpc_tls_server_authorization_check_config in grpc_tls_credentials_options.h - * for more details on the expectations of the member functions of the - * interface. - * **/ -struct TlsServerAuthorizationCheckInterface { - virtual ~TlsServerAuthorizationCheckInterface() = default; - /** A callback that invokes the server authorization check. **/ - virtual int Schedule(TlsServerAuthorizationCheckArg* arg) = 0; - /** A callback that cancels a server authorization check request. **/ - virtual void Cancel(TlsServerAuthorizationCheckArg* /* arg */) {} -}; - -/** TLS server authorization check config, wraps - * grps_tls_server_authorization_check_config. It is used for experimental - * purposes for now and it is subject to change. **/ -class TlsServerAuthorizationCheckConfig { - public: - TlsServerAuthorizationCheckConfig( - std::shared_ptr<TlsServerAuthorizationCheckInterface> - server_authorization_check_interface); - ~TlsServerAuthorizationCheckConfig(); - - int Schedule(TlsServerAuthorizationCheckArg* arg) const { - if (server_authorization_check_interface_ == nullptr) { - gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); - if (arg != nullptr) { - arg->set_status(GRPC_STATUS_NOT_FOUND); - arg->set_error_details( - "the interface of the server authorization check config is " - "nullptr"); - } - return 1; - } - return server_authorization_check_interface_->Schedule(arg); - } - - void Cancel(TlsServerAuthorizationCheckArg* arg) const { - if (server_authorization_check_interface_ == nullptr) { - gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); - if (arg != nullptr) { - arg->set_status(GRPC_STATUS_NOT_FOUND); - arg->set_error_details( - "the interface of the server authorization check config is " - "nullptr"); - } - return; - } - server_authorization_check_interface_->Cancel(arg); - } - - /** Returns C struct for the server authorization check config. **/ - grpc_tls_server_authorization_check_config* c_config() const { - return c_config_; - } - - private: - grpc_tls_server_authorization_check_config* c_config_; - std::shared_ptr<TlsServerAuthorizationCheckInterface> - server_authorization_check_interface_; -}; - -/** TLS credentials options, wrapper for grpc_tls_credentials_options. It is - * used for experimental purposes for now and it is subject to change. See the - * description of the grpc_tls_credentials_options struct in grpc_security.h for - * more details. **/ -class TlsCredentialsOptions { - public: + + /** Calls the C arg's callback function. **/ + void OnServerAuthorizationCheckDoneCallback(); + + private: + grpc_tls_server_authorization_check_arg* c_arg_; +}; + +/** An interface that the application derives and uses to instantiate a + * TlsServerAuthorizationCheckConfig instance. Refer to the definition of the + * grpc_tls_server_authorization_check_config in grpc_tls_credentials_options.h + * for more details on the expectations of the member functions of the + * interface. + * **/ +struct TlsServerAuthorizationCheckInterface { + virtual ~TlsServerAuthorizationCheckInterface() = default; + /** A callback that invokes the server authorization check. **/ + virtual int Schedule(TlsServerAuthorizationCheckArg* arg) = 0; + /** A callback that cancels a server authorization check request. **/ + virtual void Cancel(TlsServerAuthorizationCheckArg* /* arg */) {} +}; + +/** TLS server authorization check config, wraps + * grps_tls_server_authorization_check_config. It is used for experimental + * purposes for now and it is subject to change. **/ +class TlsServerAuthorizationCheckConfig { + public: + TlsServerAuthorizationCheckConfig( + std::shared_ptr<TlsServerAuthorizationCheckInterface> + server_authorization_check_interface); + ~TlsServerAuthorizationCheckConfig(); + + int Schedule(TlsServerAuthorizationCheckArg* arg) const { + if (server_authorization_check_interface_ == nullptr) { + gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_STATUS_NOT_FOUND); + arg->set_error_details( + "the interface of the server authorization check config is " + "nullptr"); + } + return 1; + } + return server_authorization_check_interface_->Schedule(arg); + } + + void Cancel(TlsServerAuthorizationCheckArg* arg) const { + if (server_authorization_check_interface_ == nullptr) { + gpr_log(GPR_ERROR, "server authorization check interface is nullptr"); + if (arg != nullptr) { + arg->set_status(GRPC_STATUS_NOT_FOUND); + arg->set_error_details( + "the interface of the server authorization check config is " + "nullptr"); + } + return; + } + server_authorization_check_interface_->Cancel(arg); + } + + /** Returns C struct for the server authorization check config. **/ + grpc_tls_server_authorization_check_config* c_config() const { + return c_config_; + } + + private: + grpc_tls_server_authorization_check_config* c_config_; + std::shared_ptr<TlsServerAuthorizationCheckInterface> + server_authorization_check_interface_; +}; + +/** TLS credentials options, wrapper for grpc_tls_credentials_options. It is + * used for experimental purposes for now and it is subject to change. See the + * description of the grpc_tls_credentials_options struct in grpc_security.h for + * more details. **/ +class TlsCredentialsOptions { + public: // Constructor for client. explicit TlsCredentialsOptions( grpc_tls_server_verification_option server_verification_option, @@ -293,53 +293,53 @@ class TlsCredentialsOptions { std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config); // This constructor will be deprecated. - TlsCredentialsOptions( - grpc_ssl_client_certificate_request_type cert_request_type, + TlsCredentialsOptions( + grpc_ssl_client_certificate_request_type cert_request_type, grpc_tls_server_verification_option server_verification_option, - std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config, - std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config, - std::shared_ptr<TlsServerAuthorizationCheckConfig> - server_authorization_check_config); - ~TlsCredentialsOptions(); - - /** Getters for member fields. **/ - grpc_ssl_client_certificate_request_type cert_request_type() const { - return cert_request_type_; - } + std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config, + std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config, + std::shared_ptr<TlsServerAuthorizationCheckConfig> + server_authorization_check_config); + ~TlsCredentialsOptions(); + + /** Getters for member fields. **/ + grpc_ssl_client_certificate_request_type cert_request_type() const { + return cert_request_type_; + } grpc_tls_server_verification_option server_verification_option() const { return server_verification_option_; } - std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config() const { - return key_materials_config_; - } - std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config() const { - return credential_reload_config_; - } - std::shared_ptr<TlsServerAuthorizationCheckConfig> - server_authorization_check_config() const { - return server_authorization_check_config_; - } - grpc_tls_credentials_options* c_credentials_options() const { - return c_credentials_options_; - } - - private: - /** The cert_request_type_ flag is only relevant when the - * TlsCredentialsOptions are used to instantiate server credentials; the flag - * goes unused when creating channel credentials, and the user can set it to - * GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE. **/ - grpc_ssl_client_certificate_request_type cert_request_type_; + std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config() const { + return key_materials_config_; + } + std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config() const { + return credential_reload_config_; + } + std::shared_ptr<TlsServerAuthorizationCheckConfig> + server_authorization_check_config() const { + return server_authorization_check_config_; + } + grpc_tls_credentials_options* c_credentials_options() const { + return c_credentials_options_; + } + + private: + /** The cert_request_type_ flag is only relevant when the + * TlsCredentialsOptions are used to instantiate server credentials; the flag + * goes unused when creating channel credentials, and the user can set it to + * GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE. **/ + grpc_ssl_client_certificate_request_type cert_request_type_; /** The server_verification_option_ flag is only relevant when the * TlsCredentialsOptions are used to instantiate client credentials; **/ grpc_tls_server_verification_option server_verification_option_; - std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config_; - std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config_; - std::shared_ptr<TlsServerAuthorizationCheckConfig> - server_authorization_check_config_; - grpc_tls_credentials_options* c_credentials_options_; -}; - -} // namespace experimental + std::shared_ptr<TlsKeyMaterialsConfig> key_materials_config_; + std::shared_ptr<TlsCredentialReloadConfig> credential_reload_config_; + std::shared_ptr<TlsServerAuthorizationCheckConfig> + server_authorization_check_config_; + grpc_tls_credentials_options* c_credentials_options_; +}; + +} // namespace experimental } // namespace grpc - -#endif // GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H + +#endif // GRPCPP_SECURITY_TLS_CREDENTIALS_OPTIONS_H diff --git a/contrib/libs/grpc/include/grpcpp/support/channel_arguments.h b/contrib/libs/grpc/include/grpcpp/support/channel_arguments.h index 70e7fd9988..85b6ee7dcc 100644 --- a/contrib/libs/grpc/include/grpcpp/support/channel_arguments.h +++ b/contrib/libs/grpc/include/grpcpp/support/channel_arguments.h @@ -32,7 +32,7 @@ #include <grpcpp/support/config.h> namespace grpc { -class SecureChannelCredentials; +class SecureChannelCredentials; namespace testing { class ChannelArgumentsTest; } // namespace testing diff --git a/contrib/libs/grpc/include/grpcpp/support/message_allocator.h b/contrib/libs/grpc/include/grpcpp/support/message_allocator.h index 70ee0ac269..20ce072b90 100644 --- a/contrib/libs/grpc/include/grpcpp/support/message_allocator.h +++ b/contrib/libs/grpc/include/grpcpp/support/message_allocator.h @@ -1,24 +1,24 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H -#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H - -#include <grpcpp/impl/codegen/message_allocator.h> - -#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H +#define GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H + +#include <grpcpp/impl/codegen/message_allocator.h> + +#endif // GRPCPP_SUPPORT_MESSAGE_ALLOCATOR_H diff --git a/contrib/libs/grpc/include/grpcpp/support/method_handler.h b/contrib/libs/grpc/include/grpcpp/support/method_handler.h index 990d9c9e4f..038e76c8af 100644 --- a/contrib/libs/grpc/include/grpcpp/support/method_handler.h +++ b/contrib/libs/grpc/include/grpcpp/support/method_handler.h @@ -1,24 +1,24 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H -#define GRPCPP_SUPPORT_METHOD_HANDLER_H - -#include <grpcpp/impl/codegen/method_handler.h> - -#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_METHOD_HANDLER_H +#define GRPCPP_SUPPORT_METHOD_HANDLER_H + +#include <grpcpp/impl/codegen/method_handler.h> + +#endif // GRPCPP_SUPPORT_METHOD_HANDLER_H diff --git a/contrib/libs/grpc/include/grpcpp/support/validate_service_config.h b/contrib/libs/grpc/include/grpcpp/support/validate_service_config.h index 4812817ede..f1368623b5 100644 --- a/contrib/libs/grpc/include/grpcpp/support/validate_service_config.h +++ b/contrib/libs/grpc/include/grpcpp/support/validate_service_config.h @@ -1,36 +1,36 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H -#define GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H - -#include <grpcpp/support/config.h> - -namespace grpc { - -namespace experimental { -/// Validates \a service_config_json. If valid, returns an empty string. -/// Otherwise, returns the validation error. -/// TODO(yashykt): Promote it to out of experimental once it is proved useful -/// and gRFC is accepted. +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H +#define GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H + +#include <grpcpp/support/config.h> + +namespace grpc { + +namespace experimental { +/// Validates \a service_config_json. If valid, returns an empty string. +/// Otherwise, returns the validation error. +/// TODO(yashykt): Promote it to out of experimental once it is proved useful +/// and gRFC is accepted. TString ValidateServiceConfigJSON(const TString& service_config_json); -} // namespace experimental - -} // namespace grpc - -#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H +} // namespace experimental + +} // namespace grpc + +#endif // GRPCPP_SUPPORT_VALIDATE_SERVICE_CONFIG_H diff --git a/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h b/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h index 8a237378e4..a792e6f94a 100644 --- a/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h +++ b/contrib/libs/grpc/include/grpcpp/test/default_reactor_test_peer.h @@ -1,58 +1,58 @@ -/* - * - * Copyright 2019 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H -#define GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H - -#include <grpcpp/server_context.h> -#include <grpcpp/support/server_callback.h> - -namespace grpc { -namespace testing { - -/// A test-only class to monitor the behavior of the ServerContext's -/// DefaultReactor. It is intended for allow unit-testing of a callback API -/// service via direct invocation of the service methods rather than through -/// RPCs. It is only applicable for unary RPC methods that use the +/* + * + * Copyright 2019 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H +#define GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H + +#include <grpcpp/server_context.h> +#include <grpcpp/support/server_callback.h> + +namespace grpc { +namespace testing { + +/// A test-only class to monitor the behavior of the ServerContext's +/// DefaultReactor. It is intended for allow unit-testing of a callback API +/// service via direct invocation of the service methods rather than through +/// RPCs. It is only applicable for unary RPC methods that use the /// DefaultReactor rather than any user-defined reactor. If it is used, it must /// be created before the RPC is invoked so that it can bind the reactor into a /// test mode rather than letting it follow the normal paths. -class DefaultReactorTestPeer { - public: - explicit DefaultReactorTestPeer(experimental::CallbackServerContext* ctx) - : DefaultReactorTestPeer(ctx, [](::grpc::Status) {}) {} - DefaultReactorTestPeer(experimental::CallbackServerContext* ctx, - std::function<void(::grpc::Status)> finish_func) - : ctx_(ctx) { - ctx->SetupTestDefaultReactor(std::move(finish_func)); - } - ::grpc::experimental::ServerUnaryReactor* reactor() const { +class DefaultReactorTestPeer { + public: + explicit DefaultReactorTestPeer(experimental::CallbackServerContext* ctx) + : DefaultReactorTestPeer(ctx, [](::grpc::Status) {}) {} + DefaultReactorTestPeer(experimental::CallbackServerContext* ctx, + std::function<void(::grpc::Status)> finish_func) + : ctx_(ctx) { + ctx->SetupTestDefaultReactor(std::move(finish_func)); + } + ::grpc::experimental::ServerUnaryReactor* reactor() const { return reinterpret_cast<experimental::ServerUnaryReactor*>( &ctx_->default_reactor_); - } - bool test_status_set() const { return ctx_->test_status_set(); } - Status test_status() const { return ctx_->test_status(); } - - private: - experimental::CallbackServerContext* const ctx_; // not owned -}; - -} // namespace testing -} // namespace grpc - -#endif // GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H + } + bool test_status_set() const { return ctx_->test_status_set(); } + Status test_status() const { return ctx_->test_status(); } + + private: + experimental::CallbackServerContext* const ctx_; // not owned +}; + +} // namespace testing +} // namespace grpc + +#endif // GRPCPP_TEST_DEFAULT_REACTOR_TEST_PEER_H diff --git a/contrib/libs/grpc/include/grpcpp/test/mock_stream.h b/contrib/libs/grpc/include/grpcpp/test/mock_stream.h index 24bbffa190..e33595d709 100644 --- a/contrib/libs/grpc/include/grpcpp/test/mock_stream.h +++ b/contrib/libs/grpc/include/grpcpp/test/mock_stream.h @@ -62,7 +62,7 @@ class MockClientWriter : public ::grpc::ClientWriterInterface<W> { }; template <class W, class R> -class MockClientReaderWriter +class MockClientReaderWriter : public ::grpc::ClientReaderWriterInterface<W, R> { public: MockClientReaderWriter() = default; diff --git a/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h b/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h index 775920c597..00c19dc4b8 100644 --- a/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h +++ b/contrib/libs/grpc/include/grpcpp/test/server_context_test_spouse.h @@ -37,11 +37,11 @@ class ServerContextTestSpouse { client_metadata_storage_.insert( std::pair<TString, TString>(key, value)); ctx_->client_metadata_.map()->clear(); - for (const auto& item : client_metadata_storage_) { + for (const auto& item : client_metadata_storage_) { ctx_->client_metadata_.map()->insert( std::pair<grpc::string_ref, grpc::string_ref>( - item.first.c_str(), - grpc::string_ref(item.second.data(), item.second.size()))); + item.first.c_str(), + grpc::string_ref(item.second.data(), item.second.size()))); } } |