diff options
author | akastornov <akastornov@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:03 +0300 |
commit | 3a2de774d91ca8d7325aaf81c200b1d2047725e6 (patch) | |
tree | 5674a780ce03a8bbd794733a19c7a70d587e4a14 /contrib/libs/grpc/src/core | |
parent | 7bd11ff35e97544d119e43447e3e865f2588ee7f (diff) | |
download | ydb-3a2de774d91ca8d7325aaf81c200b1d2047725e6.tar.gz |
Restoring authorship annotation for <akastornov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/grpc/src/core')
137 files changed, 5134 insertions, 5134 deletions
diff --git a/contrib/libs/grpc/src/core/README.md b/contrib/libs/grpc/src/core/README.md index 5dea45a692..e4c204a8f4 100644 --- a/contrib/libs/grpc/src/core/README.md +++ b/contrib/libs/grpc/src/core/README.md @@ -1,4 +1,4 @@ # Overview - + This directory contains source code for C library (a.k.a the *gRPC C core*) that provides all gRPC's core functionality through a low level API. Libraries in other languages in this repository (C++, C#, Ruby, -Python, PHP, NodeJS, Objective-C) are layered on top of this library. +Python, PHP, NodeJS, Objective-C) are layered on top of this library. diff --git a/contrib/libs/grpc/src/core/ext/README.md b/contrib/libs/grpc/src/core/ext/README.md index 0812b20823..81d492b43c 100644 --- a/contrib/libs/grpc/src/core/ext/README.md +++ b/contrib/libs/grpc/src/core/ext/README.md @@ -1,5 +1,5 @@ -Optional plugins for gRPC Core: Modules in this directory extend gRPC Core in -useful ways. All optional code belongs here. - -NOTE: The movement of code between lib and ext is an ongoing effort, so this -directory currently contains too much of the core library. +Optional plugins for gRPC Core: Modules in this directory extend gRPC Core in +useful ways. All optional code belongs here. + +NOTE: The movement of code between lib and ext is an ongoing effort, so this +directory currently contains too much of the core library. diff --git a/contrib/libs/grpc/src/core/ext/transport/README.md b/contrib/libs/grpc/src/core/ext/transport/README.md index 2290568784..70273b169e 100644 --- a/contrib/libs/grpc/src/core/ext/transport/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/README.md @@ -1 +1 @@ -Transports for gRPC +Transports for gRPC diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md index 8880a47460..1d63c5f064 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/README.md @@ -1 +1 @@ -CHTTP2 - gRPC's implementation of a HTTP2 based transport +CHTTP2 - gRPC's implementation of a HTTP2 based transport diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h index e2ffe4e405..1d0af6d7d7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/alpn/alpn.h @@ -1,36 +1,36 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H + #include <grpc/support/port_platform.h> -#include <string.h> - +#include <string.h> + /* Returns 1 if the version is supported, 0 otherwise. */ int grpc_chttp2_is_alpn_version_supported(const char* version, size_t size); - -/* Returns the number of protocol versions to advertise */ -size_t grpc_chttp2_num_alpn_versions(void); - -/* Returns the protocol version at index i (0 <= i < - * grpc_chttp2_num_alpn_versions()) */ + +/* Returns the number of protocol versions to advertise */ +size_t grpc_chttp2_num_alpn_versions(void); + +/* Returns the protocol version at index i (0 <= i < + * grpc_chttp2_num_alpn_versions()) */ const char* grpc_chttp2_get_alpn_version_index(size_t i); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_ALPN_ALPN_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h index 322cbc2eba..4e2becaafe 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/chttp2_connector.h @@ -1,32 +1,32 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H + #include <grpc/support/port_platform.h> - + #include "src/core/ext/filters/client_channel/connector.h" #include "src/core/lib/channel/handshaker.h" #include "src/core/lib/channel/handshaker_registry.h" namespace grpc_core { - + class Chttp2Connector : public SubchannelConnector { public: Chttp2Connector(); @@ -72,4 +72,4 @@ class Chttp2Connector : public SubchannelConnector { } // namespace grpc_core -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_CLIENT_CHTTP2_CONNECTOR_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md index fa11463388..df33b76a4a 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/insecure/README.md @@ -1 +1 @@ -Plugin for creating insecure channels using chttp2 +Plugin for creating insecure channels using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md index 405a86e5db..6736a4911a 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/client/secure/README.md @@ -1 +1 @@ -Plugin for creating secure channels using chttp2 +Plugin for creating secure channels using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h index 095cc5e4c0..d94880b996 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/chttp2_server.h @@ -1,38 +1,38 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> - +#include <grpc/impl/codegen/grpc_types.h> + #include "src/core/lib/iomgr/error.h" #include "src/core/lib/surface/server.h" - + namespace grpc_core { -/// Adds a port to \a server. Sets \a port_num to the port number. -/// Takes ownership of \a args. +/// Adds a port to \a server. Sets \a port_num to the port number. +/// Takes ownership of \a args. grpc_error* Chttp2ServerAddPort(Server* server, const char* addr, grpc_channel_args* args, int* port_num); - + } // namespace grpc_core -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_SERVER_CHTTP2_SERVER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md index fc0bc14ed7..74dc9e94a0 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/insecure/README.md @@ -1 +1 @@ -Plugin for creating insecure servers using chttp2 +Plugin for creating insecure servers using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md index 6bda696a9a..372c6dc24c 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/server/secure/README.md @@ -1 +1 @@ -Plugin for creating secure servers using chttp2 +Plugin for creating secure servers using chttp2 diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md index 4684e58759..7471b0243b 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/README.md @@ -1,4 +1,4 @@ -chttp2 transport plugin - implements grpc over http2 - -Used by chttp2/{client,server}/{insecure,secure} plugins to implement most of -their functionality +chttp2 transport plugin - implements grpc over http2 + +Used by chttp2/{client,server}/{insecure,secure} plugins to implement most of +their functionality diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h index 1cbca033a1..c3bc8fa701 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -1,56 +1,56 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <stdbool.h> - -struct grpc_base64_decode_context { - /* input/output: */ +#include <grpc/slice.h> +#include <stdbool.h> + +struct grpc_base64_decode_context { + /* input/output: */ const uint8_t* input_cur; const uint8_t* input_end; uint8_t* output_cur; uint8_t* output_end; - /* Indicate if the decoder should handle the tail of input data*/ - bool contains_tail; -}; - -/* base64 decode a grpc_base64_decode_context util either input_end is reached - or output_end is reached. When input_end is reached, (input_end - input_cur) - is less than 4. When output_end is reached, (output_end - output_cur) is less - than 3. Returns false if decoding is failed. */ + /* Indicate if the decoder should handle the tail of input data*/ + bool contains_tail; +}; + +/* base64 decode a grpc_base64_decode_context util either input_end is reached + or output_end is reached. When input_end is reached, (input_end - input_cur) + is less than 4. When output_end is reached, (output_end - output_cur) is less + than 3. Returns false if decoding is failed. */ bool grpc_base64_decode_partial(struct grpc_base64_decode_context* ctx); - -/* base64 decode a slice with pad chars. Returns a new slice, does not take - ownership of the input. Returns an empty slice if decoding is failed. */ + +/* base64 decode a slice with pad chars. Returns a new slice, does not take + ownership of the input. Returns an empty slice if decoding is failed. */ grpc_slice grpc_chttp2_base64_decode(const grpc_slice& input); - -/* base64 decode a slice without pad chars, data length is needed. Returns a new - slice, does not take ownership of the input. Returns an empty slice if - decoding is failed. */ + +/* base64 decode a slice without pad chars, data length is needed. Returns a new + slice, does not take ownership of the input. Returns an empty slice if + decoding is failed. */ grpc_slice grpc_chttp2_base64_decode_with_length(const grpc_slice& input, - size_t output_length); - + size_t output_length); + /* Infer the length of decoded data from encoded data. */ size_t grpc_chttp2_base64_infer_length_after_decode(const grpc_slice& slice); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h index 4f7ee67bd3..10c3523877 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -1,42 +1,42 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> - -/* base64 encode a slice. Returns a new slice, does not take ownership of the - input */ +#include <grpc/slice.h> + +/* base64 encode a slice. Returns a new slice, does not take ownership of the + input */ grpc_slice grpc_chttp2_base64_encode(const grpc_slice& input); - -/* Compress a slice with the static huffman encoder detailed in the hpack - standard. Returns a new slice, does not take ownership of the input */ + +/* Compress a slice with the static huffman encoder detailed in the hpack + standard. Returns a new slice, does not take ownership of the input */ grpc_slice grpc_chttp2_huffman_compress(const grpc_slice& input); - -/* equivalent to: - grpc_slice x = grpc_chttp2_base64_encode(input); - grpc_slice y = grpc_chttp2_huffman_compress(x); + +/* equivalent to: + grpc_slice x = grpc_chttp2_base64_encode(input); + grpc_slice y = grpc_chttp2_huffman_compress(x); grpc_slice_unref_internal( x); - return y; */ + return y; */ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress( const grpc_slice& input); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h index b04630bbe2..b2a7932eee 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -1,39 +1,39 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H + #include <grpc/support/port_platform.h> #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/transport/transport.h" - +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/transport/transport.h" + extern grpc_core::TraceFlag grpc_http_trace; extern grpc_core::TraceFlag grpc_keepalive_trace; extern grpc_core::TraceFlag grpc_trace_http2_stream_state; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_refcount; extern grpc_core::DebugOnlyTraceFlag grpc_trace_chttp2_hpack_parser; - + extern bool g_flow_control_enabled; - + grpc_transport* grpc_create_chttp2_transport( const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client, grpc_resource_user* resource_user = nullptr); @@ -41,12 +41,12 @@ grpc_transport* grpc_create_chttp2_transport( grpc_core::RefCountedPtr<grpc_core::channelz::SocketNode> grpc_chttp2_transport_get_socket_node(grpc_transport* transport); -/// Takes ownership of \a read_buffer, which (if non-NULL) contains -/// leftover bytes previously read from the endpoint (e.g., by handshakers). +/// Takes ownership of \a read_buffer, which (if non-NULL) contains +/// leftover bytes previously read from the endpoint (e.g., by handshakers). /// If non-null, \a notify_on_receive_settings will be scheduled when /// HTTP/2 settings are received from the peer. void grpc_chttp2_transport_start_reading( grpc_transport* transport, grpc_slice_buffer* read_buffer, grpc_closure* notify_on_receive_settings); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h index 083c0076e7..1f5a7b2c0f 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame.h @@ -1,47 +1,47 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H - -#include <grpc/support/port_platform.h> - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H + +#include <grpc/support/port_platform.h> + #include <grpc/slice.h> -#include "src/core/lib/iomgr/error.h" - -/* defined in internal.h */ -typedef struct grpc_chttp2_stream grpc_chttp2_stream; -typedef struct grpc_chttp2_transport grpc_chttp2_transport; - -#define GRPC_CHTTP2_FRAME_DATA 0 -#define GRPC_CHTTP2_FRAME_HEADER 1 -#define GRPC_CHTTP2_FRAME_CONTINUATION 9 -#define GRPC_CHTTP2_FRAME_RST_STREAM 3 -#define GRPC_CHTTP2_FRAME_SETTINGS 4 -#define GRPC_CHTTP2_FRAME_PING 6 -#define GRPC_CHTTP2_FRAME_GOAWAY 7 -#define GRPC_CHTTP2_FRAME_WINDOW_UPDATE 8 - -#define GRPC_CHTTP2_DATA_FLAG_END_STREAM 1 -#define GRPC_CHTTP2_FLAG_ACK 1 -#define GRPC_CHTTP2_DATA_FLAG_END_HEADERS 4 -#define GRPC_CHTTP2_DATA_FLAG_PADDED 8 -#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20 - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H */ +#include "src/core/lib/iomgr/error.h" + +/* defined in internal.h */ +typedef struct grpc_chttp2_stream grpc_chttp2_stream; +typedef struct grpc_chttp2_transport grpc_chttp2_transport; + +#define GRPC_CHTTP2_FRAME_DATA 0 +#define GRPC_CHTTP2_FRAME_HEADER 1 +#define GRPC_CHTTP2_FRAME_CONTINUATION 9 +#define GRPC_CHTTP2_FRAME_RST_STREAM 3 +#define GRPC_CHTTP2_FRAME_SETTINGS 4 +#define GRPC_CHTTP2_FRAME_PING 6 +#define GRPC_CHTTP2_FRAME_GOAWAY 7 +#define GRPC_CHTTP2_FRAME_WINDOW_UPDATE 8 + +#define GRPC_CHTTP2_DATA_FLAG_END_STREAM 1 +#define GRPC_CHTTP2_FLAG_ACK 1 +#define GRPC_CHTTP2_DATA_FLAG_END_HEADERS 4 +#define GRPC_CHTTP2_DATA_FLAG_PADDED 8 +#define GRPC_CHTTP2_FLAG_HAS_PRIORITY 0x20 + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h index ec3890098e..ee08a4d758 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_data.h @@ -1,82 +1,82 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H - -/* Parser for GRPC streams embedded in DATA frames */ - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H + +/* Parser for GRPC streams embedded in DATA frames */ + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/byte_stream.h" -#include "src/core/lib/transport/transport.h" - -typedef enum { - GRPC_CHTTP2_DATA_FH_0, - GRPC_CHTTP2_DATA_FH_1, - GRPC_CHTTP2_DATA_FH_2, - GRPC_CHTTP2_DATA_FH_3, - GRPC_CHTTP2_DATA_FH_4, - GRPC_CHTTP2_DATA_FRAME, - GRPC_CHTTP2_DATA_ERROR -} grpc_chttp2_stream_state; - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/byte_stream.h" +#include "src/core/lib/transport/transport.h" + +typedef enum { + GRPC_CHTTP2_DATA_FH_0, + GRPC_CHTTP2_DATA_FH_1, + GRPC_CHTTP2_DATA_FH_2, + GRPC_CHTTP2_DATA_FH_3, + GRPC_CHTTP2_DATA_FH_4, + GRPC_CHTTP2_DATA_FRAME, + GRPC_CHTTP2_DATA_ERROR +} grpc_chttp2_stream_state; + namespace grpc_core { class Chttp2IncomingByteStream; } // namespace grpc_core - + struct grpc_chttp2_data_parser { grpc_chttp2_data_parser() = default; ~grpc_chttp2_data_parser(); - + grpc_chttp2_stream_state state = GRPC_CHTTP2_DATA_FH_0; uint8_t frame_type = 0; uint32_t frame_size = 0; grpc_error* error = GRPC_ERROR_NONE; - + bool is_frame_compressed = false; grpc_core::Chttp2IncomingByteStream* parsing_frame = nullptr; }; - -/* start processing a new data frame */ + +/* start processing a new data frame */ grpc_error* grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser* parser, - uint8_t flags, + uint8_t flags, uint32_t stream_id, grpc_chttp2_stream* s); - -/* handle a slice of a data frame - is_last indicates the last slice of a - frame */ + +/* handle a slice of a data frame - is_last indicates the last slice of a + frame */ grpc_error* grpc_chttp2_data_parser_parse(void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer* inbuf, - uint32_t write_bytes, int is_eof, + uint32_t write_bytes, int is_eof, grpc_transport_one_way_stats* stats, grpc_slice_buffer* outbuf); - + grpc_error* grpc_deframe_unprocessed_incoming_frames( grpc_chttp2_data_parser* p, grpc_chttp2_stream* s, grpc_slice_buffer* slices, grpc_slice* slice_out, grpc_core::OrphanablePtr<grpc_core::ByteStream>* stream_out); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h index df6274d628..e3f0a15f82 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -1,49 +1,49 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" - -typedef enum { - GRPC_CHTTP2_GOAWAY_LSI0, - GRPC_CHTTP2_GOAWAY_LSI1, - GRPC_CHTTP2_GOAWAY_LSI2, - GRPC_CHTTP2_GOAWAY_LSI3, - GRPC_CHTTP2_GOAWAY_ERR0, - GRPC_CHTTP2_GOAWAY_ERR1, - GRPC_CHTTP2_GOAWAY_ERR2, - GRPC_CHTTP2_GOAWAY_ERR3, - GRPC_CHTTP2_GOAWAY_DEBUG -} grpc_chttp2_goaway_parse_state; - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" + +typedef enum { + GRPC_CHTTP2_GOAWAY_LSI0, + GRPC_CHTTP2_GOAWAY_LSI1, + GRPC_CHTTP2_GOAWAY_LSI2, + GRPC_CHTTP2_GOAWAY_LSI3, + GRPC_CHTTP2_GOAWAY_ERR0, + GRPC_CHTTP2_GOAWAY_ERR1, + GRPC_CHTTP2_GOAWAY_ERR2, + GRPC_CHTTP2_GOAWAY_ERR3, + GRPC_CHTTP2_GOAWAY_DEBUG +} grpc_chttp2_goaway_parse_state; + struct grpc_chttp2_goaway_parser { - grpc_chttp2_goaway_parse_state state; - uint32_t last_stream_id; - uint32_t error_code; + grpc_chttp2_goaway_parse_state state; + uint32_t last_stream_id; + uint32_t error_code; char* debug_data; - uint32_t debug_length; - uint32_t debug_pos; + uint32_t debug_length; + uint32_t debug_pos; }; void grpc_chttp2_goaway_parser_init(grpc_chttp2_goaway_parser* p); void grpc_chttp2_goaway_parser_destroy(grpc_chttp2_goaway_parser* p); @@ -54,9 +54,9 @@ grpc_error* grpc_chttp2_goaway_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, + +void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, const grpc_slice& debug_data, grpc_slice_buffer* slice_buffer); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h index e356bf43f0..5529c2c893 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -1,44 +1,44 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" + struct grpc_chttp2_ping_parser { - uint8_t byte; - uint8_t is_ack; + uint8_t byte; + uint8_t is_ack; uint64_t opaque_8bytes; }; grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes); - + grpc_error* grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser* parser, - uint32_t length, uint8_t flags); + uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_ping_parser_parse(void* parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + /* Test-only function for disabling ping ack */ void grpc_set_disable_ping_ack(bool disable_ping_ack); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index e324ee2cfc..93592da6aa 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -1,37 +1,37 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_rst_stream_parser { - uint8_t byte; - uint8_t reason_bytes[4]; + uint8_t byte; + uint8_t reason_bytes[4]; }; -grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, +grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats* stats); - + // Adds RST_STREAM frame to t->qbuf (buffer for the next write). Should be // called when we want to add RST_STREAM and we are not in // write_action_begin_locked. @@ -46,5 +46,5 @@ grpc_error* grpc_chttp2_rst_stream_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h index 181471401c..144d6b9de9 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -1,53 +1,53 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/ext/transport/chttp2/transport/http2_settings.h" - -typedef enum { - GRPC_CHTTP2_SPS_ID0, - GRPC_CHTTP2_SPS_ID1, - GRPC_CHTTP2_SPS_VAL0, - GRPC_CHTTP2_SPS_VAL1, - GRPC_CHTTP2_SPS_VAL2, - GRPC_CHTTP2_SPS_VAL3 -} grpc_chttp2_settings_parse_state; - + +typedef enum { + GRPC_CHTTP2_SPS_ID0, + GRPC_CHTTP2_SPS_ID1, + GRPC_CHTTP2_SPS_VAL0, + GRPC_CHTTP2_SPS_VAL1, + GRPC_CHTTP2_SPS_VAL2, + GRPC_CHTTP2_SPS_VAL3 +} grpc_chttp2_settings_parse_state; + struct grpc_chttp2_settings_parser { - grpc_chttp2_settings_parse_state state; + grpc_chttp2_settings_parse_state state; uint32_t* target_settings; - uint8_t is_ack; - uint16_t id; - uint32_t value; - uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS]; + uint8_t is_ack; + uint16_t id; + uint32_t value; + uint32_t incoming_settings[GRPC_CHTTP2_NUM_SETTINGS]; }; -/* Create a settings frame by diffing old & new, and updating old to be new */ +/* Create a settings frame by diffing old & new, and updating old to be new */ grpc_slice grpc_chttp2_settings_create(uint32_t* old, const uint32_t* newval, - uint32_t force_mask, size_t count); -/* Create an ack settings frame */ -grpc_slice grpc_chttp2_settings_ack_create(void); - + uint32_t force_mask, size_t count); +/* Create an ack settings frame */ +grpc_slice grpc_chttp2_settings_ack_create(void); + grpc_error* grpc_chttp2_settings_parser_begin_frame( grpc_chttp2_settings_parser* parser, uint32_t length, uint8_t flags, uint32_t* settings); @@ -56,5 +56,5 @@ grpc_error* grpc_chttp2_settings_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h index 340445d87a..e21b0e0ed0 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -1,38 +1,38 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_window_update_parser { - uint8_t byte; - uint8_t is_connection_update; - uint32_t amount; + uint8_t byte; + uint8_t is_connection_update; + uint32_t amount; }; -grpc_slice grpc_chttp2_window_update_create( +grpc_slice grpc_chttp2_window_update_create( uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats* stats); - + grpc_error* grpc_chttp2_window_update_parser_begin_frame( grpc_chttp2_window_update_parser* parser, uint32_t length, uint8_t flags); grpc_error* grpc_chttp2_window_update_parser_parse(void* parser, @@ -40,5 +40,5 @@ grpc_error* grpc_chttp2_window_update_parser_parse(void* parser, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 5093f80ae2..f8d1c893b7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -1,69 +1,69 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/lib/transport/metadata.h" -#include "src/core/lib/transport/metadata_batch.h" -#include "src/core/lib/transport/transport.h" - +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/metadata_batch.h" +#include "src/core/lib/transport/transport.h" + // This should be <= 8. We use 6 to save space. #define GRPC_CHTTP2_HPACKC_NUM_VALUES_BITS 6 #define GRPC_CHTTP2_HPACKC_NUM_VALUES (1 << GRPC_CHTTP2_HPACKC_NUM_VALUES_BITS) -/* initial table size, per spec */ -#define GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE 4096 -/* maximum table size we'll actually use */ -#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024) - +/* initial table size, per spec */ +#define GRPC_CHTTP2_HPACKC_INITIAL_TABLE_SIZE 4096 +/* maximum table size we'll actually use */ +#define GRPC_CHTTP2_HPACKC_MAX_TABLE_SIZE (1024 * 1024) + extern grpc_core::TraceFlag grpc_http_trace; struct grpc_chttp2_hpack_compressor { - uint32_t max_table_size; - uint32_t max_table_elems; - uint32_t cap_table_elems; - /** maximum number of bytes we'll use for the decode table (to guard against - peers ooming us by setting decode table size high) */ - uint32_t max_usable_size; - /* one before the lowest usable table index */ - uint32_t tail_remote_index; - uint32_t table_size; - uint32_t table_elems; + uint32_t max_table_size; + uint32_t max_table_elems; + uint32_t cap_table_elems; + /** maximum number of bytes we'll use for the decode table (to guard against + peers ooming us by setting decode table size high) */ + uint32_t max_usable_size; + /* one before the lowest usable table index */ + uint32_t tail_remote_index; + uint32_t table_size; + uint32_t table_elems; uint16_t* table_elem_size; /** if non-zero, advertise to the decoder that we'll start using a table of this size */ uint8_t advertise_table_size_change; - - /* filter tables for elems: this tables provides an approximate - popularity count for particular hashes, and are used to determine whether - a new literal should be added to the compression table or not. - They track a single integer that counts how often a particular value has - been seen. When that count reaches max (255), all values are halved. */ + + /* filter tables for elems: this tables provides an approximate + popularity count for particular hashes, and are used to determine whether + a new literal should be added to the compression table or not. + They track a single integer that counts how often a particular value has + been seen. When that count reaches max (255), all values are halved. */ uint32_t filter_elems_sum; uint8_t filter_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES]; - - /* entry tables for keys & elems: these tables track values that have been - seen and *may* be in the decompressor table */ + + /* entry tables for keys & elems: these tables track values that have been + seen and *may* be in the decompressor table */ struct { struct { grpc_mdelem value; @@ -82,14 +82,14 @@ struct grpc_chttp2_hpack_compressor { } entries[GRPC_CHTTP2_HPACKC_NUM_VALUES]; } key_table; /* Key table management */ }; - + void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor* c); void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor* c); -void grpc_chttp2_hpack_compressor_set_max_table_size( +void grpc_chttp2_hpack_compressor_set_max_table_size( grpc_chttp2_hpack_compressor* c, uint32_t max_table_size); -void grpc_chttp2_hpack_compressor_set_max_usable_size( +void grpc_chttp2_hpack_compressor_set_max_usable_size( grpc_chttp2_hpack_compressor* c, uint32_t max_table_size); - + struct grpc_encode_header_options { uint32_t stream_id; bool is_eof; @@ -104,4 +104,4 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor* c, const grpc_encode_header_options* options, grpc_slice_buffer* outbuf); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h index 1b859c4d7c..dc45940986 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -1,37 +1,37 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/ext/transport/chttp2/transport/hpack_table.h" -#include "src/core/lib/transport/metadata.h" - -typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; - +#include <stddef.h> + +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/hpack_table.h" +#include "src/core/lib/transport/metadata.h" + +typedef struct grpc_chttp2_hpack_parser grpc_chttp2_hpack_parser; + typedef grpc_error* (*grpc_chttp2_hpack_parser_state)( grpc_chttp2_hpack_parser* p, const uint8_t* beg, const uint8_t* end); - + struct grpc_chttp2_hpack_parser_string { bool copied; struct { @@ -43,31 +43,31 @@ struct grpc_chttp2_hpack_parser_string { } copied; } data; }; -struct grpc_chttp2_hpack_parser { - /* user specified callback for each header output */ +struct grpc_chttp2_hpack_parser { + /* user specified callback for each header output */ grpc_error* (*on_header)(void* user_data, grpc_mdelem md); void* on_header_user_data; - + grpc_error* last_error; - - /* current parse state - or a function that implements it */ - grpc_chttp2_hpack_parser_state state; - /* future states dependent on the opening op code */ + + /* current parse state - or a function that implements it */ + grpc_chttp2_hpack_parser_state state; + /* future states dependent on the opening op code */ const grpc_chttp2_hpack_parser_state* next_state; - /* what to do after skipping prioritization data */ - grpc_chttp2_hpack_parser_state after_prioritization; + /* what to do after skipping prioritization data */ + grpc_chttp2_hpack_parser_state after_prioritization; /* the refcount of the slice that we're currently parsing */ grpc_slice_refcount* current_slice_refcount; - /* the value we're currently parsing */ - union { + /* the value we're currently parsing */ + union { uint32_t* value; grpc_chttp2_hpack_parser_string* str; - } parsing; - /* string parameters for each chunk */ - grpc_chttp2_hpack_parser_string key; - grpc_chttp2_hpack_parser_string value; - /* parsed index */ - uint32_t index; + } parsing; + /* string parameters for each chunk */ + grpc_chttp2_hpack_parser_string key; + grpc_chttp2_hpack_parser_string value; + /* parsed index */ + uint32_t index; /* When we parse a value string, we determine the metadata element for a specific index, which we need again when we're finishing up with that header. To avoid calculating the metadata element for that index a second @@ -76,42 +76,42 @@ struct grpc_chttp2_hpack_parser { #ifndef NDEBUG int64_t precomputed_md_index; #endif - /* length of source bytes for the currently parsing string */ - uint32_t strlen; - /* number of source bytes read for the currently parsing string */ - uint32_t strgot; - /* huffman decoding state */ - int16_t huff_state; - /* is the string being decoded binary? */ - uint8_t binary; - /* is the current string huffman encoded? */ - uint8_t huff; - /* is a dynamic table update allowed? */ - uint8_t dynamic_table_update_allowed; - /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal - it should append a metadata boundary at the end of frame */ - uint8_t is_boundary; - uint8_t is_eof; - uint32_t base64_buffer; - - /* hpack table */ - grpc_chttp2_hptbl table; -}; - + /* length of source bytes for the currently parsing string */ + uint32_t strlen; + /* number of source bytes read for the currently parsing string */ + uint32_t strgot; + /* huffman decoding state */ + int16_t huff_state; + /* is the string being decoded binary? */ + uint8_t binary; + /* is the current string huffman encoded? */ + uint8_t huff; + /* is a dynamic table update allowed? */ + uint8_t dynamic_table_update_allowed; + /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal + it should append a metadata boundary at the end of frame */ + uint8_t is_boundary; + uint8_t is_eof; + uint32_t base64_buffer; + + /* hpack table */ + grpc_chttp2_hptbl table; +}; + void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser* p); void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser* p); - + void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser* p); - + grpc_error* grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser* p, const grpc_slice& slice); - -/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for - the transport */ + +/* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for + the transport */ grpc_error* grpc_chttp2_header_parser_parse(void* hpack_parser, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h index 34c3dceda7..9ba29d8525 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -1,52 +1,52 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> +#include <grpc/slice.h> #include "src/core/lib/gprpp/memory.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" - -/* HPACK header table */ - -/* last index in the static table */ -#define GRPC_CHTTP2_LAST_STATIC_ENTRY 61 - -/* Initial table size as per the spec */ -#define GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE 4096 -/* Maximum table size that we'll use */ -#define GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE -/* Per entry overhead bytes as per the spec */ -#define GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD 32 -#if 0 -/* Maximum number of entries we could possibly fit in the table, given defined - overheads */ -#define GRPC_CHTTP2_MAX_TABLE_COUNT \ - ((GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / \ - GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD) -#endif - -/* hpack decoder table */ + +/* HPACK header table */ + +/* last index in the static table */ +#define GRPC_CHTTP2_LAST_STATIC_ENTRY 61 + +/* Initial table size as per the spec */ +#define GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE 4096 +/* Maximum table size that we'll use */ +#define GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE +/* Per entry overhead bytes as per the spec */ +#define GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD 32 +#if 0 +/* Maximum number of entries we could possibly fit in the table, given defined + overheads */ +#define GRPC_CHTTP2_MAX_TABLE_COUNT \ + ((GRPC_CHTTP2_MAX_HPACK_TABLE_SIZE + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / \ + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD) +#endif + +/* hpack decoder table */ struct grpc_chttp2_hptbl { static uint32_t entries_for_bytes(uint32_t bytes) { return (bytes + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD - 1) / @@ -64,35 +64,35 @@ struct grpc_chttp2_hptbl { memset(ents, 0, AllocSize); } - /* the first used entry in ents */ + /* the first used entry in ents */ uint32_t first_ent = 0; - /* how many entries are in the table */ + /* how many entries are in the table */ uint32_t num_ents = 0; - /* the amount of memory used by the table, according to the hpack algorithm */ + /* the amount of memory used by the table, according to the hpack algorithm */ uint32_t mem_used = 0; - /* the max memory allowed to be used by the table, according to the hpack - algorithm */ + /* the max memory allowed to be used by the table, according to the hpack + algorithm */ uint32_t max_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; - /* the currently agreed size of the table, according to the hpack algorithm */ + /* the currently agreed size of the table, according to the hpack algorithm */ uint32_t current_table_bytes = GRPC_CHTTP2_INITIAL_HPACK_TABLE_SIZE; - /* Maximum number of entries we could possibly fit in the table, given defined - overheads */ + /* Maximum number of entries we could possibly fit in the table, given defined + overheads */ uint32_t max_entries = kInitialCapacity; - /* Number of entries allocated in ents */ + /* Number of entries allocated in ents */ uint32_t cap_entries = kInitialCapacity; - /* a circular buffer of headers - this is stored in the opposite order to - what hpack specifies, in order to simplify table management a little... - meaning lookups need to SUBTRACT from the end position */ + /* a circular buffer of headers - this is stored in the opposite order to + what hpack specifies, in order to simplify table management a little... + meaning lookups need to SUBTRACT from the end position */ grpc_mdelem* ents = nullptr; }; - + void grpc_chttp2_hptbl_destroy(grpc_chttp2_hptbl* tbl); void grpc_chttp2_hptbl_set_max_bytes(grpc_chttp2_hptbl* tbl, - uint32_t max_bytes); + uint32_t max_bytes); grpc_error* grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl* tbl, - uint32_t bytes); - -/* lookup a table entry based on its hpack index */ + uint32_t bytes); + +/* lookup a table entry based on its hpack index */ grpc_mdelem grpc_chttp2_hptbl_lookup_dynamic_index(const grpc_chttp2_hptbl* tbl, uint32_t tbl_index); grpc_mdelem grpc_chttp2_hptbl_lookup_ref_dynamic_index( @@ -116,7 +116,7 @@ inline grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl* tbl, } } } -/* add a table entry to the index */ +/* add a table entry to the index */ grpc_error* grpc_chttp2_hptbl_add(grpc_chttp2_hptbl* tbl, grpc_mdelem md) GRPC_MUST_USE_RESULT; @@ -136,13 +136,13 @@ inline uintptr_t grpc_chttp2_get_static_hpack_table_index(grpc_mdelem md) { return 0; } -/* Find a key/value pair in the table... returns the index in the table of the - most similar entry, or 0 if the value was not found */ +/* Find a key/value pair in the table... returns the index in the table of the + most similar entry, or 0 if the value was not found */ struct grpc_chttp2_hptbl_find_result { - uint32_t index; - int has_value; + uint32_t index; + int has_value; }; -grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( +grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( const grpc_chttp2_hptbl* tbl, grpc_mdelem md); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt index 08842a0267..441fb95707 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/hpack_tables.txt @@ -1,66 +1,66 @@ -Static table, from the spec: - +-------+-----------------------------+---------------+ - | Index | Header Name | Header Value | - +-------+-----------------------------+---------------+ - | 1 | :authority | | - | 2 | :method | GET | - | 3 | :method | POST | - | 4 | :path | / | - | 5 | :path | /index.html | - | 6 | :scheme | http | - | 7 | :scheme | https | - | 8 | :status | 200 | - | 9 | :status | 204 | - | 10 | :status | 206 | - | 11 | :status | 304 | - | 12 | :status | 400 | - | 13 | :status | 404 | - | 14 | :status | 500 | - | 15 | accept-charset | | - | 16 | accept-encoding | gzip, deflate | - | 17 | accept-language | | - | 18 | accept-ranges | | - | 19 | accept | | - | 20 | access-control-allow-origin | | - | 21 | age | | - | 22 | allow | | - | 23 | authorization | | - | 24 | cache-control | | - | 25 | content-disposition | | - | 26 | content-encoding | | - | 27 | content-language | | - | 28 | content-length | | - | 29 | content-location | | - | 30 | content-range | | - | 31 | content-type | | - | 32 | cookie | | - | 33 | date | | - | 34 | etag | | - | 35 | expect | | - | 36 | expires | | - | 37 | from | | - | 38 | host | | - | 39 | if-match | | - | 40 | if-modified-since | | - | 41 | if-none-match | | - | 42 | if-range | | - | 43 | if-unmodified-since | | - | 44 | last-modified | | - | 45 | link | | - | 46 | location | | - | 47 | max-forwards | | - | 48 | proxy-authenticate | | - | 49 | proxy-authorization | | - | 50 | range | | - | 51 | referer | | - | 52 | refresh | | - | 53 | retry-after | | - | 54 | server | | - | 55 | set-cookie | | - | 56 | strict-transport-security | | - | 57 | transfer-encoding | | - | 58 | user-agent | | - | 59 | vary | | - | 60 | via | | - | 61 | www-authenticate | | - +-------+-----------------------------+---------------+ +Static table, from the spec: + +-------+-----------------------------+---------------+ + | Index | Header Name | Header Value | + +-------+-----------------------------+---------------+ + | 1 | :authority | | + | 2 | :method | GET | + | 3 | :method | POST | + | 4 | :path | / | + | 5 | :path | /index.html | + | 6 | :scheme | http | + | 7 | :scheme | https | + | 8 | :status | 200 | + | 9 | :status | 204 | + | 10 | :status | 206 | + | 11 | :status | 304 | + | 12 | :status | 400 | + | 13 | :status | 404 | + | 14 | :status | 500 | + | 15 | accept-charset | | + | 16 | accept-encoding | gzip, deflate | + | 17 | accept-language | | + | 18 | accept-ranges | | + | 19 | accept | | + | 20 | access-control-allow-origin | | + | 21 | age | | + | 22 | allow | | + | 23 | authorization | | + | 24 | cache-control | | + | 25 | content-disposition | | + | 26 | content-encoding | | + | 27 | content-language | | + | 28 | content-length | | + | 29 | content-location | | + | 30 | content-range | | + | 31 | content-type | | + | 32 | cookie | | + | 33 | date | | + | 34 | etag | | + | 35 | expect | | + | 36 | expires | | + | 37 | from | | + | 38 | host | | + | 39 | if-match | | + | 40 | if-modified-since | | + | 41 | if-none-match | | + | 42 | if-range | | + | 43 | if-unmodified-since | | + | 44 | last-modified | | + | 45 | link | | + | 46 | location | | + | 47 | max-forwards | | + | 48 | proxy-authenticate | | + | 49 | proxy-authorization | | + | 50 | range | | + | 51 | referer | | + | 52 | refresh | | + | 53 | retry-after | | + | 54 | server | | + | 55 | set-cookie | | + | 56 | strict-transport-security | | + | 57 | transfer-encoding | | + | 58 | user-agent | | + | 59 | vary | | + | 60 | via | | + | 61 | www-authenticate | | + +-------+-----------------------------+---------------+ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h index 49feb238f1..1ceb6efd16 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/huffsyms.h @@ -1,32 +1,32 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H - -/* HPACK static huffman table */ - -#define GRPC_CHTTP2_NUM_HUFFSYMS 257 - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H + +/* HPACK static huffman table */ + +#define GRPC_CHTTP2_NUM_HUFFSYMS 257 + struct grpc_chttp2_huffsym { - unsigned bits; - unsigned length; + unsigned bits; + unsigned length; }; -extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS]; - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H */ +extern const grpc_chttp2_huffsym grpc_chttp2_huffsyms[GRPC_CHTTP2_NUM_HUFFSYMS]; + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HUFFSYMS_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h index b63caa1ae2..da7b522e91 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/incoming_metadata.h @@ -1,28 +1,28 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/transport/transport.h" - +#include "src/core/lib/transport/transport.h" + struct grpc_chttp2_incoming_metadata_buffer { explicit grpc_chttp2_incoming_metadata_buffer(grpc_core::Arena* arena) : arena(arena) { @@ -42,17 +42,17 @@ struct grpc_chttp2_incoming_metadata_buffer { grpc_linked_mdelem preallocated_mdelems[kPreallocatedMDElem]; grpc_metadata_batch batch; }; - -void grpc_chttp2_incoming_metadata_buffer_publish( + +void grpc_chttp2_incoming_metadata_buffer_publish( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_metadata_batch* batch); - + grpc_error* grpc_chttp2_incoming_metadata_buffer_add( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; grpc_error* grpc_chttp2_incoming_metadata_buffer_replace_or_add( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_mdelem elem) GRPC_MUST_USE_RESULT; -void grpc_chttp2_incoming_metadata_buffer_set_deadline( +void grpc_chttp2_incoming_metadata_buffer_set_deadline( grpc_chttp2_incoming_metadata_buffer* buffer, grpc_millis deadline); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INCOMING_METADATA_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h index 2f028c08f3..253dba1fbd 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/internal.h @@ -1,77 +1,77 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H - + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H + #include <grpc/support/port_platform.h> -#include <assert.h> -#include <stdbool.h> - +#include <assert.h> +#include <stdbool.h> + #include "src/core/ext/transport/chttp2/transport/flow_control.h" -#include "src/core/ext/transport/chttp2/transport/frame.h" -#include "src/core/ext/transport/chttp2/transport/frame_data.h" -#include "src/core/ext/transport/chttp2/transport/frame_goaway.h" -#include "src/core/ext/transport/chttp2/transport/frame_ping.h" -#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h" -#include "src/core/ext/transport/chttp2/transport/frame_settings.h" -#include "src/core/ext/transport/chttp2/transport/frame_window_update.h" -#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" -#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" -#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" -#include "src/core/ext/transport/chttp2/transport/stream_map.h" +#include "src/core/ext/transport/chttp2/transport/frame.h" +#include "src/core/ext/transport/chttp2/transport/frame_data.h" +#include "src/core/ext/transport/chttp2/transport/frame_goaway.h" +#include "src/core/ext/transport/chttp2/transport/frame_ping.h" +#include "src/core/ext/transport/chttp2/transport/frame_rst_stream.h" +#include "src/core/ext/transport/chttp2/transport/frame_settings.h" +#include "src/core/ext/transport/chttp2/transport/frame_window_update.h" +#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" +#include "src/core/ext/transport/chttp2/transport/hpack_parser.h" +#include "src/core/ext/transport/chttp2/transport/incoming_metadata.h" +#include "src/core/ext/transport/chttp2/transport/stream_map.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/compression/stream_compression.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/iomgr/combiner.h" -#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/combiner.h" +#include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/transport_impl.h" - +#include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/transport_impl.h" + namespace grpc_core { class ContextList; } -/* streams are kept in various linked lists depending on what things need to - happen to them... this enum labels each list */ -typedef enum { +/* streams are kept in various linked lists depending on what things need to + happen to them... this enum labels each list */ +typedef enum { /* If a stream is in the following two lists, an explicit ref is associated with the stream */ - GRPC_CHTTP2_LIST_WRITABLE, - GRPC_CHTTP2_LIST_WRITING, + GRPC_CHTTP2_LIST_WRITABLE, + GRPC_CHTTP2_LIST_WRITING, /* No additional ref is taken for the following refs. Make sure to remove the stream from these lists when the stream is removed. */ - GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, + GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, GRPC_CHTTP2_LIST_STALLED_BY_STREAM, - /** streams that are waiting to start because there are too many concurrent - streams on the connection */ - GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, - STREAM_LIST_COUNT /* must be last */ -} grpc_chttp2_stream_list_id; - -typedef enum { - GRPC_CHTTP2_WRITE_STATE_IDLE, - GRPC_CHTTP2_WRITE_STATE_WRITING, - GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE, -} grpc_chttp2_write_state; - + /** streams that are waiting to start because there are too many concurrent + streams on the connection */ + GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, + STREAM_LIST_COUNT /* must be last */ +} grpc_chttp2_stream_list_id; + +typedef enum { + GRPC_CHTTP2_WRITE_STATE_IDLE, + GRPC_CHTTP2_WRITE_STATE_WRITING, + GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE, +} grpc_chttp2_write_state; + typedef enum { GRPC_CHTTP2_OPTIMIZE_FOR_LATENCY, GRPC_CHTTP2_OPTIMIZE_FOR_THROUGHPUT, @@ -131,49 +131,49 @@ struct grpc_chttp2_server_ping_recv_state { grpc_millis last_ping_recv_time; int ping_strikes; }; -/* deframer state for the overall http2 stream of bytes */ -typedef enum { - /* prefix: one entry per http2 connection prefix byte */ - GRPC_DTS_CLIENT_PREFIX_0 = 0, - GRPC_DTS_CLIENT_PREFIX_1, - GRPC_DTS_CLIENT_PREFIX_2, - GRPC_DTS_CLIENT_PREFIX_3, - GRPC_DTS_CLIENT_PREFIX_4, - GRPC_DTS_CLIENT_PREFIX_5, - GRPC_DTS_CLIENT_PREFIX_6, - GRPC_DTS_CLIENT_PREFIX_7, - GRPC_DTS_CLIENT_PREFIX_8, - GRPC_DTS_CLIENT_PREFIX_9, - GRPC_DTS_CLIENT_PREFIX_10, - GRPC_DTS_CLIENT_PREFIX_11, - GRPC_DTS_CLIENT_PREFIX_12, - GRPC_DTS_CLIENT_PREFIX_13, - GRPC_DTS_CLIENT_PREFIX_14, - GRPC_DTS_CLIENT_PREFIX_15, - GRPC_DTS_CLIENT_PREFIX_16, - GRPC_DTS_CLIENT_PREFIX_17, - GRPC_DTS_CLIENT_PREFIX_18, - GRPC_DTS_CLIENT_PREFIX_19, - GRPC_DTS_CLIENT_PREFIX_20, - GRPC_DTS_CLIENT_PREFIX_21, - GRPC_DTS_CLIENT_PREFIX_22, - GRPC_DTS_CLIENT_PREFIX_23, - /* frame header byte 0... */ - /* must follow from the prefix states */ - GRPC_DTS_FH_0, - GRPC_DTS_FH_1, - GRPC_DTS_FH_2, - GRPC_DTS_FH_3, - GRPC_DTS_FH_4, - GRPC_DTS_FH_5, - GRPC_DTS_FH_6, - GRPC_DTS_FH_7, - /* ... frame header byte 8 */ - GRPC_DTS_FH_8, - /* inside a http2 frame */ - GRPC_DTS_FRAME -} grpc_chttp2_deframe_transport_state; - +/* deframer state for the overall http2 stream of bytes */ +typedef enum { + /* prefix: one entry per http2 connection prefix byte */ + GRPC_DTS_CLIENT_PREFIX_0 = 0, + GRPC_DTS_CLIENT_PREFIX_1, + GRPC_DTS_CLIENT_PREFIX_2, + GRPC_DTS_CLIENT_PREFIX_3, + GRPC_DTS_CLIENT_PREFIX_4, + GRPC_DTS_CLIENT_PREFIX_5, + GRPC_DTS_CLIENT_PREFIX_6, + GRPC_DTS_CLIENT_PREFIX_7, + GRPC_DTS_CLIENT_PREFIX_8, + GRPC_DTS_CLIENT_PREFIX_9, + GRPC_DTS_CLIENT_PREFIX_10, + GRPC_DTS_CLIENT_PREFIX_11, + GRPC_DTS_CLIENT_PREFIX_12, + GRPC_DTS_CLIENT_PREFIX_13, + GRPC_DTS_CLIENT_PREFIX_14, + GRPC_DTS_CLIENT_PREFIX_15, + GRPC_DTS_CLIENT_PREFIX_16, + GRPC_DTS_CLIENT_PREFIX_17, + GRPC_DTS_CLIENT_PREFIX_18, + GRPC_DTS_CLIENT_PREFIX_19, + GRPC_DTS_CLIENT_PREFIX_20, + GRPC_DTS_CLIENT_PREFIX_21, + GRPC_DTS_CLIENT_PREFIX_22, + GRPC_DTS_CLIENT_PREFIX_23, + /* frame header byte 0... */ + /* must follow from the prefix states */ + GRPC_DTS_FH_0, + GRPC_DTS_FH_1, + GRPC_DTS_FH_2, + GRPC_DTS_FH_3, + GRPC_DTS_FH_4, + GRPC_DTS_FH_5, + GRPC_DTS_FH_6, + GRPC_DTS_FH_7, + /* ... frame header byte 8 */ + GRPC_DTS_FH_8, + /* inside a http2 frame */ + GRPC_DTS_FRAME +} grpc_chttp2_deframe_transport_state; + struct grpc_chttp2_stream_list { grpc_chttp2_stream* head; grpc_chttp2_stream* tail; @@ -182,41 +182,41 @@ struct grpc_chttp2_stream_link { grpc_chttp2_stream* next; grpc_chttp2_stream* prev; }; -/* We keep several sets of connection wide parameters */ -typedef enum { - /* The settings our peer has asked for (and we have acked) */ - GRPC_PEER_SETTINGS = 0, - /* The settings we'd like to have */ - GRPC_LOCAL_SETTINGS, - /* The settings we've published to our peer */ - GRPC_SENT_SETTINGS, - /* The settings the peer has acked */ - GRPC_ACKED_SETTINGS, - GRPC_NUM_SETTING_SETS -} grpc_chttp2_setting_set; - -typedef enum { - GRPC_CHTTP2_NO_GOAWAY_SEND, - GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED, - GRPC_CHTTP2_GOAWAY_SENT, -} grpc_chttp2_sent_goaway_state; - -typedef struct grpc_chttp2_write_cb { - int64_t call_at_byte; +/* We keep several sets of connection wide parameters */ +typedef enum { + /* The settings our peer has asked for (and we have acked) */ + GRPC_PEER_SETTINGS = 0, + /* The settings we'd like to have */ + GRPC_LOCAL_SETTINGS, + /* The settings we've published to our peer */ + GRPC_SENT_SETTINGS, + /* The settings the peer has acked */ + GRPC_ACKED_SETTINGS, + GRPC_NUM_SETTING_SETS +} grpc_chttp2_setting_set; + +typedef enum { + GRPC_CHTTP2_NO_GOAWAY_SEND, + GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED, + GRPC_CHTTP2_GOAWAY_SENT, +} grpc_chttp2_sent_goaway_state; + +typedef struct grpc_chttp2_write_cb { + int64_t call_at_byte; grpc_closure* closure; struct grpc_chttp2_write_cb* next; -} grpc_chttp2_write_cb; - +} grpc_chttp2_write_cb; + namespace grpc_core { - + class Chttp2IncomingByteStream : public ByteStream { public: Chttp2IncomingByteStream(grpc_chttp2_transport* transport, grpc_chttp2_stream* stream, uint32_t frame_size, uint32_t flags); - + void Orphan() override; - + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; grpc_error* Pull(grpc_slice* slice) override; void Shutdown(grpc_error* error) override; @@ -269,14 +269,14 @@ class Chttp2IncomingByteStream : public ByteStream { /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == * true */ - struct { - grpc_closure closure; - size_t max_size_hint; + struct { + grpc_closure closure; + size_t max_size_hint; grpc_closure* on_complete; } next_action_; grpc_closure destroy_action_; -}; - +}; + } // namespace grpc_core typedef enum { @@ -286,125 +286,125 @@ typedef enum { GRPC_CHTTP2_KEEPALIVE_STATE_DISABLED, } grpc_chttp2_keepalive_state; -struct grpc_chttp2_transport { +struct grpc_chttp2_transport { grpc_chttp2_transport(const grpc_channel_args* channel_args, grpc_endpoint* ep, bool is_client, grpc_resource_user* resource_user); ~grpc_chttp2_transport(); - grpc_transport base; /* must be first */ + grpc_transport base; /* must be first */ grpc_core::RefCount refs; grpc_endpoint* ep; TString peer_string; - + grpc_resource_user* resource_user; grpc_core::Combiner* combiner; - + grpc_closure* notify_on_receive_settings = nullptr; - /** write execution state of the transport */ + /** write execution state of the transport */ grpc_chttp2_write_state write_state = GRPC_CHTTP2_WRITE_STATE_IDLE; - - /** is the transport destroying itself? */ + + /** is the transport destroying itself? */ uint8_t destroying = false; - /** has the upper layer closed the transport? */ + /** has the upper layer closed the transport? */ grpc_error* closed_with_error = GRPC_ERROR_NONE; - - /** is there a read request to the endpoint outstanding? */ + + /** is there a read request to the endpoint outstanding? */ uint8_t endpoint_reading = 1; - - /** various lists of streams */ + + /** various lists of streams */ grpc_chttp2_stream_list lists[STREAM_LIST_COUNT] = {}; - - /** maps stream id to grpc_chttp2_stream objects */ - grpc_chttp2_stream_map stream_map; - - grpc_closure write_action_begin_locked; - grpc_closure write_action; - grpc_closure write_action_end_locked; - - grpc_closure read_action_locked; - - /** incoming read bytes */ - grpc_slice_buffer read_buffer; - - /** address to place a newly accepted stream - set and unset by - grpc_chttp2_parsing_accept_stream; used by init_stream to - publish the accepted server stream */ + + /** maps stream id to grpc_chttp2_stream objects */ + grpc_chttp2_stream_map stream_map; + + grpc_closure write_action_begin_locked; + grpc_closure write_action; + grpc_closure write_action_end_locked; + + grpc_closure read_action_locked; + + /** incoming read bytes */ + grpc_slice_buffer read_buffer; + + /** address to place a newly accepted stream - set and unset by + grpc_chttp2_parsing_accept_stream; used by init_stream to + publish the accepted server stream */ grpc_chttp2_stream** accepting_stream = nullptr; - + /* accept stream callback */ void (*accept_stream_cb)(void* user_data, grpc_transport* transport, const void* server_data); void* accept_stream_cb_user_data; - + /** connectivity tracking */ grpc_core::ConnectivityStateTracker state_tracker; - - /** data to write now */ - grpc_slice_buffer outbuf; - /** hpack encoding */ - grpc_chttp2_hpack_compressor hpack_compressor; - /** is this a client? */ + + /** data to write now */ + grpc_slice_buffer outbuf; + /** hpack encoding */ + grpc_chttp2_hpack_compressor hpack_compressor; + /** is this a client? */ bool is_client; - - /** data to write next write */ - grpc_slice_buffer qbuf; - - /** how much data are we willing to buffer when the WRITE_BUFFER_HINT is set? - */ + + /** data to write next write */ + grpc_slice_buffer qbuf; + + /** how much data are we willing to buffer when the WRITE_BUFFER_HINT is set? + */ uint32_t write_buffer_size = grpc_core::chttp2::kDefaultWindow; - + /** Set to a grpc_error object if a goaway frame is received. By default, set * to GRPC_ERROR_NONE */ grpc_error* goaway_error = GRPC_ERROR_NONE; grpc_chttp2_sent_goaway_state sent_goaway_state = GRPC_CHTTP2_NO_GOAWAY_SEND; - - /** are the local settings dirty and need to be sent? */ + + /** are the local settings dirty and need to be sent? */ bool dirtied_local_settings = true; - /** have local settings been sent? */ + /** have local settings been sent? */ bool sent_local_settings = false; /** bitmask of setting indexes to send out Hack: it's common for implementations to assume 65536 bytes initial send window -- this should by rights be 0 */ uint32_t force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; - /** settings values */ - uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; - - /** what is the next stream id to be allocated by this peer? - copied to next_stream_id in parsing when parsing commences */ + /** settings values */ + uint32_t settings[GRPC_NUM_SETTING_SETS][GRPC_CHTTP2_NUM_SETTINGS]; + + /** what is the next stream id to be allocated by this peer? + copied to next_stream_id in parsing when parsing commences */ uint32_t next_stream_id = 0; - - /** last new stream id */ + + /** last new stream id */ uint32_t last_new_stream_id = 0; - + /** ping queues for various ping insertion points */ grpc_chttp2_ping_queue ping_queue = grpc_chttp2_ping_queue(); grpc_chttp2_repeated_ping_policy ping_policy; grpc_chttp2_repeated_ping_state ping_state; uint64_t ping_ctr = 0; /* unique id for pings */ grpc_closure retry_initiate_ping_locked; - + /** ping acks */ size_t ping_ack_count = 0; size_t ping_ack_capacity = 0; uint64_t* ping_acks = nullptr; grpc_chttp2_server_ping_recv_state ping_recv_state; - /** parser for headers */ - grpc_chttp2_hpack_parser hpack_parser; - /** simple one shot parsers */ - union { - grpc_chttp2_window_update_parser window_update; - grpc_chttp2_settings_parser settings; - grpc_chttp2_ping_parser ping; - grpc_chttp2_rst_stream_parser rst_stream; - } simple; - /** parser for goaway frames */ - grpc_chttp2_goaway_parser goaway_parser; - + /** parser for headers */ + grpc_chttp2_hpack_parser hpack_parser; + /** simple one shot parsers */ + union { + grpc_chttp2_window_update_parser window_update; + grpc_chttp2_settings_parser settings; + grpc_chttp2_ping_parser ping; + grpc_chttp2_rst_stream_parser rst_stream; + } simple; + /** parser for goaway frames */ + grpc_chttp2_goaway_parser goaway_parser; + grpc_core::PolymorphicManualConstructor< grpc_core::chttp2::TransportFlowControlBase, grpc_core::chttp2::TransportFlowControl, @@ -414,8 +414,8 @@ struct grpc_chttp2_transport { * the remote peer. If there is a positive delta, then we will make all * streams readable since they may have become unstalled */ int64_t initial_window_update = 0; - - /* deframing */ + + /* deframing */ grpc_chttp2_deframe_transport_state deframe_state = GRPC_DTS_CLIENT_PREFIX_0; uint8_t incoming_frame_type = 0; uint8_t incoming_frame_flags = 0; @@ -424,39 +424,39 @@ struct grpc_chttp2_transport { uint32_t expect_continuation_stream_id = 0; uint32_t incoming_frame_size = 0; uint32_t incoming_stream_id = 0; - - /* active parser */ + + /* active parser */ void* parser_data = nullptr; grpc_chttp2_stream* incoming_stream = nullptr; grpc_error* (*parser)(void* parser_user_data, grpc_chttp2_transport* t, grpc_chttp2_stream* s, const grpc_slice& slice, int is_last); - + grpc_chttp2_write_cb* write_cb_pool = nullptr; - + /* bdp estimator */ bool bdp_ping_blocked = false; /* Is the BDP blocked due to not receiving any data? */ grpc_closure next_bdp_ping_timer_expired_locked; grpc_closure start_bdp_ping_locked; grpc_closure finish_bdp_ping_locked; - - /* if non-NULL, close the transport with this error when writes are finished - */ + + /* if non-NULL, close the transport with this error when writes are finished + */ grpc_error* close_transport_on_writes_finished = GRPC_ERROR_NONE; - - /* a list of closures to run after writes are finished */ + + /* a list of closures to run after writes are finished */ grpc_closure_list run_after_write = GRPC_CLOSURE_LIST_INIT; - - /* buffer pool state */ - /** have we scheduled a benign cleanup? */ + + /* buffer pool state */ + /** have we scheduled a benign cleanup? */ bool benign_reclaimer_registered = false; - /** have we scheduled a destructive cleanup? */ + /** have we scheduled a destructive cleanup? */ bool destructive_reclaimer_registered = false; - /** benign cleanup closure */ - grpc_closure benign_reclaimer_locked; - /** destructive cleanup closure */ - grpc_closure destructive_reclaimer_locked; + /** benign cleanup closure */ + grpc_closure benign_reclaimer_locked; + /** destructive cleanup closure */ + grpc_closure destructive_reclaimer_locked; /* next bdp ping timer */ bool have_next_bdp_ping_timer = false; @@ -497,16 +497,16 @@ struct grpc_chttp2_transport { * thereby reducing the number of induced frames. */ uint32_t num_pending_induced_frames = 0; bool reading_paused_on_pending_induced_frames = false; -}; - -typedef enum { - GRPC_METADATA_NOT_PUBLISHED, - GRPC_METADATA_SYNTHESIZED_FROM_FAKE, - GRPC_METADATA_PUBLISHED_FROM_WIRE, +}; + +typedef enum { + GRPC_METADATA_NOT_PUBLISHED, + GRPC_METADATA_SYNTHESIZED_FROM_FAKE, + GRPC_METADATA_PUBLISHED_FROM_WIRE, GRPC_METADATA_PUBLISHED_AT_CLOSE -} grpc_published_metadata_method; - -struct grpc_chttp2_stream { +} grpc_published_metadata_method; + +struct grpc_chttp2_stream { grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_stream_refcount* refcount, const void* server_data, grpc_core::Arena* arena); ~grpc_chttp2_stream(); @@ -520,17 +520,17 @@ struct grpc_chttp2_stream { struct Reffer { explicit Reffer(grpc_chttp2_stream* s); } reffer; - - grpc_closure destroy_stream; + + grpc_closure destroy_stream; grpc_closure* destroy_stream_arg; - - grpc_chttp2_stream_link links[STREAM_LIST_COUNT]; + + grpc_chttp2_stream_link links[STREAM_LIST_COUNT]; uint8_t included[STREAM_LIST_COUNT] = {}; - - /** HTTP2 stream id for this stream, or zero if one has not been assigned */ + + /** HTTP2 stream id for this stream, or zero if one has not been assigned */ uint32_t id = 0; - - /** things the upper layers would like to send */ + + /** things the upper layers would like to send */ grpc_metadata_batch* send_initial_metadata = nullptr; grpc_closure* send_initial_metadata_finished = nullptr; grpc_metadata_batch* send_trailing_metadata = nullptr; @@ -542,16 +542,16 @@ struct grpc_chttp2_stream { // detecting cancellation on the server-side).. bool* sent_trailing_metadata_op = nullptr; grpc_closure* send_trailing_metadata_finished = nullptr; - + grpc_core::OrphanablePtr<grpc_core::ByteStream> fetching_send_message; uint32_t fetched_send_message_length = 0; grpc_slice fetching_slice = grpc_empty_slice(); - int64_t next_message_end_offset; + int64_t next_message_end_offset; int64_t flow_controlled_bytes_written = 0; int64_t flow_controlled_bytes_flowed = 0; - grpc_closure complete_fetch_locked; + grpc_closure complete_fetch_locked; grpc_closure* fetching_send_message_finished = nullptr; - + grpc_metadata_batch* recv_initial_metadata; grpc_closure* recv_initial_metadata_ready = nullptr; bool* trailing_metadata_available = nullptr; @@ -559,39 +559,39 @@ struct grpc_chttp2_stream { grpc_closure* recv_message_ready = nullptr; grpc_metadata_batch* recv_trailing_metadata; grpc_closure* recv_trailing_metadata_finished = nullptr; - + grpc_transport_stream_stats* collecting_stats = nullptr; grpc_transport_stream_stats stats = grpc_transport_stream_stats(); - - /** Is this stream closed for writing. */ + + /** Is this stream closed for writing. */ bool write_closed = false; - /** Is this stream reading half-closed. */ + /** Is this stream reading half-closed. */ bool read_closed = false; - /** Are all published incoming byte streams closed. */ + /** Are all published incoming byte streams closed. */ bool all_incoming_byte_streams_finished = false; - /** Has this stream seen an error. - If true, then pending incoming frames can be thrown away. */ + /** Has this stream seen an error. + If true, then pending incoming frames can be thrown away. */ bool seen_error = false; - /** Are we buffering writes on this stream? If yes, we won't become writable - until there's enough queued up in the flow_controlled_buffer */ + /** Are we buffering writes on this stream? If yes, we won't become writable + until there's enough queued up in the flow_controlled_buffer */ bool write_buffering = false; - + /* have we sent or received the EOS bit? */ bool eos_received = false; bool eos_sent = false; - /** the error that resulted in this stream being read-closed */ + /** the error that resulted in this stream being read-closed */ grpc_error* read_closed_error = GRPC_ERROR_NONE; - /** the error that resulted in this stream being write-closed */ + /** the error that resulted in this stream being write-closed */ grpc_error* write_closed_error = GRPC_ERROR_NONE; - + grpc_published_metadata_method published_metadata[2] = {}; bool final_metadata_requested = false; - - grpc_chttp2_incoming_metadata_buffer metadata_buffer[2]; - + + grpc_chttp2_incoming_metadata_buffer metadata_buffer[2]; + grpc_slice_buffer frame_storage; /* protected by t combiner */ - + grpc_closure* on_next = nullptr; /* protected by t combiner */ bool pending_byte_stream = false; /* protected by t combiner */ // cached length of buffer to be used by the transport thread in cases where @@ -606,21 +606,21 @@ struct grpc_chttp2_stream { grpc_closure reset_byte_stream; grpc_error* byte_stream_error = GRPC_ERROR_NONE; /* protected by t combiner */ bool received_last_frame = false; /* protected by t combiner */ - + grpc_millis deadline = GRPC_MILLIS_INF_FUTURE; - /** saw some stream level error */ + /** saw some stream level error */ grpc_error* forced_close_error = GRPC_ERROR_NONE; - /** how many header frames have we received? */ + /** how many header frames have we received? */ uint8_t header_frames_received = 0; - /** parsing state for data frames */ + /** parsing state for data frames */ /* Accessed only by transport thread when stream->pending_byte_stream == false * Accessed only by application thread when stream->pending_byte_stream == * true */ - grpc_chttp2_data_parser data_parser; - /** number of bytes received - reset at end of parse thread execution */ + grpc_chttp2_data_parser data_parser; + /** number of bytes received - reset at end of parse thread execution */ int64_t received_bytes = 0; - + bool sent_initial_metadata = false; bool sent_trailing_metadata = false; @@ -630,8 +630,8 @@ struct grpc_chttp2_stream { grpc_core::chttp2::StreamFlowControlDisabled> flow_control; - grpc_slice_buffer flow_controlled_buffer; - + grpc_slice_buffer flow_controlled_buffer; + grpc_chttp2_write_cb* on_flow_controlled_cbs = nullptr; grpc_chttp2_write_cb* on_write_finished_cbs = nullptr; grpc_chttp2_write_cb* finish_after_write = nullptr; @@ -669,23 +669,23 @@ struct grpc_chttp2_stream { * compression. */ grpc_slice_buffer decompressed_data_buffer; -}; - -/** Transport writing call flow: - grpc_chttp2_initiate_write() is called anywhere that we know bytes need to - go out on the wire. - If no other write has been started, a task is enqueued onto our workqueue. - When that task executes, it obtains the global lock, and gathers the data - to write. - The global lock is dropped and we do the syscall to write. - After writing, a follow-up check is made to see if another round of writing - should be performed. - - The actual call chain is documented in the implementation of this function. - */ +}; + +/** Transport writing call flow: + grpc_chttp2_initiate_write() is called anywhere that we know bytes need to + go out on the wire. + If no other write has been started, a task is enqueued onto our workqueue. + When that task executes, it obtains the global lock, and gathers the data + to write. + The global lock is dropped and we do the syscall to write. + After writing, a follow-up check is made to see if another round of writing + should be performed. + + The actual call chain is documented in the implementation of this function. + */ void grpc_chttp2_initiate_write(grpc_chttp2_transport* t, grpc_chttp2_initiate_write_reason reason); - + struct grpc_chttp2_begin_write_result { /** are we writing? */ bool writing; @@ -698,45 +698,45 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( grpc_chttp2_transport* t); void grpc_chttp2_end_write(grpc_chttp2_transport* t, grpc_error* error); -/** Process one slice of incoming data; return 1 if the connection is still - viable after reading, or 0 if the connection should be torn down */ +/** Process one slice of incoming data; return 1 if the connection is still + viable after reading, or 0 if the connection should be torn down */ grpc_error* grpc_chttp2_perform_read(grpc_chttp2_transport* t, const grpc_slice& slice); - + bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); -/** Get a writable stream - returns non-zero if there was a stream available */ +/** Get a writable stream + returns non-zero if there was a stream available */ bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); bool grpc_chttp2_list_remove_writable_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport* t); bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); - + void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport* t, grpc_chttp2_stream** s); - + void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream** s); void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream** s); void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s); bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport* t, @@ -759,62 +759,62 @@ inline grpc_chttp2_stream* grpc_chttp2_parsing_lookup_stream( grpc_chttp2_stream_map_find(&t->stream_map, id)); } grpc_chttp2_stream* grpc_chttp2_parsing_accept_stream(grpc_chttp2_transport* t, - uint32_t id); - + uint32_t id); + void grpc_chttp2_add_incoming_goaway(grpc_chttp2_transport* t, - uint32_t goaway_error, + uint32_t goaway_error, uint32_t last_stream_id, const grpc_slice& goaway_text); - + void grpc_chttp2_parsing_become_skip_parser(grpc_chttp2_transport* t); - + void grpc_chttp2_complete_closure_step(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_closure** pclosure, grpc_error* error, const char* desc); - + #define GRPC_HEADER_SIZE_IN_BYTES 5 #define MAX_SIZE_T (~(size_t)0) -#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" -#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ - (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) - +#define GRPC_CHTTP2_CLIENT_CONNECT_STRING "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" +#define GRPC_CHTTP2_CLIENT_CONNECT_STRLEN \ + (sizeof(GRPC_CHTTP2_CLIENT_CONNECT_STRING) - 1) + // extern grpc_core::TraceFlag grpc_http_trace; // extern grpc_core::TraceFlag grpc_flowctl_trace; - + #define GRPC_CHTTP2_IF_TRACING(stmt) \ do { \ if (GRPC_TRACE_FLAG_ENABLED(grpc_http_trace)) { \ (stmt); \ } \ } while (0) - + void grpc_chttp2_fake_status(grpc_chttp2_transport* t, grpc_chttp2_stream* stream, grpc_error* error); void grpc_chttp2_mark_stream_closed(grpc_chttp2_transport* t, grpc_chttp2_stream* s, int close_reads, int close_writes, grpc_error* error); void grpc_chttp2_start_writing(grpc_chttp2_transport* t); - + #ifndef NDEBUG -#define GRPC_CHTTP2_STREAM_REF(stream, reason) \ - grpc_chttp2_stream_ref(stream, reason) +#define GRPC_CHTTP2_STREAM_REF(stream, reason) \ + grpc_chttp2_stream_ref(stream, reason) #define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \ grpc_chttp2_stream_unref(stream, reason) void grpc_chttp2_stream_ref(grpc_chttp2_stream* s, const char* reason); void grpc_chttp2_stream_unref(grpc_chttp2_stream* s, const char* reason); -#else -#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream) +#else +#define GRPC_CHTTP2_STREAM_REF(stream, reason) grpc_chttp2_stream_ref(stream) #define GRPC_CHTTP2_STREAM_UNREF(stream, reason) \ grpc_chttp2_stream_unref(stream) void grpc_chttp2_stream_ref(grpc_chttp2_stream* s); void grpc_chttp2_stream_unref(grpc_chttp2_stream* s); -#endif - +#endif + #ifndef NDEBUG -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ - grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) +#define GRPC_CHTTP2_REF_TRANSPORT(t, r) \ + grpc_chttp2_ref_transport(t, r, __FILE__, __LINE__) #define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) \ grpc_chttp2_unref_transport(t, r, __FILE__, __LINE__) inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t, @@ -829,8 +829,8 @@ inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t, int line) { t->refs.Ref(grpc_core::DebugLocation(file, line), reason); } -#else -#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t) +#else +#define GRPC_CHTTP2_REF_TRANSPORT(t, r) grpc_chttp2_ref_transport(t) #define GRPC_CHTTP2_UNREF_TRANSPORT(t, r) grpc_chttp2_unref_transport(t) inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { if (t->refs.Unref()) { @@ -840,40 +840,40 @@ inline void grpc_chttp2_unref_transport(grpc_chttp2_transport* t) { inline void grpc_chttp2_ref_transport(grpc_chttp2_transport* t) { t->refs.Ref(); } -#endif - +#endif + void grpc_chttp2_ack_ping(grpc_chttp2_transport* t, uint64_t id); - + /** Add a new ping strike to ping_recv_state.ping_strikes. If ping_recv_state.ping_strikes > ping_policy.max_ping_strikes, it sends GOAWAY with error code ENHANCE_YOUR_CALM and additional debug data resembling "too_many_pings" followed by immediately closing the connection. */ void grpc_chttp2_add_ping_strike(grpc_chttp2_transport* t); - + /** Resets ping clock. Should be called when flushing window updates, * initial/trailing metadata or data frames. For a server, it resets the number * of ping strikes and the last_ping_recv_time. For a ping sender, it resets * pings_before_data_required. */ void grpc_chttp2_reset_ping_clock(grpc_chttp2_transport* t); -/** add a ref to the stream and add it to the writable list; - ref will be dropped in writing.c */ +/** add a ref to the stream and add it to the writable list; + ref will be dropped in writing.c */ void grpc_chttp2_mark_stream_writable(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_cancel_stream(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_error* due_to_error); - + void grpc_chttp2_maybe_complete_recv_initial_metadata(grpc_chttp2_transport* t, grpc_chttp2_stream* s); void grpc_chttp2_maybe_complete_recv_message(grpc_chttp2_transport* t, grpc_chttp2_stream* s); void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_chttp2_transport* t, grpc_chttp2_stream* s); - + void grpc_chttp2_fail_pending_writes(grpc_chttp2_transport* t, grpc_chttp2_stream* s, grpc_error* error); - + /** Set the default keepalive configurations, must only be called at initialization */ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args* args, @@ -883,4 +883,4 @@ void grpc_chttp2_retry_initiate_ping(void* tp, grpc_error* error); void schedule_bdp_ping_locked(grpc_chttp2_transport* t); -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */ +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_INTERNAL_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h index 485abd2d13..d79e502f70 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/stream_map.h @@ -1,67 +1,67 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H - -#include <grpc/support/port_platform.h> - -#include <stddef.h> - -/* Data structure to map a uint32_t to a data object (represented by a void*) - - Represented as a sorted array of keys, and a corresponding array of values. - Lookups are performed with binary search. - Adds are restricted to strictly higher keys than previously seen (this is - guaranteed by http2). */ + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H + +#include <grpc/support/port_platform.h> + +#include <stddef.h> + +/* Data structure to map a uint32_t to a data object (represented by a void*) + + Represented as a sorted array of keys, and a corresponding array of values. + Lookups are performed with binary search. + Adds are restricted to strictly higher keys than previously seen (this is + guaranteed by http2). */ struct grpc_chttp2_stream_map { uint32_t* keys; void** values; - size_t count; - size_t free; - size_t capacity; + size_t count; + size_t free; + size_t capacity; }; void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map* map, - size_t initial_capacity); + size_t initial_capacity); void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map* map); - -/* Add a new key: given http2 semantics, new keys must always be greater than - existing keys - this is asserted */ + +/* Add a new key: given http2 semantics, new keys must always be greater than + existing keys - this is asserted */ void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map* map, uint32_t key, void* value); - -/* Delete an existing key - returns the previous value of the key if it existed, - or NULL otherwise */ + +/* Delete an existing key - returns the previous value of the key if it existed, + or NULL otherwise */ void* grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map* map, uint32_t key); - -/* Return an existing key, or NULL if it does not exist */ + +/* Return an existing key, or NULL if it does not exist */ void* grpc_chttp2_stream_map_find(grpc_chttp2_stream_map* map, uint32_t key); - -/* Return a random entry */ + +/* Return a random entry */ void* grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map* map); - -/* How many (populated) entries are in the stream map? */ + +/* How many (populated) entries are in the stream map? */ size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map* map); - -/* Callback on each stream */ + +/* Callback on each stream */ void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map* map, void (*f)(void* user_data, uint32_t key, void* value), void* user_data); - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_STREAM_MAP_H */ diff --git a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h index 5a2b670f06..cdaeaef0a7 100644 --- a/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h +++ b/contrib/libs/grpc/src/core/ext/transport/chttp2/transport/varint.h @@ -1,60 +1,60 @@ -/* - * +/* + * * 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 GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H -#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H - -#include <grpc/support/port_platform.h> - -/* Helpers for hpack varint encoding */ - -/* length of a value that needs varint tail encoding (it's bigger than can be - bitpacked into the opcode byte) - returned value includes the length of the - opcode byte */ -uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value); - -void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target, - uint32_t tail_length); - -/* maximum value that can be bitpacked with the opcode if the opcode has a - prefix - of length prefix_bits */ -#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ - ((uint32_t)((1 << (8 - (prefix_bits))) - 1)) - -/* length required to bitpack a value */ -#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \ - ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ - ? 1u \ - : grpc_chttp2_hpack_varint_length( \ - (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) - -#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ - do { \ - uint8_t* tgt = target; \ - if ((length) == 1u) { \ - (tgt)[0] = (uint8_t)((prefix_or) | (n)); \ - } else { \ - (tgt)[0] = \ - (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ - grpc_chttp2_hpack_write_varint_tail( \ - (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ - } \ - } while (0) - -#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */ + * + */ + +#ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H +#define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H + +#include <grpc/support/port_platform.h> + +/* Helpers for hpack varint encoding */ + +/* length of a value that needs varint tail encoding (it's bigger than can be + bitpacked into the opcode byte) - returned value includes the length of the + opcode byte */ +uint32_t grpc_chttp2_hpack_varint_length(uint32_t tail_value); + +void grpc_chttp2_hpack_write_varint_tail(uint32_t tail_value, uint8_t* target, + uint32_t tail_length); + +/* maximum value that can be bitpacked with the opcode if the opcode has a + prefix + of length prefix_bits */ +#define GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ + ((uint32_t)((1 << (8 - (prefix_bits))) - 1)) + +/* length required to bitpack a value */ +#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \ + ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ + ? 1u \ + : grpc_chttp2_hpack_varint_length( \ + (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) + +#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ + do { \ + uint8_t* tgt = target; \ + if ((length) == 1u) { \ + (tgt)[0] = (uint8_t)((prefix_or) | (n)); \ + } else { \ + (tgt)[0] = \ + (prefix_or) | (uint8_t)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ + grpc_chttp2_hpack_write_varint_tail( \ + (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ + } \ + } while (0) + +#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_VARINT_H */ diff --git a/contrib/libs/grpc/src/core/lib/README.md b/contrib/libs/grpc/src/core/lib/README.md index 69b6bce2d9..bcac36ccae 100644 --- a/contrib/libs/grpc/src/core/lib/README.md +++ b/contrib/libs/grpc/src/core/lib/README.md @@ -1,6 +1,6 @@ -Required elements of gRPC Core: Each module in this directory is required to -build gRPC. If it's possible to envisage a configuration where code is not -required, then that code belongs in ext/ instead. - -NOTE: The movement of code between lib and ext is an ongoing effort, so this -directory currently contains too much of the core library. +Required elements of gRPC Core: Each module in this directory is required to +build gRPC. If it's possible to envisage a configuration where code is not +required, then that code belongs in ext/ instead. + +NOTE: The movement of code between lib and ext is an ongoing effort, so this +directory currently contains too much of the core library. diff --git a/contrib/libs/grpc/src/core/lib/channel/README.md b/contrib/libs/grpc/src/core/lib/channel/README.md index 2dfcfe6e66..aff64775cb 100644 --- a/contrib/libs/grpc/src/core/lib/channel/README.md +++ b/contrib/libs/grpc/src/core/lib/channel/README.md @@ -1,4 +1,4 @@ -# Channel - -Provides channel/call stack implementation, and implementation of common filters -for that implementation. +# Channel + +Provides channel/call stack implementation, and implementation of common filters +for that implementation. diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_args.h b/contrib/libs/grpc/src/core/lib/channel/channel_args.h index 6b973aa94d..695eb60464 100644 --- a/contrib/libs/grpc/src/core/lib/channel/channel_args.h +++ b/contrib/libs/grpc/src/core/lib/channel/channel_args.h @@ -1,81 +1,81 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> -#include <grpc/grpc.h> - +#include <grpc/grpc.h> + #include "src/core/lib/surface/channel_stack_type.h" -// Channel args are intentionally immutable, to avoid the need for locking. - -/** Copy the arguments in \a src into a new instance */ +// Channel args are intentionally immutable, to avoid the need for locking. + +/** Copy the arguments in \a src into a new instance */ grpc_channel_args* grpc_channel_args_copy(const grpc_channel_args* src); - -/** Copy the arguments in \a src into a new instance, stably sorting keys */ + +/** Copy the arguments in \a src into a new instance, stably sorting keys */ grpc_channel_args* grpc_channel_args_normalize(const grpc_channel_args* src); - -/** Copy the arguments in \a src and append \a to_add. If \a to_add is NULL, it - * is equivalent to calling \a grpc_channel_args_copy. */ + +/** Copy the arguments in \a src and append \a to_add. If \a to_add is NULL, it + * is equivalent to calling \a grpc_channel_args_copy. */ grpc_channel_args* grpc_channel_args_copy_and_add(const grpc_channel_args* src, const grpc_arg* to_add, - size_t num_to_add); - -/** Copies the arguments in \a src except for those whose keys are in - \a to_remove. */ + size_t num_to_add); + +/** Copies the arguments in \a src except for those whose keys are in + \a to_remove. */ grpc_channel_args* grpc_channel_args_copy_and_remove( const grpc_channel_args* src, const char** to_remove, size_t num_to_remove); - -/** Copies the arguments from \a src except for those whose keys are in - \a to_remove and appends the arguments in \a to_add. */ + +/** Copies the arguments from \a src except for those whose keys are in + \a to_remove and appends the arguments in \a to_add. */ grpc_channel_args* grpc_channel_args_copy_and_add_and_remove( const grpc_channel_args* src, const char** to_remove, size_t num_to_remove, const grpc_arg* to_add, size_t num_to_add); - + /** Perform the union of \a a and \a b, prioritizing \a a entries */ grpc_channel_args* grpc_channel_args_union(const grpc_channel_args* a, const grpc_channel_args* b); - -/** Destroy arguments created by \a grpc_channel_args_copy */ + +/** Destroy arguments created by \a grpc_channel_args_copy */ void grpc_channel_args_destroy(grpc_channel_args* a); inline void grpc_channel_args_destroy(const grpc_channel_args* a) { grpc_channel_args_destroy(const_cast<grpc_channel_args*>(a)); } - + int grpc_channel_args_compare(const grpc_channel_args* a, const grpc_channel_args* b); - -/** Returns the value of argument \a name from \a args, or NULL if not found. */ + +/** Returns the value of argument \a name from \a args, or NULL if not found. */ const grpc_arg* grpc_channel_args_find(const grpc_channel_args* args, const char* name); - + bool grpc_channel_args_want_minimal_stack(const grpc_channel_args* args); -typedef struct grpc_integer_options { - int default_value; // Return this if value is outside of expected bounds. - int min_value; - int max_value; -} grpc_integer_options; +typedef struct grpc_integer_options { + int default_value; // Return this if value is outside of expected bounds. + int min_value; + int max_value; +} grpc_integer_options; /** Returns the value of \a arg, subject to the constraints in \a options. */ int grpc_channel_arg_get_integer(const grpc_arg* arg, @@ -85,7 +85,7 @@ int grpc_channel_arg_get_integer(const grpc_arg* arg, int grpc_channel_args_find_integer(const grpc_channel_args* args, const char* name, const grpc_integer_options options); - + /** Returns the value of \a arg if \a arg is of type GRPC_ARG_STRING. Otherwise, emits a warning log, and returns nullptr. If arg is nullptr, returns nullptr, and does not emit a warning. */ @@ -131,4 +131,4 @@ void grpc_channel_args_set_client_channel_creation_mutator( grpc_channel_args_client_channel_creation_mutator grpc_channel_args_get_client_channel_creation_mutator(); -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_ARGS_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_stack.h b/contrib/libs/grpc/src/core/lib/channel/channel_stack.h index e297df9488..805277a38b 100644 --- a/contrib/libs/grpc/src/core/lib/channel/channel_stack.h +++ b/contrib/libs/grpc/src/core/lib/channel/channel_stack.h @@ -1,38 +1,38 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H - -////////////////////////////////////////////////////////////////////////////// -// IMPORTANT NOTE: -// -// When you update this API, please make the corresponding changes to -// the C++ API in src/cpp/common/channel_filter.{h,cc} -////////////////////////////////////////////////////////////////////////////// - -/* A channel filter defines how operations on a channel are implemented. - Channel filters are chained together to create full channels, and if those - chains are linear, then channel stacks provide a mechanism to minimize - allocations for that chain. - Call stacks are created by channel stacks and represent the per-call data + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H + +////////////////////////////////////////////////////////////////////////////// +// IMPORTANT NOTE: +// +// When you update this API, please make the corresponding changes to +// the C++ API in src/cpp/common/channel_filter.{h,cc} +////////////////////////////////////////////////////////////////////////////// + +/* A channel filter defines how operations on a channel are implemented. + Channel filters are chained together to create full channels, and if those + chains are linear, then channel stacks provide a mechanism to minimize + allocations for that chain. + Call stacks are created by channel stacks and represent the per-call data for that stack. - + Implementations should take care of the following details for a batch - 1. Synchronization is achieved with a CallCombiner. View src/core/lib/iomgr/call_combiner.h for more details. @@ -46,32 +46,32 @@ #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include <grpc/grpc.h> -#include <grpc/support/log.h> -#include <grpc/support/time.h> - -#include "src/core/lib/debug/trace.h" +#include <stddef.h> + +#include <grpc/grpc.h> +#include <grpc/support/log.h> +#include <grpc/support/time.h> + +#include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/iomgr/call_combiner.h" -#include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/transport/transport.h" - -typedef struct grpc_channel_element grpc_channel_element; -typedef struct grpc_call_element grpc_call_element; - -typedef struct grpc_channel_stack grpc_channel_stack; -typedef struct grpc_call_stack grpc_call_stack; - +#include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/transport/transport.h" + +typedef struct grpc_channel_element grpc_channel_element; +typedef struct grpc_call_element grpc_call_element; + +typedef struct grpc_channel_stack grpc_channel_stack; +typedef struct grpc_call_stack grpc_call_stack; + struct grpc_channel_element_args { grpc_channel_stack* channel_stack; const grpc_channel_args* channel_args; - /** Transport, iff it is known */ + /** Transport, iff it is known */ grpc_transport* optional_transport; - int is_first; - int is_last; + int is_first; + int is_last; }; struct grpc_call_element_args { grpc_call_stack* call_stack; @@ -84,164 +84,164 @@ struct grpc_call_element_args { grpc_core::CallCombiner* call_combiner; }; struct grpc_call_stats { - grpc_transport_stream_stats transport_stream_stats; - gpr_timespec latency; /* From call creating to enqueing of received status */ + grpc_transport_stream_stats transport_stream_stats; + gpr_timespec latency; /* From call creating to enqueing of received status */ }; -/** Information about the call upon completion. */ +/** Information about the call upon completion. */ struct grpc_call_final_info { - grpc_call_stats stats; + grpc_call_stats stats; grpc_status_code final_status = GRPC_STATUS_OK; const char* error_string = nullptr; }; - -/* Channel filters specify: - 1. the amount of memory needed in the channel & call (via the sizeof_XXX - members) - 2. functions to initialize and destroy channel & call data - (init_XXX, destroy_XXX) - 3. functions to implement call operations and channel operations (call_op, - channel_op) - 4. a name, which is useful when debugging - - Members are laid out in approximate frequency of use order. */ + +/* Channel filters specify: + 1. the amount of memory needed in the channel & call (via the sizeof_XXX + members) + 2. functions to initialize and destroy channel & call data + (init_XXX, destroy_XXX) + 3. functions to implement call operations and channel operations (call_op, + channel_op) + 4. a name, which is useful when debugging + + Members are laid out in approximate frequency of use order. */ struct grpc_channel_filter { - /* Called to eg. send/receive data on a call. - See grpc_call_next_op on how to call the next element in the stack */ + /* Called to eg. send/receive data on a call. + See grpc_call_next_op on how to call the next element in the stack */ void (*start_transport_stream_op_batch)(grpc_call_element* elem, grpc_transport_stream_op_batch* op); - /* Called to handle channel level operations - e.g. new calls, or transport - closure. - See grpc_channel_next_op on how to call the next element in the stack */ + /* Called to handle channel level operations - e.g. new calls, or transport + closure. + See grpc_channel_next_op on how to call the next element in the stack */ void (*start_transport_op)(grpc_channel_element* elem, grpc_transport_op* op); - - /* sizeof(per call data) */ - size_t sizeof_call_data; - /* Initialize per call data. - elem is initialized at the start of the call, and elem->call_data is what - needs initializing. - The filter does not need to do any chaining. - server_transport_data is an opaque pointer. If it is NULL, this call is - on a client; if it is non-NULL, then it points to memory owned by the - transport and is on the server. Most filters want to ignore this + + /* sizeof(per call data) */ + size_t sizeof_call_data; + /* Initialize per call data. + elem is initialized at the start of the call, and elem->call_data is what + needs initializing. + The filter does not need to do any chaining. + server_transport_data is an opaque pointer. If it is NULL, this call is + on a client; if it is non-NULL, then it points to memory owned by the + transport and is on the server. Most filters want to ignore this argument. Implementations may assume that elem->call_data is all zeros. */ grpc_error* (*init_call_elem)(grpc_call_element* elem, const grpc_call_element_args* args); void (*set_pollset_or_pollset_set)(grpc_call_element* elem, grpc_polling_entity* pollent); - /* Destroy per call data. - The filter does not need to do any chaining. - The bottom filter of a stack will be passed a non-NULL pointer to + /* Destroy per call data. + The filter does not need to do any chaining. + The bottom filter of a stack will be passed a non-NULL pointer to \a then_schedule_closure that should be passed to GRPC_CLOSURE_SCHED when destruction is complete. \a final_info contains data about the completed call, mainly for reporting purposes. */ void (*destroy_call_elem)(grpc_call_element* elem, const grpc_call_final_info* final_info, grpc_closure* then_schedule_closure); - - /* sizeof(per channel data) */ - size_t sizeof_channel_data; - /* Initialize per-channel data. - elem is initialized at the creating of the channel, and elem->channel_data - is what needs initializing. - is_first, is_last designate this elements position in the stack, and are - useful for asserting correct configuration by upper layer code. + + /* sizeof(per channel data) */ + size_t sizeof_channel_data; + /* Initialize per-channel data. + elem is initialized at the creating of the channel, and elem->channel_data + is what needs initializing. + is_first, is_last designate this elements position in the stack, and are + useful for asserting correct configuration by upper layer code. The filter does not need to do any chaining. Implementations may assume that elem->channel_data is all zeros. */ grpc_error* (*init_channel_elem)(grpc_channel_element* elem, grpc_channel_element_args* args); - /* Destroy per channel data. - The filter does not need to do any chaining */ + /* Destroy per channel data. + The filter does not need to do any chaining */ void (*destroy_channel_elem)(grpc_channel_element* elem); - - /* Implement grpc_channel_get_info() */ + + /* Implement grpc_channel_get_info() */ void (*get_channel_info)(grpc_channel_element* elem, const grpc_channel_info* channel_info); - - /* The name of this filter */ + + /* The name of this filter */ const char* name; }; -/* A channel_element tracks its filter and the filter requested memory within - a channel allocation */ -struct grpc_channel_element { +/* A channel_element tracks its filter and the filter requested memory within + a channel allocation */ +struct grpc_channel_element { const grpc_channel_filter* filter; void* channel_data; -}; - -/* A call_element tracks its filter, the filter requested memory within - a channel allocation, and the filter requested memory within a call - allocation */ -struct grpc_call_element { +}; + +/* A call_element tracks its filter, the filter requested memory within + a channel allocation, and the filter requested memory within a call + allocation */ +struct grpc_call_element { const grpc_channel_filter* filter; void* channel_data; void* call_data; -}; - -/* A channel stack tracks a set of related filters for one channel, and - guarantees they live within a single malloc() allocation */ -struct grpc_channel_stack { - grpc_stream_refcount refcount; - size_t count; - /* Memory required for a call stack (computed at channel stack - initialization) */ - size_t call_stack_size; -}; - -/* A call stack tracks a set of related filters for one call, and guarantees - they live within a single malloc() allocation */ -struct grpc_call_stack { - /* shared refcount for this channel stack. - MUST be the first element: the underlying code calls destroy - with the address of the refcount, but higher layers prefer to think - about the address of the call stack itself. */ - grpc_stream_refcount refcount; - size_t count; -}; - -/* Get a channel element given a channel stack and its index */ +}; + +/* A channel stack tracks a set of related filters for one channel, and + guarantees they live within a single malloc() allocation */ +struct grpc_channel_stack { + grpc_stream_refcount refcount; + size_t count; + /* Memory required for a call stack (computed at channel stack + initialization) */ + size_t call_stack_size; +}; + +/* A call stack tracks a set of related filters for one call, and guarantees + they live within a single malloc() allocation */ +struct grpc_call_stack { + /* shared refcount for this channel stack. + MUST be the first element: the underlying code calls destroy + with the address of the refcount, but higher layers prefer to think + about the address of the call stack itself. */ + grpc_stream_refcount refcount; + size_t count; +}; + +/* Get a channel element given a channel stack and its index */ grpc_channel_element* grpc_channel_stack_element(grpc_channel_stack* stack, - size_t i); -/* Get the last channel element in a channel stack */ + size_t i); +/* Get the last channel element in a channel stack */ grpc_channel_element* grpc_channel_stack_last_element( grpc_channel_stack* stack); -/* Get a call stack element given a call stack and an index */ +/* Get a call stack element given a call stack and an index */ grpc_call_element* grpc_call_stack_element(grpc_call_stack* stack, size_t i); - -/* Determine memory required for a channel stack containing a set of filters */ + +/* Determine memory required for a channel stack containing a set of filters */ size_t grpc_channel_stack_size(const grpc_channel_filter** filters, - size_t filter_count); -/* Initialize a channel stack given some filters */ + size_t filter_count); +/* Initialize a channel stack given some filters */ grpc_error* grpc_channel_stack_init( int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg, const grpc_channel_filter** filters, size_t filter_count, const grpc_channel_args* args, grpc_transport* optional_transport, const char* name, grpc_channel_stack* stack); -/* Destroy a channel stack */ +/* Destroy a channel stack */ void grpc_channel_stack_destroy(grpc_channel_stack* stack); - -/* Initialize a call stack given a channel stack. transport_server_data is - expected to be NULL on a client, or an opaque transport owned pointer on the - server. */ + +/* Initialize a call stack given a channel stack. transport_server_data is + expected to be NULL on a client, or an opaque transport owned pointer on the + server. */ grpc_error* grpc_call_stack_init(grpc_channel_stack* channel_stack, int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg, const grpc_call_element_args* elem_args); -/* Set a pollset or a pollset_set for a call stack: must occur before the first - * op is started */ +/* Set a pollset or a pollset_set for a call stack: must occur before the first + * op is started */ void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack, grpc_polling_entity* pollent); - + #ifndef NDEBUG -#define GRPC_CALL_STACK_REF(call_stack, reason) \ - grpc_stream_ref(&(call_stack)->refcount, reason) +#define GRPC_CALL_STACK_REF(call_stack, reason) \ + grpc_stream_ref(&(call_stack)->refcount, reason) #define GRPC_CALL_STACK_UNREF(call_stack, reason) \ grpc_stream_unref(&(call_stack)->refcount, reason) -#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \ - grpc_stream_ref(&(channel_stack)->refcount, reason) +#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \ + grpc_stream_ref(&(channel_stack)->refcount, reason) #define GRPC_CHANNEL_STACK_UNREF(channel_stack, reason) \ grpc_stream_unref(&(channel_stack)->refcount, reason) -#else -#define GRPC_CALL_STACK_REF(call_stack, reason) \ +#else +#define GRPC_CALL_STACK_REF(call_stack, reason) \ do { \ grpc_stream_ref(&(call_stack)->refcount); \ (void)(reason); \ @@ -251,7 +251,7 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack, grpc_stream_unref(&(call_stack)->refcount); \ (void)(reason); \ } while (0); -#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \ +#define GRPC_CHANNEL_STACK_REF(channel_stack, reason) \ do { \ grpc_stream_ref(&(channel_stack)->refcount); \ (void)(reason); \ @@ -261,44 +261,44 @@ void grpc_call_stack_set_pollset_or_pollset_set(grpc_call_stack* call_stack, grpc_stream_unref(&(channel_stack)->refcount); \ (void)(reason); \ } while (0); -#endif - -/* Destroy a call stack */ +#endif + +/* Destroy a call stack */ void grpc_call_stack_destroy(grpc_call_stack* stack, const grpc_call_final_info* final_info, grpc_closure* then_schedule_closure); - -/* Ignore set pollset{_set} - used by filters if they don't care about pollsets - * at all. Does nothing. */ -void grpc_call_stack_ignore_set_pollset_or_pollset_set( + +/* Ignore set pollset{_set} - used by filters if they don't care about pollsets + * at all. Does nothing. */ +void grpc_call_stack_ignore_set_pollset_or_pollset_set( grpc_call_element* elem, grpc_polling_entity* pollent); -/* Call the next operation in a call stack */ +/* Call the next operation in a call stack */ void grpc_call_next_op(grpc_call_element* elem, grpc_transport_stream_op_batch* op); -/* Call the next operation (depending on call directionality) in a channel - stack */ +/* Call the next operation (depending on call directionality) in a channel + stack */ void grpc_channel_next_op(grpc_channel_element* elem, grpc_transport_op* op); -/* Pass through a request to get_channel_info() to the next child element */ +/* Pass through a request to get_channel_info() to the next child element */ void grpc_channel_next_get_info(grpc_channel_element* elem, const grpc_channel_info* channel_info); - -/* Given the top element of a channel stack, get the channel stack itself */ + +/* Given the top element of a channel stack, get the channel stack itself */ grpc_channel_stack* grpc_channel_stack_from_top_element( grpc_channel_element* elem); -/* Given the top element of a call stack, get the call stack itself */ +/* Given the top element of a call stack, get the call stack itself */ grpc_call_stack* grpc_call_stack_from_top_element(grpc_call_element* elem); - + void grpc_call_log_op(const char* file, int line, gpr_log_severity severity, grpc_call_element* elem, grpc_transport_stream_op_batch* op); - + extern grpc_core::TraceFlag grpc_trace_channel; - + #define GRPC_CALL_LOG_OP(sev, elem, op) \ do { \ if (GRPC_TRACE_FLAG_ENABLED(grpc_trace_channel)) { \ grpc_call_log_op(sev, elem, op); \ } \ } while (0) - -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H */ + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/channel_stack_builder.h b/contrib/libs/grpc/src/core/lib/channel/channel_stack_builder.h index 89c30e0c5e..11c114ec8c 100644 --- a/contrib/libs/grpc/src/core/lib/channel/channel_stack_builder.h +++ b/contrib/libs/grpc/src/core/lib/channel/channel_stack_builder.h @@ -1,59 +1,59 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H -#define GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H +#define GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H + #include <grpc/support/port_platform.h> -#include <stdbool.h> - -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_stack.h" - -/// grpc_channel_stack_builder offers a programmatic interface to selected -/// and order channel filters -typedef struct grpc_channel_stack_builder grpc_channel_stack_builder; -typedef struct grpc_channel_stack_builder_iterator - grpc_channel_stack_builder_iterator; - -/// Create a new channel stack builder +#include <stdbool.h> + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/channel_stack.h" + +/// grpc_channel_stack_builder offers a programmatic interface to selected +/// and order channel filters +typedef struct grpc_channel_stack_builder grpc_channel_stack_builder; +typedef struct grpc_channel_stack_builder_iterator + grpc_channel_stack_builder_iterator; + +/// Create a new channel stack builder grpc_channel_stack_builder* grpc_channel_stack_builder_create(void); - -/// Assign a name to the channel stack: \a name must be statically allocated + +/// Assign a name to the channel stack: \a name must be statically allocated void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder, const char* name); - -/// Set the target uri + +/// Set the target uri void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b, const char* target); - + const char* grpc_channel_stack_builder_get_target( grpc_channel_stack_builder* b); - -/// Attach \a transport to the builder (does not take ownership) -void grpc_channel_stack_builder_set_transport( + +/// Attach \a transport to the builder (does not take ownership) +void grpc_channel_stack_builder_set_transport( grpc_channel_stack_builder* builder, grpc_transport* transport); - -/// Fetch attached transport + +/// Fetch attached transport grpc_transport* grpc_channel_stack_builder_get_transport( grpc_channel_stack_builder* builder); - + /// Attach \a resource_user to the builder (does not take ownership) void grpc_channel_stack_builder_set_resource_user( grpc_channel_stack_builder* builder, grpc_resource_user* resource_user); @@ -62,105 +62,105 @@ void grpc_channel_stack_builder_set_resource_user( grpc_resource_user* grpc_channel_stack_builder_get_resource_user( grpc_channel_stack_builder* builder); -/// Set channel arguments: copies args -void grpc_channel_stack_builder_set_channel_arguments( +/// Set channel arguments: copies args +void grpc_channel_stack_builder_set_channel_arguments( grpc_channel_stack_builder* builder, const grpc_channel_args* args); - -/// Return a borrowed pointer to the channel arguments + +/// Return a borrowed pointer to the channel arguments const grpc_channel_args* grpc_channel_stack_builder_get_channel_arguments( grpc_channel_stack_builder* builder); - -/// Begin iterating over already defined filters in the builder at the beginning + +/// Begin iterating over already defined filters in the builder at the beginning grpc_channel_stack_builder_iterator* -grpc_channel_stack_builder_create_iterator_at_first( +grpc_channel_stack_builder_create_iterator_at_first( grpc_channel_stack_builder* builder); - -/// Begin iterating over already defined filters in the builder at the end + +/// Begin iterating over already defined filters in the builder at the end grpc_channel_stack_builder_iterator* -grpc_channel_stack_builder_create_iterator_at_last( +grpc_channel_stack_builder_create_iterator_at_last( grpc_channel_stack_builder* builder); - -/// Is an iterator at the first element? -bool grpc_channel_stack_builder_iterator_is_first( + +/// Is an iterator at the first element? +bool grpc_channel_stack_builder_iterator_is_first( grpc_channel_stack_builder_iterator* iterator); - -/// Is an iterator at the end? -bool grpc_channel_stack_builder_iterator_is_end( + +/// Is an iterator at the end? +bool grpc_channel_stack_builder_iterator_is_end( grpc_channel_stack_builder_iterator* iterator); - + /// What is the name of the filter at this iterator position? const char* grpc_channel_stack_builder_iterator_filter_name( grpc_channel_stack_builder_iterator* iterator); -/// Move an iterator to the next item -bool grpc_channel_stack_builder_move_next( +/// Move an iterator to the next item +bool grpc_channel_stack_builder_move_next( grpc_channel_stack_builder_iterator* iterator); - -/// Move an iterator to the previous item -bool grpc_channel_stack_builder_move_prev( + +/// Move an iterator to the previous item +bool grpc_channel_stack_builder_move_prev( grpc_channel_stack_builder_iterator* iterator); - + /// Return an iterator at \a filter_name, or at the end of the list if not /// found. grpc_channel_stack_builder_iterator* grpc_channel_stack_builder_iterator_find( grpc_channel_stack_builder* builder, const char* filter_name); -typedef void (*grpc_post_filter_create_init_func)( +typedef void (*grpc_post_filter_create_init_func)( grpc_channel_stack* channel_stack, grpc_channel_element* elem, void* arg); - -/// Add \a filter to the stack, after \a iterator. -/// Call \a post_init_func(..., \a user_data) once the channel stack is -/// created. -bool grpc_channel_stack_builder_add_filter_after( + +/// Add \a filter to the stack, after \a iterator. +/// Call \a post_init_func(..., \a user_data) once the channel stack is +/// created. +bool grpc_channel_stack_builder_add_filter_after( grpc_channel_stack_builder_iterator* iterator, const grpc_channel_filter* filter, - grpc_post_filter_create_init_func post_init_func, + grpc_post_filter_create_init_func post_init_func, void* user_data) GRPC_MUST_USE_RESULT; - -/// Add \a filter to the stack, before \a iterator. -/// Call \a post_init_func(..., \a user_data) once the channel stack is -/// created. -bool grpc_channel_stack_builder_add_filter_before( + +/// Add \a filter to the stack, before \a iterator. +/// Call \a post_init_func(..., \a user_data) once the channel stack is +/// created. +bool grpc_channel_stack_builder_add_filter_before( grpc_channel_stack_builder_iterator* iterator, const grpc_channel_filter* filter, - grpc_post_filter_create_init_func post_init_func, + grpc_post_filter_create_init_func post_init_func, void* user_data) GRPC_MUST_USE_RESULT; - -/// Add \a filter to the beginning of the filter list. -/// Call \a post_init_func(..., \a user_data) once the channel stack is -/// created. -bool grpc_channel_stack_builder_prepend_filter( + +/// Add \a filter to the beginning of the filter list. +/// Call \a post_init_func(..., \a user_data) once the channel stack is +/// created. +bool grpc_channel_stack_builder_prepend_filter( grpc_channel_stack_builder* builder, const grpc_channel_filter* filter, - grpc_post_filter_create_init_func post_init_func, + grpc_post_filter_create_init_func post_init_func, void* user_data) GRPC_MUST_USE_RESULT; - -/// Add \a filter to the end of the filter list. -/// Call \a post_init_func(..., \a user_data) once the channel stack is -/// created. -bool grpc_channel_stack_builder_append_filter( + +/// Add \a filter to the end of the filter list. +/// Call \a post_init_func(..., \a user_data) once the channel stack is +/// created. +bool grpc_channel_stack_builder_append_filter( grpc_channel_stack_builder* builder, const grpc_channel_filter* filter, - grpc_post_filter_create_init_func post_init_func, + grpc_post_filter_create_init_func post_init_func, void* user_data) GRPC_MUST_USE_RESULT; - + /// Remove any filter whose name is \a filter_name from \a builder. Returns true /// if \a filter_name was not found. bool grpc_channel_stack_builder_remove_filter( grpc_channel_stack_builder* builder, const char* filter_name); -/// Terminate iteration and destroy \a iterator -void grpc_channel_stack_builder_iterator_destroy( +/// Terminate iteration and destroy \a iterator +void grpc_channel_stack_builder_iterator_destroy( grpc_channel_stack_builder_iterator* iterator); - -/// Destroy the builder, return the freshly minted channel stack in \a result. -/// Allocates \a prefix_bytes bytes before the channel stack -/// Returns the base pointer of the allocated block -/// \a initial_refs, \a destroy, \a destroy_arg are as per -/// grpc_channel_stack_init + +/// Destroy the builder, return the freshly minted channel stack in \a result. +/// Allocates \a prefix_bytes bytes before the channel stack +/// Returns the base pointer of the allocated block +/// \a initial_refs, \a destroy, \a destroy_arg are as per +/// grpc_channel_stack_init grpc_error* grpc_channel_stack_builder_finish( grpc_channel_stack_builder* builder, size_t prefix_bytes, int initial_refs, grpc_iomgr_cb_func destroy, void* destroy_arg, void** result); - -/// Destroy the builder without creating a channel stack + +/// Destroy the builder without creating a channel stack void grpc_channel_stack_builder_destroy(grpc_channel_stack_builder* builder); - -#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H */ + +#endif /* GRPC_CORE_LIB_CHANNEL_CHANNEL_STACK_BUILDER_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/connected_channel.h b/contrib/libs/grpc/src/core/lib/channel/connected_channel.h index faa1c73a21..db5a40cfc5 100644 --- a/contrib/libs/grpc/src/core/lib/channel/connected_channel.h +++ b/contrib/libs/grpc/src/core/lib/channel/connected_channel.h @@ -1,34 +1,34 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H -#define GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H +#define GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/channel/channel_stack_builder.h" - +#include "src/core/lib/channel/channel_stack_builder.h" + extern const grpc_channel_filter grpc_connected_filter; - + bool grpc_add_connected_filter(grpc_channel_stack_builder* builder, void* arg_must_be_null); /* Debug helper to dig the transport stream out of a call element */ grpc_stream* grpc_connected_channel_get_stream(grpc_call_element* elem); -#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/context.h b/contrib/libs/grpc/src/core/lib/channel/context.h index bd7fd495e4..b1849e5f79 100644 --- a/contrib/libs/grpc/src/core/lib/channel/context.h +++ b/contrib/libs/grpc/src/core/lib/channel/context.h @@ -1,49 +1,49 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_CHANNEL_CONTEXT_H -#define GRPC_CORE_LIB_CHANNEL_CONTEXT_H - -/// Call object context pointers. - -/// Call context is represented as an array of \a grpc_call_context_elements. -/// This enum represents the indexes into the array, where each index -/// contains a different type of value. -typedef enum { - /// Value is either a \a grpc_client_security_context or a - /// \a grpc_server_security_context. - GRPC_CONTEXT_SECURITY = 0, - - /// Value is a \a census_context. - GRPC_CONTEXT_TRACING, - - /// Reserved for traffic_class_context. - GRPC_CONTEXT_TRAFFIC, - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_CONTEXT_H +#define GRPC_CORE_LIB_CHANNEL_CONTEXT_H + +/// Call object context pointers. + +/// Call context is represented as an array of \a grpc_call_context_elements. +/// This enum represents the indexes into the array, where each index +/// contains a different type of value. +typedef enum { + /// Value is either a \a grpc_client_security_context or a + /// \a grpc_server_security_context. + GRPC_CONTEXT_SECURITY = 0, + + /// Value is a \a census_context. + GRPC_CONTEXT_TRACING, + + /// Reserved for traffic_class_context. + GRPC_CONTEXT_TRAFFIC, + /// Holds a pointer to ServiceConfigCallData associated with this call. GRPC_CONTEXT_SERVICE_CONFIG_CALL_DATA, - GRPC_CONTEXT_COUNT -} grpc_context_index; - + GRPC_CONTEXT_COUNT +} grpc_context_index; + struct grpc_call_context_element { void* value = nullptr; void (*destroy)(void*) = nullptr; }; - -#endif /* GRPC_CORE_LIB_CHANNEL_CONTEXT_H */ + +#endif /* GRPC_CORE_LIB_CHANNEL_CONTEXT_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker.h b/contrib/libs/grpc/src/core/lib/channel/handshaker.h index cc8e9b2578..5fd29afb32 100644 --- a/contrib/libs/grpc/src/core/lib/channel/handshaker.h +++ b/contrib/libs/grpc/src/core/lib/channel/handshaker.h @@ -1,80 +1,80 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H -#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H +#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H + #include <grpc/support/port_platform.h> #include "y_absl/container/inlined_vector.h" #include <grpc/support/string_util.h> -#include <grpc/impl/codegen/grpc_types.h> - +#include <grpc/impl/codegen/grpc_types.h> + #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/tcp_server.h" +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/tcp_server.h" #include "src/core/lib/iomgr/timer.h" - + namespace grpc_core { -/// Handshakers are used to perform initial handshakes on a connection -/// before the client sends the initial request. Some examples of what -/// a handshaker can be used for includes support for HTTP CONNECT on -/// the client side and various types of security initialization. -/// -/// In general, handshakers should be used via a handshake manager. - -/// Arguments passed through handshakers and to the on_handshake_done callback. -/// -/// For handshakers, all members are input/output parameters; for -/// example, a handshaker may read from or write to \a endpoint and -/// then later replace it with a wrapped endpoint. Similarly, a -/// handshaker may modify \a args. -/// -/// A handshaker takes ownership of the members while a handshake is in -/// progress. Upon failure or shutdown of an in-progress handshaker, -/// the handshaker is responsible for destroying the members and setting -/// them to NULL before invoking the on_handshake_done callback. -/// -/// For the on_handshake_done callback, all members are input arguments, -/// which the callback takes ownership of. +/// Handshakers are used to perform initial handshakes on a connection +/// before the client sends the initial request. Some examples of what +/// a handshaker can be used for includes support for HTTP CONNECT on +/// the client side and various types of security initialization. +/// +/// In general, handshakers should be used via a handshake manager. + +/// Arguments passed through handshakers and to the on_handshake_done callback. +/// +/// For handshakers, all members are input/output parameters; for +/// example, a handshaker may read from or write to \a endpoint and +/// then later replace it with a wrapped endpoint. Similarly, a +/// handshaker may modify \a args. +/// +/// A handshaker takes ownership of the members while a handshake is in +/// progress. Upon failure or shutdown of an in-progress handshaker, +/// the handshaker is responsible for destroying the members and setting +/// them to NULL before invoking the on_handshake_done callback. +/// +/// For the on_handshake_done callback, all members are input arguments, +/// which the callback takes ownership of. struct HandshakerArgs { grpc_endpoint* endpoint = nullptr; grpc_channel_args* args = nullptr; grpc_slice_buffer* read_buffer = nullptr; - // A handshaker may set this to true before invoking on_handshake_done - // to indicate that subsequent handshakers should be skipped. + // A handshaker may set this to true before invoking on_handshake_done + // to indicate that subsequent handshakers should be skipped. bool exit_early = false; - // User data passed through the handshake manager. Not used by - // individual handshakers. + // User data passed through the handshake manager. Not used by + // individual handshakers. void* user_data = nullptr; }; - + /// /// Handshaker /// - + class Handshaker : public RefCounted<Handshaker> { public: virtual ~Handshaker() = default; @@ -84,7 +84,7 @@ class Handshaker : public RefCounted<Handshaker> { HandshakerArgs* args) = 0; virtual const char* name() const = 0; }; - + // // HandshakeManager // @@ -93,28 +93,28 @@ class HandshakeManager : public RefCounted<HandshakeManager> { public: HandshakeManager(); ~HandshakeManager(); - + /// Add \a mgr to the server side list of all pending handshake managers, the /// list starts with \a *head. // Not thread-safe. Caller needs to synchronize. void AddToPendingMgrList(HandshakeManager** head); - + /// Remove \a mgr from the server side list of all pending handshake managers. // Not thread-safe. Caller needs to synchronize. void RemoveFromPendingMgrList(HandshakeManager** head); - + /// Shutdown all pending handshake managers starting at head on the server /// side. Not thread-safe. Caller needs to synchronize. void ShutdownAllPending(grpc_error* why); - + /// Adds a handshaker to the handshake manager. /// Takes ownership of \a handshaker. void Add(RefCountedPtr<Handshaker> handshaker); - + /// Shuts down the handshake manager (e.g., to clean up when the operation is /// aborted in the middle). void Shutdown(grpc_error* why); - + /// Invokes handshakers in the order they were added. /// Takes ownership of \a endpoint, and then passes that ownership to /// the \a on_handshake_done callback. @@ -131,19 +131,19 @@ class HandshakeManager : public RefCounted<HandshakeManager> { const grpc_channel_args* channel_args, grpc_millis deadline, grpc_tcp_server_acceptor* acceptor, grpc_iomgr_cb_func on_handshake_done, void* user_data); - + private: bool CallNextHandshakerLocked(grpc_error* error); - + // A function used as the handshaker-done callback when chaining // handshakers together. static void CallNextHandshakerFn(void* arg, grpc_error* error); - + // Callback invoked when deadline is exceeded. static void OnTimeoutFn(void* arg, grpc_error* error); - + static const size_t HANDSHAKERS_INIT_SIZE = 2; - + gpr_mu mu_; bool is_shutdown_ = false; // An array of handshakers added via grpc_handshake_manager_add(). @@ -176,4 +176,4 @@ typedef grpc_core::Handshaker grpc_handshaker; void grpc_handshake_manager_add(grpc_handshake_manager* mgr, grpc_handshaker* handshaker); -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker_factory.h b/contrib/libs/grpc/src/core/lib/channel/handshaker_factory.h index 520e5e4b25..d3022c7ffa 100644 --- a/contrib/libs/grpc/src/core/lib/channel/handshaker_factory.h +++ b/contrib/libs/grpc/src/core/lib/channel/handshaker_factory.h @@ -1,42 +1,42 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H -#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H +#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> - -#include "src/core/lib/channel/handshaker.h" - -// A handshaker factory is used to create handshakers. - +#include <grpc/impl/codegen/grpc_types.h> + +#include "src/core/lib/channel/handshaker.h" + +// A handshaker factory is used to create handshakers. + namespace grpc_core { - + class HandshakerFactory { public: virtual void AddHandshakers(const grpc_channel_args* args, grpc_pollset_set* interested_parties, HandshakeManager* handshake_mgr) = 0; virtual ~HandshakerFactory() = default; -}; - +}; + } // namespace grpc_core - -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ + +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_FACTORY_H */ diff --git a/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.h b/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.h index 4a02efc3f2..0bbdf29b45 100644 --- a/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.h +++ b/contrib/libs/grpc/src/core/lib/channel/handshaker_registry.h @@ -1,38 +1,38 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H -#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H - + * + */ + +#ifndef GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H +#define GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> - -#include "src/core/lib/channel/handshaker_factory.h" - +#include <grpc/impl/codegen/grpc_types.h> + +#include "src/core/lib/channel/handshaker_factory.h" + namespace grpc_core { -typedef enum { - HANDSHAKER_CLIENT = 0, - HANDSHAKER_SERVER, - NUM_HANDSHAKER_TYPES, // Must be last. +typedef enum { + HANDSHAKER_CLIENT = 0, + HANDSHAKER_SERVER, + NUM_HANDSHAKER_TYPES, // Must be last. } HandshakerType; - + class HandshakerRegistry { public: /// Registers a new handshaker factory. Takes ownership. @@ -48,7 +48,7 @@ class HandshakerRegistry { static void Init(); static void Shutdown(); }; - + } // namespace grpc_core - -#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ + +#endif /* GRPC_CORE_LIB_CHANNEL_HANDSHAKER_REGISTRY_H */ diff --git a/contrib/libs/grpc/src/core/lib/compression/algorithm_metadata.h b/contrib/libs/grpc/src/core/lib/compression/algorithm_metadata.h index d58d2f541a..ab8e17e5b4 100644 --- a/contrib/libs/grpc/src/core/lib/compression/algorithm_metadata.h +++ b/contrib/libs/grpc/src/core/lib/compression/algorithm_metadata.h @@ -1,34 +1,34 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H -#define GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H - + * + */ + +#ifndef GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H +#define GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H + #include <grpc/support/port_platform.h> -#include <grpc/compression.h> +#include <grpc/compression.h> #include "src/core/lib/compression/compression_internal.h" -#include "src/core/lib/transport/metadata.h" - -/** Return compression algorithm based metadata value */ +#include "src/core/lib/transport/metadata.h" + +/** Return compression algorithm based metadata value */ grpc_slice grpc_compression_algorithm_slice( - grpc_compression_algorithm algorithm); - + grpc_compression_algorithm algorithm); + /** Find compression algorithm based on passed in mdstr - returns * GRPC_COMPRESS_ALGORITHM_COUNT on failure */ grpc_compression_algorithm grpc_compression_algorithm_from_slice( @@ -36,8 +36,8 @@ grpc_compression_algorithm grpc_compression_algorithm_from_slice( /** Return compression algorithm based metadata element */ grpc_mdelem grpc_compression_encoding_mdelem( - grpc_compression_algorithm algorithm); - + grpc_compression_algorithm algorithm); + /** Return message compression algorithm based metadata element (grpc-encoding: * xxx) */ grpc_mdelem grpc_message_compression_encoding_mdelem( @@ -48,14 +48,14 @@ grpc_mdelem grpc_message_compression_encoding_mdelem( grpc_mdelem grpc_stream_compression_encoding_mdelem( grpc_stream_compression_algorithm algorithm); -/** Find compression algorithm based on passed in mdstr - returns - * GRPC_COMPRESS_ALGORITHM_COUNT on failure */ +/** Find compression algorithm based on passed in mdstr - returns + * GRPC_COMPRESS_ALGORITHM_COUNT on failure */ grpc_message_compression_algorithm grpc_message_compression_algorithm_from_slice(const grpc_slice& str); - + /** Find stream compression algorithm based on passed in mdstr - returns * GRPC_STREAM_COMPRESS_ALGORITHM_COUNT on failure */ grpc_stream_compression_algorithm grpc_stream_compression_algorithm_from_slice( const grpc_slice& str); -#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ +#endif /* GRPC_CORE_LIB_COMPRESSION_ALGORITHM_METADATA_H */ diff --git a/contrib/libs/grpc/src/core/lib/compression/message_compress.h b/contrib/libs/grpc/src/core/lib/compression/message_compress.h index 91654e47e3..0427d2f1a6 100644 --- a/contrib/libs/grpc/src/core/lib/compression/message_compress.h +++ b/contrib/libs/grpc/src/core/lib/compression/message_compress.h @@ -1,40 +1,40 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H -#define GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H - + * + */ + +#ifndef GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H +#define GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H + #include <grpc/support/port_platform.h> -#include <grpc/slice_buffer.h> - +#include <grpc/slice_buffer.h> + #include "src/core/lib/compression/compression_internal.h" -/* compress 'input' to 'output' using 'algorithm'. - On success, appends compressed slices to output and returns 1. - On failure, appends uncompressed slices to output and returns 0. */ +/* compress 'input' to 'output' using 'algorithm'. + On success, appends compressed slices to output and returns 1. + On failure, appends uncompressed slices to output and returns 0. */ int grpc_msg_compress(grpc_message_compression_algorithm algorithm, - grpc_slice_buffer* input, grpc_slice_buffer* output); - -/* decompress 'input' to 'output' using 'algorithm'. - On success, appends slices to output and returns 1. - On failure, output is unchanged, and returns 0. */ + grpc_slice_buffer* input, grpc_slice_buffer* output); + +/* decompress 'input' to 'output' using 'algorithm'. + On success, appends slices to output and returns 1. + On failure, output is unchanged, and returns 0. */ int grpc_msg_decompress(grpc_message_compression_algorithm algorithm, - grpc_slice_buffer* input, grpc_slice_buffer* output); - -#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ + grpc_slice_buffer* input, grpc_slice_buffer* output); + +#endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ diff --git a/contrib/libs/grpc/src/core/lib/debug/trace.h b/contrib/libs/grpc/src/core/lib/debug/trace.h index ac7b40e58a..bf8edb21ad 100644 --- a/contrib/libs/grpc/src/core/lib/debug/trace.h +++ b/contrib/libs/grpc/src/core/lib/debug/trace.h @@ -1,26 +1,26 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_DEBUG_TRACE_H -#define GRPC_CORE_LIB_DEBUG_TRACE_H - -#include <grpc/support/port_platform.h> - + * + */ + +#ifndef GRPC_CORE_LIB_DEBUG_TRACE_H +#define GRPC_CORE_LIB_DEBUG_TRACE_H + +#include <grpc/support/port_platform.h> + #include <grpc/support/atm.h> #include <stdbool.h> @@ -33,8 +33,8 @@ GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_trace); void grpc_tracer_init(const char* env_var_name); void grpc_tracer_init(); -void grpc_tracer_shutdown(void); - +void grpc_tracer_shutdown(void); + #if defined(__has_feature) #if __has_feature(thread_sanitizer) #define GRPC_THREADSAFE_TRACER @@ -128,4 +128,4 @@ class DebugOnlyTraceFlag { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_DEBUG_TRACE_H */ +#endif /* GRPC_CORE_LIB_DEBUG_TRACE_H */ diff --git a/contrib/libs/grpc/src/core/lib/http/format_request.h b/contrib/libs/grpc/src/core/lib/http/format_request.h index bcc332fe6e..8ef0bd0865 100644 --- a/contrib/libs/grpc/src/core/lib/http/format_request.h +++ b/contrib/libs/grpc/src/core/lib/http/format_request.h @@ -1,34 +1,34 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H -#define GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H - + * + */ + +#ifndef GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H +#define GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/lib/http/httpcli.h" - +#include <grpc/slice.h> +#include "src/core/lib/http/httpcli.h" + grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request* request); grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request* request, const char* body_bytes, - size_t body_size); -grpc_slice grpc_httpcli_format_connect_request( + size_t body_size); +grpc_slice grpc_httpcli_format_connect_request( const grpc_httpcli_request* request); - -#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ + +#endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ diff --git a/contrib/libs/grpc/src/core/lib/http/httpcli.h b/contrib/libs/grpc/src/core/lib/http/httpcli.h index 16a160cc96..77bef0c762 100644 --- a/contrib/libs/grpc/src/core/lib/http/httpcli.h +++ b/contrib/libs/grpc/src/core/lib/http/httpcli.h @@ -1,105 +1,105 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_HTTP_HTTPCLI_H -#define GRPC_CORE_LIB_HTTP_HTTPCLI_H - + * + */ + +#ifndef GRPC_CORE_LIB_HTTP_HTTPCLI_H +#define GRPC_CORE_LIB_HTTP_HTTPCLI_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include <grpc/support/time.h> - -#include "src/core/lib/http/parser.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/iomgr_internal.h" -#include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/iomgr/pollset_set.h" - -/* User agent this library reports */ -#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0" - -/* Tracks in-progress http requests - TODO(ctiller): allow caching and capturing multiple requests for the - same content and combining them */ -typedef struct grpc_httpcli_context { +#include <stddef.h> + +#include <grpc/support/time.h> + +#include "src/core/lib/http/parser.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/iomgr_internal.h" +#include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/iomgr/pollset_set.h" + +/* User agent this library reports */ +#define GRPC_HTTPCLI_USER_AGENT "grpc-httpcli/0.0" + +/* Tracks in-progress http requests + TODO(ctiller): allow caching and capturing multiple requests for the + same content and combining them */ +typedef struct grpc_httpcli_context { grpc_pollset_set* pollset_set; -} grpc_httpcli_context; - +} grpc_httpcli_context; + struct grpc_httpcli_handshaker { const char* default_port; void (*handshake)(void* arg, grpc_endpoint* endpoint, const char* host, grpc_millis deadline, void (*on_done)(void* arg, grpc_endpoint* endpoint)); }; -extern const grpc_httpcli_handshaker grpc_httpcli_plaintext; -extern const grpc_httpcli_handshaker grpc_httpcli_ssl; - -/* A request */ -typedef struct grpc_httpcli_request { - /* The host name to connect to */ +extern const grpc_httpcli_handshaker grpc_httpcli_plaintext; +extern const grpc_httpcli_handshaker grpc_httpcli_ssl; + +/* A request */ +typedef struct grpc_httpcli_request { + /* The host name to connect to */ char* host; - /* The host to verify in the SSL handshake (or NULL) */ + /* The host to verify in the SSL handshake (or NULL) */ char* ssl_host_override; - /* The main part of the request - The following headers are supplied automatically and MUST NOT be set here: - Host, Connection, User-Agent */ - grpc_http_request http; - /* handshaker to use ssl for the request */ + /* The main part of the request + The following headers are supplied automatically and MUST NOT be set here: + Host, Connection, User-Agent */ + grpc_http_request http; + /* handshaker to use ssl for the request */ const grpc_httpcli_handshaker* handshaker; -} grpc_httpcli_request; - -/* Expose the parser response type as a httpcli response too */ -typedef struct grpc_http_response grpc_httpcli_response; - +} grpc_httpcli_request; + +/* Expose the parser response type as a httpcli response too */ +typedef struct grpc_http_response grpc_httpcli_response; + void grpc_httpcli_context_init(grpc_httpcli_context* context); void grpc_httpcli_context_destroy(grpc_httpcli_context* context); - -/* Asynchronously perform a HTTP GET. - 'context' specifies the http context under which to do the get - 'pollset' indicates a grpc_pollset that is interested in the result - of the get - work on this pollset may be used to progress the get - operation - 'request' contains request parameters - these are caller owned and can be - destroyed once the call returns - 'deadline' contains a deadline for the request (or gpr_inf_future) - 'on_response' is a callback to report results to */ + +/* Asynchronously perform a HTTP GET. + 'context' specifies the http context under which to do the get + 'pollset' indicates a grpc_pollset that is interested in the result + of the get - work on this pollset may be used to progress the get + operation + 'request' contains request parameters - these are caller owned and can be + destroyed once the call returns + 'deadline' contains a deadline for the request (or gpr_inf_future) + 'on_response' is a callback to report results to */ void grpc_httpcli_get(grpc_httpcli_context* context, grpc_polling_entity* pollent, grpc_resource_quota* resource_quota, const grpc_httpcli_request* request, grpc_millis deadline, grpc_closure* on_complete, grpc_httpcli_response* response); - -/* Asynchronously perform a HTTP POST. - 'context' specifies the http context under which to do the post - 'pollset' indicates a grpc_pollset that is interested in the result - of the post - work on this pollset may be used to progress the post - operation - 'request' contains request parameters - these are caller owned and can be - destroyed once the call returns - 'body_bytes' and 'body_size' specify the payload for the post. - When there is no body, pass in NULL as body_bytes. - 'deadline' contains a deadline for the request (or gpr_inf_future) - 'em' points to a caller owned event manager that must be alive for the - lifetime of the request - 'on_response' is a callback to report results to - Does not support ?var1=val1&var2=val2 in the path. */ + +/* Asynchronously perform a HTTP POST. + 'context' specifies the http context under which to do the post + 'pollset' indicates a grpc_pollset that is interested in the result + of the post - work on this pollset may be used to progress the post + operation + 'request' contains request parameters - these are caller owned and can be + destroyed once the call returns + 'body_bytes' and 'body_size' specify the payload for the post. + When there is no body, pass in NULL as body_bytes. + 'deadline' contains a deadline for the request (or gpr_inf_future) + 'em' points to a caller owned event manager that must be alive for the + lifetime of the request + 'on_response' is a callback to report results to + Does not support ?var1=val1&var2=val2 in the path. */ void grpc_httpcli_post(grpc_httpcli_context* context, grpc_polling_entity* pollent, grpc_resource_quota* resource_quota, @@ -107,8 +107,8 @@ void grpc_httpcli_post(grpc_httpcli_context* context, const char* body_bytes, size_t body_size, grpc_millis deadline, grpc_closure* on_complete, grpc_httpcli_response* response); - -/* override functions return 1 if they handled the request, 0 otherwise */ + +/* override functions return 1 if they handled the request, 0 otherwise */ typedef int (*grpc_httpcli_get_override)(const grpc_httpcli_request* request, grpc_millis deadline, grpc_closure* on_complete, @@ -119,8 +119,8 @@ typedef int (*grpc_httpcli_post_override)(const grpc_httpcli_request* request, grpc_millis deadline, grpc_closure* on_complete, grpc_httpcli_response* response); - -void grpc_httpcli_set_override(grpc_httpcli_get_override get, - grpc_httpcli_post_override post); - -#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ + +void grpc_httpcli_set_override(grpc_httpcli_get_override get, + grpc_httpcli_post_override post); + +#endif /* GRPC_CORE_LIB_HTTP_HTTPCLI_H */ diff --git a/contrib/libs/grpc/src/core/lib/http/parser.h b/contrib/libs/grpc/src/core/lib/http/parser.h index 2da21903e6..758c67e87c 100644 --- a/contrib/libs/grpc/src/core/lib/http/parser.h +++ b/contrib/libs/grpc/src/core/lib/http/parser.h @@ -1,113 +1,113 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_HTTP_PARSER_H -#define GRPC_CORE_LIB_HTTP_PARSER_H - + * + */ + +#ifndef GRPC_CORE_LIB_HTTP_PARSER_H +#define GRPC_CORE_LIB_HTTP_PARSER_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> +#include <grpc/slice.h> #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/error.h" - -/* Maximum length of a header string of the form 'Key: Value\r\n' */ -#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH 4096 - -/* A single header to be passed in a request */ -typedef struct grpc_http_header { +#include "src/core/lib/iomgr/error.h" + +/* Maximum length of a header string of the form 'Key: Value\r\n' */ +#define GRPC_HTTP_PARSER_MAX_HEADER_LENGTH 4096 + +/* A single header to be passed in a request */ +typedef struct grpc_http_header { char* key; char* value; -} grpc_http_header; - -typedef enum { - GRPC_HTTP_FIRST_LINE, - GRPC_HTTP_HEADERS, - GRPC_HTTP_BODY -} grpc_http_parser_state; - -typedef enum { - GRPC_HTTP_HTTP10, - GRPC_HTTP_HTTP11, - GRPC_HTTP_HTTP20, -} grpc_http_version; - -typedef enum { - GRPC_HTTP_RESPONSE, - GRPC_HTTP_REQUEST, -} grpc_http_type; - -/* A request */ -typedef struct grpc_http_request { - /* Method of the request (e.g. GET, POST) */ +} grpc_http_header; + +typedef enum { + GRPC_HTTP_FIRST_LINE, + GRPC_HTTP_HEADERS, + GRPC_HTTP_BODY +} grpc_http_parser_state; + +typedef enum { + GRPC_HTTP_HTTP10, + GRPC_HTTP_HTTP11, + GRPC_HTTP_HTTP20, +} grpc_http_version; + +typedef enum { + GRPC_HTTP_RESPONSE, + GRPC_HTTP_REQUEST, +} grpc_http_type; + +/* A request */ +typedef struct grpc_http_request { + /* Method of the request (e.g. GET, POST) */ char* method; - /* The path of the resource to fetch */ + /* The path of the resource to fetch */ char* path; - /* HTTP version to use */ - grpc_http_version version; - /* Headers attached to the request */ - size_t hdr_count; + /* HTTP version to use */ + grpc_http_version version; + /* Headers attached to the request */ + size_t hdr_count; grpc_http_header* hdrs; - /* Body: length and contents; contents are NOT null-terminated */ - size_t body_length; + /* Body: length and contents; contents are NOT null-terminated */ + size_t body_length; char* body; -} grpc_http_request; - -/* A response */ -typedef struct grpc_http_response { - /* HTTP status code */ +} grpc_http_request; + +/* A response */ +typedef struct grpc_http_response { + /* HTTP status code */ int status = 0; - /* Headers: count and key/values */ + /* Headers: count and key/values */ size_t hdr_count = 0; grpc_http_header* hdrs = nullptr; - /* Body: length and contents; contents are NOT null-terminated */ + /* Body: length and contents; contents are NOT null-terminated */ size_t body_length = 0; char* body = nullptr; -} grpc_http_response; - +} grpc_http_response; + struct grpc_http_parser { - grpc_http_parser_state state; - grpc_http_type type; - - union { + grpc_http_parser_state state; + grpc_http_type type; + + union { grpc_http_response* response; grpc_http_request* request; void* request_or_response; - } http; - size_t body_capacity; - size_t hdr_capacity; - - uint8_t cur_line[GRPC_HTTP_PARSER_MAX_HEADER_LENGTH]; - size_t cur_line_length; - size_t cur_line_end_length; + } http; + size_t body_capacity; + size_t hdr_capacity; + + uint8_t cur_line[GRPC_HTTP_PARSER_MAX_HEADER_LENGTH]; + size_t cur_line_length; + size_t cur_line_end_length; }; void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type, void* request_or_response); void grpc_http_parser_destroy(grpc_http_parser* parser); - -/* Sets \a start_of_body to the offset in \a slice of the start of the body. */ + +/* Sets \a start_of_body to the offset in \a slice of the start of the body. */ grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, const grpc_slice& slice, size_t* start_of_body); grpc_error* grpc_http_parser_eof(grpc_http_parser* parser); - + void grpc_http_request_destroy(grpc_http_request* request); void grpc_http_response_destroy(grpc_http_response* response); - + extern grpc_core::TraceFlag grpc_http1_trace; - -#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ + +#endif /* GRPC_CORE_LIB_HTTP_PARSER_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/README.md b/contrib/libs/grpc/src/core/lib/iomgr/README.md index 9b22b76ceb..94c0abfa68 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/README.md +++ b/contrib/libs/grpc/src/core/lib/iomgr/README.md @@ -1,6 +1,6 @@ -# iomgr - -Platform abstractions for I/O (mostly network). - -Provides abstractions over TCP/UDP I/O, file loading, polling, and concurrency -management for various operating systems. +# iomgr + +Platform abstractions for I/O (mostly network). + +Provides abstractions over TCP/UDP I/O, file loading, polling, and concurrency +management for various operating systems. diff --git a/contrib/libs/grpc/src/core/lib/iomgr/closure.h b/contrib/libs/grpc/src/core/lib/iomgr/closure.h index 6bb65340d1..63c608136f 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/closure.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/closure.h @@ -1,26 +1,26 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_CLOSURE_H -#define GRPC_CORE_LIB_IOMGR_CLOSURE_H - -#include <grpc/support/port_platform.h> - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_CLOSURE_H +#define GRPC_CORE_LIB_IOMGR_CLOSURE_H + +#include <grpc/support/port_platform.h> + #include <assert.h> #include <stdbool.h> @@ -30,51 +30,51 @@ #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/mpscq.h" -#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/profiling/timers.h" - -struct grpc_closure; -typedef struct grpc_closure grpc_closure; - + +struct grpc_closure; +typedef struct grpc_closure grpc_closure; + extern grpc_core::DebugOnlyTraceFlag grpc_trace_closure; -typedef struct grpc_closure_list { +typedef struct grpc_closure_list { grpc_closure* head; grpc_closure* tail; -} grpc_closure_list; - -/** gRPC Callback definition. - * - * \param arg Arbitrary input. - * \param error GRPC_ERROR_NONE if no error occurred, otherwise some grpc_error +} grpc_closure_list; + +/** gRPC Callback definition. + * + * \param arg Arbitrary input. + * \param error GRPC_ERROR_NONE if no error occurred, otherwise some grpc_error * describing what went wrong. * Error contract: it is not the cb's job to unref this error; * the closure scheduler will do that after the cb returns */ typedef void (*grpc_iomgr_cb_func)(void* arg, grpc_error* error); - -/** A closure over a grpc_iomgr_cb_func. */ -struct grpc_closure { - /** Once queued, next indicates the next queued closure; before then, scratch - * space */ - union { + +/** A closure over a grpc_iomgr_cb_func. */ +struct grpc_closure { + /** Once queued, next indicates the next queued closure; before then, scratch + * space */ + union { grpc_closure* next; grpc_core::ManualConstructor< grpc_core::MultiProducerSingleConsumerQueue::Node> mpscq_node; - uintptr_t scratch; - } next_data; - - /** Bound callback. */ - grpc_iomgr_cb_func cb; - - /** Arguments to be passed to "cb". */ + uintptr_t scratch; + } next_data; + + /** Bound callback. */ + grpc_iomgr_cb_func cb; + + /** Arguments to be passed to "cb". */ void* cb_arg; - - /** Once queued, the result of the closure. Before then: scratch space */ - union { + + /** Once queued, the result of the closure. Before then: scratch space */ + union { grpc_error* error; - uintptr_t scratch; - } error_data; + uintptr_t scratch; + } error_data; // extra tracing and debugging for grpc_closure. This incurs a decent amount of // overhead per closure, so it must be enabled at compile time. @@ -86,8 +86,8 @@ struct grpc_closure { const char* file_initiated; int line_initiated; #endif -}; - +}; + #ifndef NDEBUG inline grpc_closure* grpc_closure_init(const char* file, int line, grpc_closure* closure, @@ -110,7 +110,7 @@ inline grpc_closure* grpc_closure_init(grpc_closure* closure, return closure; } -/** Initializes \a closure with \a cb and \a cb_arg. Returns \a closure. */ +/** Initializes \a closure with \a cb and \a cb_arg. Returns \a closure. */ #ifndef NDEBUG #define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \ grpc_closure_init(__FILE__, __LINE__, closure, cb, cb_arg) @@ -118,7 +118,7 @@ inline grpc_closure* grpc_closure_init(grpc_closure* closure, #define GRPC_CLOSURE_INIT(closure, cb, cb_arg, scheduler) \ grpc_closure_init(closure, cb, cb_arg) #endif - + namespace closure_impl { struct wrapped_closure { @@ -155,7 +155,7 @@ inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg) { return &wc->wrapper; } -/* Create a heap allocated closure: try to avoid except for very rare events */ +/* Create a heap allocated closure: try to avoid except for very rare events */ #ifndef NDEBUG #define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \ grpc_closure_create(__FILE__, __LINE__, cb, cb_arg) @@ -163,15 +163,15 @@ inline grpc_closure* grpc_closure_create(grpc_iomgr_cb_func cb, void* cb_arg) { #define GRPC_CLOSURE_CREATE(cb, cb_arg, scheduler) \ grpc_closure_create(cb, cb_arg) #endif - -#define GRPC_CLOSURE_LIST_INIT \ + +#define GRPC_CLOSURE_LIST_INIT \ { nullptr, nullptr } - + inline void grpc_closure_list_init(grpc_closure_list* closure_list) { closure_list->head = closure_list->tail = nullptr; } - -/** add \a closure to the end of \a list + +/** add \a closure to the end of \a list and set \a closure's result to \a error Returns true if \a list becomes non-empty */ inline bool grpc_closure_list_append(grpc_closure_list* closure_list, @@ -191,8 +191,8 @@ inline bool grpc_closure_list_append(grpc_closure_list* closure_list, closure_list->tail = closure; return was_empty; } - -/** force all success bits in \a list to false */ + +/** force all success bits in \a list to false */ inline void grpc_closure_list_fail_all(grpc_closure_list* list, grpc_error* forced_failure) { for (grpc_closure* c = list->head; c != nullptr; c = c->next_data.next) { @@ -202,8 +202,8 @@ inline void grpc_closure_list_fail_all(grpc_closure_list* list, } GRPC_ERROR_UNREF(forced_failure); } - -/** append all closures from \a src to \a dst and empty \a src. */ + +/** append all closures from \a src to \a dst and empty \a src. */ inline void grpc_closure_list_move(grpc_closure_list* src, grpc_closure_list* dst) { if (src->head == nullptr) { @@ -217,12 +217,12 @@ inline void grpc_closure_list_move(grpc_closure_list* src, } src->head = src->tail = nullptr; } - -/** return whether \a list is empty. */ + +/** return whether \a list is empty. */ inline bool grpc_closure_list_empty(grpc_closure_list closure_list) { return closure_list.head == nullptr; } - + namespace grpc_core { class Closure { public: @@ -252,4 +252,4 @@ class Closure { }; } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */ +#endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/combiner.h b/contrib/libs/grpc/src/core/lib/iomgr/combiner.h index 32712066be..4879dc1596 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/combiner.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/combiner.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_COMBINER_H -#define GRPC_CORE_LIB_IOMGR_COMBINER_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_COMBINER_H +#define GRPC_CORE_LIB_IOMGR_COMBINER_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include <grpc/support/atm.h> +#include <stddef.h> + +#include <grpc/support/atm.h> #include "src/core/lib/debug/trace.h" -#include "src/core/lib/iomgr/exec_ctx.h" - +#include "src/core/lib/iomgr/exec_ctx.h" + namespace grpc_core { // TODO(yashkt) : Remove this class and replace it with a class that does not // use ExecCtx @@ -53,13 +53,13 @@ class Combiner { }; } // namespace grpc_core -// Provides serialized access to some resource. -// Each action queued on a combiner is executed serially in a borrowed thread. -// The actual thread executing actions may change over time (but there will only +// Provides serialized access to some resource. +// Each action queued on a combiner is executed serially in a borrowed thread. +// The actual thread executing actions may change over time (but there will only // ever be one at a time). - -// Initialize the lock, with an optional workqueue to shift load to when -// necessary + +// Initialize the lock, with an optional workqueue to shift load to when +// necessary grpc_core::Combiner* grpc_combiner_create(void); #ifndef NDEBUG @@ -80,9 +80,9 @@ grpc_core::Combiner* grpc_combiner_create(void); grpc_core::Combiner* grpc_combiner_ref( grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS); void grpc_combiner_unref(grpc_core::Combiner* lock GRPC_COMBINER_DEBUG_ARGS); - + bool grpc_combiner_continue_exec_ctx(); - + extern grpc_core::DebugOnlyTraceFlag grpc_combiner_trace; - -#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h index e704c3be49..ee7c2273b8 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint.h @@ -1,42 +1,42 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_ENDPOINT_H -#define GRPC_CORE_LIB_IOMGR_ENDPOINT_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ENDPOINT_H +#define GRPC_CORE_LIB_IOMGR_ENDPOINT_H + #include <grpc/support/port_platform.h> #include "y_absl/strings/string_view.h" -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> -#include <grpc/support/time.h> -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/iomgr/pollset_set.h" -#include "src/core/lib/iomgr/resource_quota.h" - -/* An endpoint caps a streaming channel between two communicating processes. - Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */ - -typedef struct grpc_endpoint grpc_endpoint; -typedef struct grpc_endpoint_vtable grpc_endpoint_vtable; - -struct grpc_endpoint_vtable { +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> +#include <grpc/support/time.h> +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/pollset_set.h" +#include "src/core/lib/iomgr/resource_quota.h" + +/* An endpoint caps a streaming channel between two communicating processes. + Examples may be: a tcp socket, <stdin+stdout>, or some shared memory. */ + +typedef struct grpc_endpoint grpc_endpoint; +typedef struct grpc_endpoint_vtable grpc_endpoint_vtable; + +struct grpc_endpoint_vtable { void (*read)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb, bool urgent); void (*write)(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb, @@ -51,60 +51,60 @@ struct grpc_endpoint_vtable { y_absl::string_view (*get_local_address)(grpc_endpoint* ep); int (*get_fd)(grpc_endpoint* ep); bool (*can_track_err)(grpc_endpoint* ep); -}; - -/* When data is available on the connection, calls the callback with slices. - Callback success indicates that the endpoint can accept more reads, failure - indicates the endpoint is closed. - Valid slices may be placed into \a slices even when the callback is - invoked with error != GRPC_ERROR_NONE. */ +}; + +/* When data is available on the connection, calls the callback with slices. + Callback success indicates that the endpoint can accept more reads, failure + indicates the endpoint is closed. + Valid slices may be placed into \a slices even when the callback is + invoked with error != GRPC_ERROR_NONE. */ void grpc_endpoint_read(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb, bool urgent); - + y_absl::string_view grpc_endpoint_get_peer(grpc_endpoint* ep); - + y_absl::string_view grpc_endpoint_get_local_address(grpc_endpoint* ep); -/* Get the file descriptor used by \a ep. Return -1 if \a ep is not using an fd. +/* Get the file descriptor used by \a ep. Return -1 if \a ep is not using an fd. */ int grpc_endpoint_get_fd(grpc_endpoint* ep); - -/* Write slices out to the socket. - - If the connection is ready for more data after the end of the call, it - returns GRPC_ENDPOINT_DONE. - Otherwise it returns GRPC_ENDPOINT_PENDING and calls cb when the - connection is ready for more data. - \a slices may be mutated at will by the endpoint until cb is called. - No guarantee is made to the content of slices after a write EXCEPT that - it is a valid slice buffer. + +/* Write slices out to the socket. + + If the connection is ready for more data after the end of the call, it + returns GRPC_ENDPOINT_DONE. + Otherwise it returns GRPC_ENDPOINT_PENDING and calls cb when the + connection is ready for more data. + \a slices may be mutated at will by the endpoint until cb is called. + No guarantee is made to the content of slices after a write EXCEPT that + it is a valid slice buffer. \a arg is platform specific. It is currently only used by TCP on linux platforms as an argument that would be forwarded to the timestamps callback. - */ + */ void grpc_endpoint_write(grpc_endpoint* ep, grpc_slice_buffer* slices, grpc_closure* cb, void* arg); - -/* Causes any pending and future read/write callbacks to run immediately with - success==0 */ + +/* Causes any pending and future read/write callbacks to run immediately with + success==0 */ void grpc_endpoint_shutdown(grpc_endpoint* ep, grpc_error* why); void grpc_endpoint_destroy(grpc_endpoint* ep); - + /* Add an endpoint to a pollset or pollset_set, so that when the pollset is polled, events from this endpoint are considered */ void grpc_endpoint_add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset); void grpc_endpoint_add_to_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset_set); - + /* Delete an endpoint from a pollset_set */ void grpc_endpoint_delete_from_pollset_set(grpc_endpoint* ep, grpc_pollset_set* pollset_set); - + grpc_resource_user* grpc_endpoint_get_resource_user(grpc_endpoint* endpoint); bool grpc_endpoint_can_track_err(grpc_endpoint* ep); -struct grpc_endpoint { +struct grpc_endpoint { const grpc_endpoint_vtable* vtable; -}; - -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ +}; + +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair.h b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair.h index e01185b9fb..87cbccd25d 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/endpoint_pair.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 GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H -#define GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H +#define GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/endpoint.h" - +#include "src/core/lib/iomgr/endpoint.h" + struct grpc_endpoint_pair { grpc_endpoint* client; grpc_endpoint* server; }; grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char* name, grpc_channel_args* args); - -#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_ENDPOINT_PAIR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/error.h b/contrib/libs/grpc/src/core/lib/iomgr/error.h index ac3ff87628..3b4cb51be4 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/error.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/error.h @@ -1,104 +1,104 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_ERROR_H -#define GRPC_CORE_LIB_IOMGR_ERROR_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_ERROR_H +#define GRPC_CORE_LIB_IOMGR_ERROR_H + #include <grpc/support/port_platform.h> #include <inttypes.h> -#include <stdbool.h> - +#include <stdbool.h> + #include <grpc/slice.h> -#include <grpc/status.h> +#include <grpc/status.h> #include <grpc/support/log.h> -#include <grpc/support/time.h> - +#include <grpc/support/time.h> + #include "src/core/lib/debug/trace.h" - -/// Opaque representation of an error. + +/// Opaque representation of an error. /// See https://github.com/grpc/grpc/blob/master/doc/core/grpc-error.md for a /// full write up of this object. -typedef struct grpc_error grpc_error; - +typedef struct grpc_error grpc_error; + extern grpc_core::DebugOnlyTraceFlag grpc_trace_error_refcount; -typedef enum { - /// 'errno' from the operating system - GRPC_ERROR_INT_ERRNO, - /// __LINE__ from the call site creating the error - GRPC_ERROR_INT_FILE_LINE, - /// stream identifier: for errors that are associated with an individual - /// wire stream - GRPC_ERROR_INT_STREAM_ID, - /// grpc status code representing this error - GRPC_ERROR_INT_GRPC_STATUS, - /// offset into some binary blob (usually represented by - /// GRPC_ERROR_STR_RAW_BYTES) where the error occurred - GRPC_ERROR_INT_OFFSET, - /// context sensitive index associated with the error - GRPC_ERROR_INT_INDEX, - /// context sensitive size associated with the error - GRPC_ERROR_INT_SIZE, - /// http2 error code associated with the error (see the HTTP2 RFC) - GRPC_ERROR_INT_HTTP2_ERROR, - /// TSI status code associated with the error - GRPC_ERROR_INT_TSI_CODE, - /// grpc_security_status associated with the error - GRPC_ERROR_INT_SECURITY_STATUS, - /// WSAGetLastError() reported when this error occurred - GRPC_ERROR_INT_WSA_ERROR, - /// File descriptor associated with this error - GRPC_ERROR_INT_FD, - /// HTTP status (i.e. 404) - GRPC_ERROR_INT_HTTP_STATUS, - /// context sensitive limit associated with the error - GRPC_ERROR_INT_LIMIT, - /// chttp2: did the error occur while a write was in progress - GRPC_ERROR_INT_OCCURRED_DURING_WRITE, +typedef enum { + /// 'errno' from the operating system + GRPC_ERROR_INT_ERRNO, + /// __LINE__ from the call site creating the error + GRPC_ERROR_INT_FILE_LINE, + /// stream identifier: for errors that are associated with an individual + /// wire stream + GRPC_ERROR_INT_STREAM_ID, + /// grpc status code representing this error + GRPC_ERROR_INT_GRPC_STATUS, + /// offset into some binary blob (usually represented by + /// GRPC_ERROR_STR_RAW_BYTES) where the error occurred + GRPC_ERROR_INT_OFFSET, + /// context sensitive index associated with the error + GRPC_ERROR_INT_INDEX, + /// context sensitive size associated with the error + GRPC_ERROR_INT_SIZE, + /// http2 error code associated with the error (see the HTTP2 RFC) + GRPC_ERROR_INT_HTTP2_ERROR, + /// TSI status code associated with the error + GRPC_ERROR_INT_TSI_CODE, + /// grpc_security_status associated with the error + GRPC_ERROR_INT_SECURITY_STATUS, + /// WSAGetLastError() reported when this error occurred + GRPC_ERROR_INT_WSA_ERROR, + /// File descriptor associated with this error + GRPC_ERROR_INT_FD, + /// HTTP status (i.e. 404) + GRPC_ERROR_INT_HTTP_STATUS, + /// context sensitive limit associated with the error + GRPC_ERROR_INT_LIMIT, + /// chttp2: did the error occur while a write was in progress + GRPC_ERROR_INT_OCCURRED_DURING_WRITE, /// channel connectivity state associated with the error GRPC_ERROR_INT_CHANNEL_CONNECTIVITY_STATE, /// Must always be last GRPC_ERROR_INT_MAX, -} grpc_error_ints; - -typedef enum { - /// top-level textual description of this error - GRPC_ERROR_STR_DESCRIPTION, - /// source file in which this error occurred - GRPC_ERROR_STR_FILE, - /// operating system description of this error - GRPC_ERROR_STR_OS_ERROR, - /// syscall that generated this error - GRPC_ERROR_STR_SYSCALL, - /// peer that we were trying to communicate when this error occurred - GRPC_ERROR_STR_TARGET_ADDRESS, - /// grpc status message associated with this error - GRPC_ERROR_STR_GRPC_MESSAGE, - /// hex dump (or similar) with the data that generated this error - GRPC_ERROR_STR_RAW_BYTES, - /// tsi error string associated with this error - GRPC_ERROR_STR_TSI_ERROR, - /// filename that we were trying to read/write when this error occurred - GRPC_ERROR_STR_FILENAME, - /// which data was queued for writing when the error occurred +} grpc_error_ints; + +typedef enum { + /// top-level textual description of this error + GRPC_ERROR_STR_DESCRIPTION, + /// source file in which this error occurred + GRPC_ERROR_STR_FILE, + /// operating system description of this error + GRPC_ERROR_STR_OS_ERROR, + /// syscall that generated this error + GRPC_ERROR_STR_SYSCALL, + /// peer that we were trying to communicate when this error occurred + GRPC_ERROR_STR_TARGET_ADDRESS, + /// grpc status message associated with this error + GRPC_ERROR_STR_GRPC_MESSAGE, + /// hex dump (or similar) with the data that generated this error + GRPC_ERROR_STR_RAW_BYTES, + /// tsi error string associated with this error + GRPC_ERROR_STR_TSI_ERROR, + /// filename that we were trying to read/write when this error occurred + GRPC_ERROR_STR_FILENAME, + /// which data was queued for writing when the error occurred GRPC_ERROR_STR_QUEUED_BUFFERS, /// key associated with the error GRPC_ERROR_STR_KEY, @@ -107,27 +107,27 @@ typedef enum { /// Must always be last GRPC_ERROR_STR_MAX, -} grpc_error_strs; - -typedef enum { - /// timestamp of error creation - GRPC_ERROR_TIME_CREATED, +} grpc_error_strs; + +typedef enum { + /// timestamp of error creation + GRPC_ERROR_TIME_CREATED, /// Must always be last GRPC_ERROR_TIME_MAX, -} grpc_error_times; - -/// The following "special" errors can be propagated without allocating memory. +} grpc_error_times; + +/// The following "special" errors can be propagated without allocating memory. /// They are always even so that other code (particularly combiner locks, /// polling engines) can safely use the lower bit for themselves. - + #define GRPC_ERROR_NONE ((grpc_error*)NULL) #define GRPC_ERROR_RESERVED_1 ((grpc_error*)1) #define GRPC_ERROR_OOM ((grpc_error*)2) #define GRPC_ERROR_RESERVED_2 ((grpc_error*)3) #define GRPC_ERROR_CANCELLED ((grpc_error*)4) #define GRPC_ERROR_SPECIAL_MAX GRPC_ERROR_CANCELLED - + inline bool grpc_error_is_special(struct grpc_error* err) { return err <= GRPC_ERROR_SPECIAL_MAX; } @@ -138,35 +138,35 @@ void grpc_disable_error_creation(); void grpc_enable_error_creation(); const char* grpc_error_string(grpc_error* error); - -/// Create an error - but use GRPC_ERROR_CREATE instead + +/// Create an error - but use GRPC_ERROR_CREATE instead grpc_error* grpc_error_create(const char* file, int line, const grpc_slice& desc, grpc_error** referencing, size_t num_referencing); -/// Create an error (this is the preferred way of generating an error that is -/// not due to a system call - for system calls, use GRPC_OS_ERROR or -/// GRPC_WSA_ERROR as appropriate) -/// \a referencing is an array of num_referencing elements indicating one or -/// more errors that are believed to have contributed to this one -/// err = grpc_error_create(x, y, z, r, nr) is equivalent to: -/// err = grpc_error_create(x, y, z, NULL, 0); -/// for (i=0; i<nr; i++) err = grpc_error_add_child(err, r[i]); +/// Create an error (this is the preferred way of generating an error that is +/// not due to a system call - for system calls, use GRPC_OS_ERROR or +/// GRPC_WSA_ERROR as appropriate) +/// \a referencing is an array of num_referencing elements indicating one or +/// more errors that are believed to have contributed to this one +/// err = grpc_error_create(x, y, z, r, nr) is equivalent to: +/// err = grpc_error_create(x, y, z, NULL, 0); +/// for (i=0; i<nr; i++) err = grpc_error_add_child(err, r[i]); #define GRPC_ERROR_CREATE_FROM_STATIC_STRING(desc) \ grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \ NULL, 0) #define GRPC_ERROR_CREATE_FROM_COPIED_STRING(desc) \ grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \ NULL, 0) - -// Create an error that references some other errors. This function adds a -// reference to each error in errs - it does not consume an existing reference + +// Create an error that references some other errors. This function adds a +// reference to each error in errs - it does not consume an existing reference #define GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(desc, errs, count) \ grpc_error_create(__FILE__, __LINE__, grpc_slice_from_static_string(desc), \ errs, count) #define GRPC_ERROR_CREATE_REFERENCING_FROM_COPIED_STRING(desc, errs, count) \ grpc_error_create(__FILE__, __LINE__, grpc_slice_from_copied_string(desc), \ errs, count) - + #define GRPC_ERROR_CREATE_FROM_VECTOR(desc, error_list) \ grpc_error_create_from_vector(__FILE__, __LINE__, desc, error_list) @@ -183,7 +183,7 @@ inline void grpc_error_unref(grpc_error* err, const char* file, int line) { } #define GRPC_ERROR_REF(err) grpc_error_ref(err, __FILE__, __LINE__) #define GRPC_ERROR_UNREF(err) grpc_error_unref(err, __FILE__, __LINE__) -#else +#else grpc_error* grpc_error_do_ref(grpc_error* err); void grpc_error_do_unref(grpc_error* err); inline grpc_error* grpc_error_ref(grpc_error* err) { @@ -194,10 +194,10 @@ inline void grpc_error_unref(grpc_error* err) { if (grpc_error_is_special(err)) return; grpc_error_do_unref(err); } -#define GRPC_ERROR_REF(err) grpc_error_ref(err) -#define GRPC_ERROR_UNREF(err) grpc_error_unref(err) -#endif - +#define GRPC_ERROR_REF(err) grpc_error_ref(err) +#define GRPC_ERROR_UNREF(err) grpc_error_unref(err) +#endif + // Consumes all the errors in the vector and forms a referencing error from // them. If the vector is empty, return GRPC_ERROR_NONE. template <typename VectorType> @@ -218,7 +218,7 @@ static grpc_error* grpc_error_create_from_vector(const char* file, int line, } grpc_error* grpc_error_set_int(grpc_error* src, grpc_error_ints which, - intptr_t value) GRPC_MUST_USE_RESULT; + intptr_t value) GRPC_MUST_USE_RESULT; /// It is an error to pass nullptr as `p`. Caller should allocate a dummy /// intptr_t for `p`, even if the value of `p` is not used. bool grpc_error_get_int(grpc_error* error, grpc_error_ints which, intptr_t* p); @@ -230,9 +230,9 @@ grpc_error* grpc_error_set_str(grpc_error* src, grpc_error_strs which, /// Caller does NOT own the slice. bool grpc_error_get_str(grpc_error* error, grpc_error_strs which, grpc_slice* s); - -/// Add a child error: an error that is believed to have contributed to this -/// error occurring. Allows root causing high level errors from lower level + +/// Add a child error: an error that is believed to have contributed to this +/// error occurring. Allows root causing high level errors from lower level /// errors that contributed to them. The src error takes ownership of the /// child error. /// @@ -253,15 +253,15 @@ inline grpc_error* grpc_assert_never_ok(grpc_error* error) { return error; } -/// create an error associated with errno!=0 (an 'operating system' error) -#define GRPC_OS_ERROR(err, call_name) \ +/// create an error associated with errno!=0 (an 'operating system' error) +#define GRPC_OS_ERROR(err, call_name) \ grpc_assert_never_ok(grpc_os_error(__FILE__, __LINE__, err, call_name)) grpc_error* grpc_wsa_error(const char* file, int line, int err, const char* call_name) GRPC_MUST_USE_RESULT; -/// windows only: create an error associated with WSAGetLastError()!=0 -#define GRPC_WSA_ERROR(err, call_name) \ - grpc_wsa_error(__FILE__, __LINE__, err, call_name) - +/// windows only: create an error associated with WSAGetLastError()!=0 +#define GRPC_WSA_ERROR(err, call_name) \ + grpc_wsa_error(__FILE__, __LINE__, err, call_name) + bool grpc_log_error(const char* what, grpc_error* error, const char* file, int line); inline bool grpc_log_if_error(const char* what, grpc_error* error, @@ -270,7 +270,7 @@ inline bool grpc_log_if_error(const char* what, grpc_error* error, : grpc_log_error(what, error, file, line); } -#define GRPC_LOG_IF_ERROR(what, error) \ +#define GRPC_LOG_IF_ERROR(what, error) \ (grpc_log_if_error((what), (error), __FILE__, __LINE__)) - -#endif /* GRPC_CORE_LIB_IOMGR_ERROR_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_ERROR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.h index ab3cd9029e..a700ba2430 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_poll_posix.h @@ -1,29 +1,29 @@ -/* - * +/* + * * Copyright 2015-2016 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 GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H -#define GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H +#define GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/ev_posix.h" - +#include "src/core/lib/iomgr/ev_posix.h" + const grpc_event_engine_vtable* grpc_init_poll_posix(bool explicit_request); const grpc_event_engine_vtable* grpc_init_poll_cv_posix(bool explicit_request); - -#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_EV_POLL_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/ev_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/ev_posix.h index 84edabce71..cad12361f1 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/ev_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/ev_posix.h @@ -1,35 +1,35 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_EV_POSIX_H -#define GRPC_CORE_LIB_IOMGR_EV_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_EV_POSIX_H +#define GRPC_CORE_LIB_IOMGR_EV_POSIX_H + #include <grpc/support/port_platform.h> -#include <poll.h> - +#include <poll.h> + #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/global_config.h" -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/iomgr/pollset_set.h" -#include "src/core/lib/iomgr/wakeup_fd_posix.h" - +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/pollset_set.h" +#include "src/core/lib/iomgr/wakeup_fd_posix.h" + GPR_GLOBAL_CONFIG_DECLARE_STRING(grpc_poll_strategy); extern grpc_core::DebugOnlyTraceFlag grpc_fd_trace; /* Disabled by default */ @@ -41,13 +41,13 @@ extern grpc_core::DebugOnlyTraceFlag gpr_log(GPR_INFO, "(fd-trace) " format, __VA_ARGS__); \ } -typedef struct grpc_fd grpc_fd; - -typedef struct grpc_event_engine_vtable { - size_t pollset_size; +typedef struct grpc_fd grpc_fd; + +typedef struct grpc_event_engine_vtable { + size_t pollset_size; bool can_track_err; bool run_in_background; - + grpc_fd* (*fd_create)(int fd, const char* name, bool track_err); int (*fd_wrapped_fd)(grpc_fd* fd); void (*fd_orphan)(grpc_fd* fd, grpc_closure* on_done, int* release_fd, @@ -60,7 +60,7 @@ typedef struct grpc_event_engine_vtable { void (*fd_set_writable)(grpc_fd* fd); void (*fd_set_error)(grpc_fd* fd); bool (*fd_is_shutdown)(grpc_fd* fd); - + void (*pollset_init)(grpc_pollset* pollset, gpr_mu** mu); void (*pollset_shutdown)(grpc_pollset* pollset, grpc_closure* closure); void (*pollset_destroy)(grpc_pollset* pollset); @@ -70,7 +70,7 @@ typedef struct grpc_event_engine_vtable { grpc_error* (*pollset_kick)(grpc_pollset* pollset, grpc_pollset_worker* specific_worker); void (*pollset_add_fd)(grpc_pollset* pollset, struct grpc_fd* fd); - + grpc_pollset_set* (*pollset_set_create)(void); void (*pollset_set_destroy)(grpc_pollset_set* pollset_set); void (*pollset_set_add_pollset)(grpc_pollset_set* pollset_set, @@ -83,25 +83,25 @@ typedef struct grpc_event_engine_vtable { grpc_pollset_set* item); void (*pollset_set_add_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd); void (*pollset_set_del_fd)(grpc_pollset_set* pollset_set, grpc_fd* fd); - + bool (*is_any_background_poller_thread)(void); void (*shutdown_background_closure)(void); - void (*shutdown_engine)(void); + void (*shutdown_engine)(void); bool (*add_closure_to_background_poller)(grpc_closure* closure, grpc_error* error); -} grpc_event_engine_vtable; - +} grpc_event_engine_vtable; + /* register a new event engine factory */ void grpc_register_event_engine_factory( const char* name, const grpc_event_engine_vtable* (*factory)(bool), bool add_at_head); -void grpc_event_engine_init(void); -void grpc_event_engine_shutdown(void); - -/* Return the name of the poll strategy */ +void grpc_event_engine_init(void); +void grpc_event_engine_shutdown(void); + +/* Return the name of the poll strategy */ const char* grpc_get_poll_strategy_name(); - + /* Returns true if polling engine can track errors separately, false otherwise. * If this is true, fd can be created with track_err set. After this, error * events will be reported using fd_notify_on_error. If it is not set, errors @@ -115,54 +115,54 @@ bool grpc_event_engine_can_track_errors(); */ bool grpc_event_engine_run_in_background(); -/* Create a wrapped file descriptor. - Requires fd is a non-blocking file descriptor. +/* Create a wrapped file descriptor. + Requires fd is a non-blocking file descriptor. \a track_err if true means that error events would be tracked separately using grpc_fd_notify_on_error. Currently, valid only for linux systems. - This takes ownership of closing fd. */ + This takes ownership of closing fd. */ grpc_fd* grpc_fd_create(int fd, const char* name, bool track_err); - -/* Return the wrapped fd, or -1 if it has been released or closed. */ + +/* Return the wrapped fd, or -1 if it has been released or closed. */ int grpc_fd_wrapped_fd(grpc_fd* fd); - -/* Releases fd to be asynchronously destroyed. - on_done is called when the underlying file descriptor is definitely close()d. - If on_done is NULL, no callback will be made. - If release_fd is not NULL, it's set to fd and fd will not be closed. - Requires: *fd initialized; no outstanding notify_on_read or - notify_on_write. - MUST NOT be called with a pollset lock taken */ + +/* Releases fd to be asynchronously destroyed. + on_done is called when the underlying file descriptor is definitely close()d. + If on_done is NULL, no callback will be made. + If release_fd is not NULL, it's set to fd and fd will not be closed. + Requires: *fd initialized; no outstanding notify_on_read or + notify_on_write. + MUST NOT be called with a pollset lock taken */ void grpc_fd_orphan(grpc_fd* fd, grpc_closure* on_done, int* release_fd, const char* reason); - -/* Has grpc_fd_shutdown been called on an fd? */ + +/* Has grpc_fd_shutdown been called on an fd? */ bool grpc_fd_is_shutdown(grpc_fd* fd); - -/* Cause any current and future callbacks to fail. */ + +/* Cause any current and future callbacks to fail. */ void grpc_fd_shutdown(grpc_fd* fd, grpc_error* why); - -/* Register read interest, causing read_cb to be called once when fd becomes - readable, on deadline specified by deadline, or on shutdown triggered by - grpc_fd_shutdown. - read_cb will be called with read_cb_arg when *fd becomes readable. - read_cb is Called with status of GRPC_CALLBACK_SUCCESS if readable, - GRPC_CALLBACK_TIMED_OUT if the call timed out, - and CANCELLED if the call was cancelled. - - Requires:This method must not be called before the read_cb for any previous - call runs. Edge triggered events are used whenever they are supported by the - underlying platform. This means that users must drain fd in read_cb before - calling notify_on_read again. Users are also expected to handle spurious - events, i.e read_cb is called while nothing can be readable from fd */ + +/* Register read interest, causing read_cb to be called once when fd becomes + readable, on deadline specified by deadline, or on shutdown triggered by + grpc_fd_shutdown. + read_cb will be called with read_cb_arg when *fd becomes readable. + read_cb is Called with status of GRPC_CALLBACK_SUCCESS if readable, + GRPC_CALLBACK_TIMED_OUT if the call timed out, + and CANCELLED if the call was cancelled. + + Requires:This method must not be called before the read_cb for any previous + call runs. Edge triggered events are used whenever they are supported by the + underlying platform. This means that users must drain fd in read_cb before + calling notify_on_read again. Users are also expected to handle spurious + events, i.e read_cb is called while nothing can be readable from fd */ void grpc_fd_notify_on_read(grpc_fd* fd, grpc_closure* closure); - -/* Exactly the same semantics as above, except based on writable events. */ + +/* Exactly the same semantics as above, except based on writable events. */ void grpc_fd_notify_on_write(grpc_fd* fd, grpc_closure* closure); - + /* Exactly the same semantics as above, except based on error events. track_err * needs to have been set on grpc_fd_create */ void grpc_fd_notify_on_error(grpc_fd* fd, grpc_closure* closure); - + /* Forcibly set the fd to be readable, resulting in the closure registered with * grpc_fd_notify_on_read being invoked. */ @@ -178,16 +178,16 @@ void grpc_fd_set_writable(grpc_fd* fd); */ void grpc_fd_set_error(grpc_fd* fd); -/* pollset_posix functions */ - -/* Add an fd to a pollset */ +/* pollset_posix functions */ + +/* Add an fd to a pollset */ void grpc_pollset_add_fd(grpc_pollset* pollset, struct grpc_fd* fd); - -/* pollset_set_posix functions */ - + +/* pollset_set_posix functions */ + void grpc_pollset_set_add_fd(grpc_pollset_set* pollset_set, grpc_fd* fd); void grpc_pollset_set_del_fd(grpc_pollset_set* pollset_set, grpc_fd* fd); - + /* Returns true if the caller is a worker thread for any background poller. */ bool grpc_is_any_background_poller_thread(); @@ -200,8 +200,8 @@ bool grpc_add_closure_to_background_poller(grpc_closure* closure, /* Shut down all the closures registered in the background poller. */ void grpc_shutdown_background_closure(); -/* override to allow tests to hook poll() usage */ +/* override to allow tests to hook poll() usage */ typedef int (*grpc_poll_function_type)(struct pollfd*, nfds_t, int); -extern grpc_poll_function_type grpc_poll_function; - -#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ +extern grpc_poll_function_type grpc_poll_function; + +#endif /* GRPC_CORE_LIB_IOMGR_EV_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h b/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h index 6b4e184cad..827ec010bf 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/exec_ctx.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 GRPC_CORE_LIB_IOMGR_EXEC_CTX_H -#define GRPC_CORE_LIB_IOMGR_EXEC_CTX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_EXEC_CTX_H +#define GRPC_CORE_LIB_IOMGR_EXEC_CTX_H + #include <grpc/support/port_platform.h> #include <limits> @@ -32,17 +32,17 @@ #include "src/core/lib/gpr/tls.h" #include "src/core/lib/gprpp/debug_location.h" #include "src/core/lib/gprpp/fork.h" -#include "src/core/lib/iomgr/closure.h" - +#include "src/core/lib/iomgr/closure.h" + typedef int64_t grpc_millis; - + #define GRPC_MILLIS_INF_FUTURE INT64_MAX #define GRPC_MILLIS_INF_PAST INT64_MIN /** A combiner represents a list of work to be executed later. Forward declared here to avoid a circular dependency with combiner.h. */ -typedef struct grpc_combiner grpc_combiner; - +typedef struct grpc_combiner grpc_combiner; + /* This exec_ctx is ready to return: either pre-populated, or cached as soon as the finish_check returns true */ #define GRPC_EXEC_CTX_FLAG_IS_FINISHED 1 @@ -65,11 +65,11 @@ grpc_millis grpc_cycle_counter_to_millis_round_up(gpr_cycle_counter cycles); namespace grpc_core { class Combiner; -/** Execution context. - * A bag of data that collects information along a callstack. +/** Execution context. + * A bag of data that collects information along a callstack. * It is created on the stack at core entry points (public API or iomgr), and * stored internally as a thread-local variable. - * + * * Generally, to create an exec_ctx instance, add the following line at the top * of the public API entry point or at the start of a thread's work function : * @@ -78,17 +78,17 @@ class Combiner; * Access the created ExecCtx instance using : * grpc_core::ExecCtx::Get() * - * Specific responsibilities (this may grow in the future): + * Specific responsibilities (this may grow in the future): * - track a list of core work that needs to be delayed until the base of the - * call stack (this provides a convenient mechanism to run callbacks - * without worrying about locking issues) + * call stack (this provides a convenient mechanism to run callbacks + * without worrying about locking issues) * - provide a decision maker (via IsReadyToFinish) that provides a - * signal as to whether a borrowed thread should continue to do work or - * should actively try to finish up and get this thread back to its owner - * - * CONVENTIONS: - * - Instance of this must ALWAYS be constructed on the stack, never - * heap allocated. + * signal as to whether a borrowed thread should continue to do work or + * should actively try to finish up and get this thread back to its owner + * + * CONVENTIONS: + * - Instance of this must ALWAYS be constructed on the stack, never + * heap allocated. * - Do not pass exec_ctx as a parameter to a function. Always access it using * grpc_core::ExecCtx::Get(). * - NOTE: In the future, the convention is likely to change to allow only one @@ -102,16 +102,16 @@ class Combiner; * Stage 2: Assert if a 2nd one is ever created on the stack * since that implies a core re-entry outside of application * callbacks. - */ + */ class ExecCtx { public: /** Default Constructor */ - + ExecCtx() : flags_(GRPC_EXEC_CTX_FLAG_IS_FINISHED) { grpc_core::Fork::IncExecCtxCount(); Set(this); } - + /** Parameterised Constructor */ ExecCtx(uintptr_t fl) : flags_(fl) { if (!(GRPC_EXEC_CTX_FLAG_IS_INTERNAL_THREAD & flags_)) { @@ -119,7 +119,7 @@ class ExecCtx { } Set(this); } - + /** Destructor */ virtual ~ExecCtx() { flags_ |= GRPC_EXEC_CTX_FLAG_IS_FINISHED; @@ -129,25 +129,25 @@ class ExecCtx { grpc_core::Fork::DecExecCtxCount(); } } - + /** Disallow copy and assignment operators */ ExecCtx(const ExecCtx&) = delete; ExecCtx& operator=(const ExecCtx&) = delete; - + unsigned starting_cpu() { if (starting_cpu_ == std::numeric_limits<unsigned>::max()) { starting_cpu_ = gpr_cpu_current_cpu(); } return starting_cpu_; } - + struct CombinerData { /* currently active combiner: updated only via combiner.c */ Combiner* active_combiner; /* last active combiner in the active combiner list */ Combiner* last_combiner; }; - + /** Only to be used by grpc-combiner code */ CombinerData* combiner_data() { return &combiner_data_; } @@ -379,4 +379,4 @@ class ApplicationCallbackExecCtx { }; } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXEC_CTX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/executor.h b/contrib/libs/grpc/src/core/lib/iomgr/executor.h index ae523ff212..21a7cd2b55 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/executor.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/executor.h @@ -1,30 +1,30 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_EXECUTOR_H -#define GRPC_CORE_LIB_IOMGR_EXECUTOR_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_EXECUTOR_H +#define GRPC_CORE_LIB_IOMGR_EXECUTOR_H + #include <grpc/support/port_platform.h> #include "src/core/lib/gpr/spinlock.h" #include "src/core/lib/gprpp/thd.h" -#include "src/core/lib/iomgr/closure.h" - +#include "src/core/lib/iomgr/closure.h" + namespace grpc_core { struct ThreadState { @@ -38,14 +38,14 @@ struct ThreadState { bool queued_long_job; grpc_core::Thread thd; }; - + enum class ExecutorType { DEFAULT = 0, RESOLVER, - + NUM_EXECUTORS // Add new values above this }; - + enum class ExecutorJobType { SHORT = 0, LONG, @@ -122,4 +122,4 @@ void grpc_executor_global_init(); } // namespace grpc_core -#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ +#endif /* GRPC_CORE_LIB_IOMGR_EXECUTOR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/iocp_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/iocp_windows.h index 68d9de6158..980bff7ca5 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/iocp_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/iocp_windows.h @@ -1,48 +1,48 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H + #include <grpc/support/port_platform.h> -#include <grpc/support/sync.h> - +#include <grpc/support/sync.h> + #include "src/core/lib/iomgr/port.h" #ifdef GRPC_WINSOCK_SOCKET #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/socket_windows.h" - -typedef enum { - GRPC_IOCP_WORK_WORK, - GRPC_IOCP_WORK_TIMEOUT, - GRPC_IOCP_WORK_KICK -} grpc_iocp_work_status; - +#include "src/core/lib/iomgr/socket_windows.h" + +typedef enum { + GRPC_IOCP_WORK_WORK, + GRPC_IOCP_WORK_TIMEOUT, + GRPC_IOCP_WORK_KICK +} grpc_iocp_work_status; + grpc_iocp_work_status grpc_iocp_work(grpc_millis deadline); -void grpc_iocp_init(void); -void grpc_iocp_kick(void); -void grpc_iocp_flush(void); -void grpc_iocp_shutdown(void); +void grpc_iocp_init(void); +void grpc_iocp_kick(void); +void grpc_iocp_flush(void); +void grpc_iocp_shutdown(void); void grpc_iocp_add_socket(grpc_winsocket*); - + #endif -#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_IOCP_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/iomgr.h b/contrib/libs/grpc/src/core/lib/iomgr/iomgr.h index e02f15e551..83a70d454b 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/iomgr.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/iomgr.h @@ -1,41 +1,41 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_IOMGR_H -#define GRPC_CORE_LIB_IOMGR_IOMGR_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_IOMGR_H +#define GRPC_CORE_LIB_IOMGR_IOMGR_H + #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/port.h" - +#include "src/core/lib/iomgr/port.h" + #include <stdlib.h> -/** Initializes the iomgr. */ +/** Initializes the iomgr. */ void grpc_iomgr_init(); - + /** Starts any background threads for iomgr. */ void grpc_iomgr_start(); -/** Signals the intention to shutdown the iomgr. Expects to be able to flush - * exec_ctx. */ +/** Signals the intention to shutdown the iomgr. Expects to be able to flush + * exec_ctx. */ void grpc_iomgr_shutdown(); - + /** Signals the intention to shutdown all the closures registered in the * background poller. */ void grpc_iomgr_shutdown_background_closure(); @@ -57,4 +57,4 @@ bool grpc_iomgr_add_closure_to_background_poller(grpc_closure* closure, /* Exposed only for testing */ size_t grpc_iomgr_count_objects_for_testing(); -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_internal.h b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_internal.h index 17607f98f1..d31831b847 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_internal.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_internal.h @@ -1,36 +1,36 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H -#define GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H +#define GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H + #include <grpc/support/port_platform.h> -#include <stdbool.h> - -#include "src/core/lib/iomgr/iomgr.h" - -typedef struct grpc_iomgr_object { +#include <stdbool.h> + +#include "src/core/lib/iomgr/iomgr.h" + +typedef struct grpc_iomgr_object { char* name; struct grpc_iomgr_object* next; struct grpc_iomgr_object* prev; -} grpc_iomgr_object; - +} grpc_iomgr_object; + typedef struct grpc_iomgr_platform_vtable { void (*init)(void); void (*flush)(void); @@ -40,7 +40,7 @@ typedef struct grpc_iomgr_platform_vtable { bool (*add_closure_to_background_poller)(grpc_closure* closure, grpc_error* error); } grpc_iomgr_platform_vtable; - + void grpc_iomgr_register_object(grpc_iomgr_object* obj, const char* name); void grpc_iomgr_unregister_object(grpc_iomgr_object* obj); @@ -50,12 +50,12 @@ void grpc_set_iomgr_platform_vtable(grpc_iomgr_platform_vtable* vtable); void grpc_set_default_iomgr_platform(); -void grpc_iomgr_platform_init(void); -/** flush any globally queued work from iomgr */ -void grpc_iomgr_platform_flush(void); -/** tear down all platform specific global iomgr structures */ -void grpc_iomgr_platform_shutdown(void); - +void grpc_iomgr_platform_init(void); +/** flush any globally queued work from iomgr */ +void grpc_iomgr_platform_flush(void); +/** tear down all platform specific global iomgr structures */ +void grpc_iomgr_platform_shutdown(void); + /** shut down all the closures registered in the background poller */ void grpc_iomgr_platform_shutdown_background_closure(void); @@ -68,6 +68,6 @@ bool grpc_iomgr_platform_is_any_background_poller_thread(void); bool grpc_iomgr_platform_add_closure_to_background_poller(grpc_closure* closure, grpc_error* error); -bool grpc_iomgr_abort_on_leaks(void); - -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ +bool grpc_iomgr_abort_on_leaks(void); + +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_INTERNAL_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix.h index 54ec46e1bb..ab8bdca649 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/iomgr_posix.h @@ -1,26 +1,26 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H -#define GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H +#define GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/iomgr_internal.h" - -#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H */ +#include "src/core/lib/iomgr/iomgr_internal.h" + +#endif /* GRPC_CORE_LIB_IOMGR_IOMGR_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/load_file.h b/contrib/libs/grpc/src/core/lib/iomgr/load_file.h index 1cb2b5de73..a9e7531816 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/load_file.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/load_file.h @@ -1,35 +1,35 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_LOAD_FILE_H -#define GRPC_CORE_LIB_IOMGR_LOAD_FILE_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_LOAD_FILE_H +#define GRPC_CORE_LIB_IOMGR_LOAD_FILE_H + #include <grpc/support/port_platform.h> -#include <stdio.h> - -#include <grpc/slice.h> - -#include "src/core/lib/iomgr/error.h" - -/* Loads the content of a file into a slice. add_null_terminator will add - a NULL terminator if non-zero. */ +#include <stdio.h> + +#include <grpc/slice.h> + +#include "src/core/lib/iomgr/error.h" + +/* Loads the content of a file into a slice. add_null_terminator will add + a NULL terminator if non-zero. */ grpc_error* grpc_load_file(const char* filename, int add_null_terminator, grpc_slice* slice); - -#endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_LOAD_FILE_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/polling_entity.h b/contrib/libs/grpc/src/core/lib/iomgr/polling_entity.h index 6f4c5bdd66..bfeba8f045 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/polling_entity.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/polling_entity.h @@ -1,68 +1,68 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H -#define GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H +#define GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/iomgr/pollset_set.h" - +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/pollset_set.h" + typedef enum grpc_pollset_tag { GRPC_POLLS_NONE, GRPC_POLLS_POLLSET, GRPC_POLLS_POLLSET_SET } grpc_pollset_tag; -/* A grpc_polling_entity is a pollset-or-pollset_set container. It allows +/* A grpc_polling_entity is a pollset-or-pollset_set container. It allows * functions that accept a pollset XOR a pollset_set to do so through an * abstract interface. No ownership is taken. */ - + struct grpc_polling_entity { - union { + union { grpc_pollset* pollset = nullptr; grpc_pollset_set* pollset_set; - } pollent; + } pollent; grpc_pollset_tag tag = GRPC_POLLS_NONE; }; - -grpc_polling_entity grpc_polling_entity_create_from_pollset_set( + +grpc_polling_entity grpc_polling_entity_create_from_pollset_set( grpc_pollset_set* pollset_set); -grpc_polling_entity grpc_polling_entity_create_from_pollset( +grpc_polling_entity grpc_polling_entity_create_from_pollset( grpc_pollset* pollset); - -/** If \a pollent contains a pollset, return it. Otherwise, return NULL */ + +/** If \a pollent contains a pollset, return it. Otherwise, return NULL */ grpc_pollset* grpc_polling_entity_pollset(grpc_polling_entity* pollent); - -/** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */ + +/** If \a pollent contains a pollset_set, return it. Otherwise, return NULL */ grpc_pollset_set* grpc_polling_entity_pollset_set(grpc_polling_entity* pollent); - + bool grpc_polling_entity_is_empty(const grpc_polling_entity* pollent); - -/** Add the pollset or pollset_set in \a pollent to the destination pollset_set + +/** Add the pollset or pollset_set in \a pollent to the destination pollset_set * \a * pss_dst */ void grpc_polling_entity_add_to_pollset_set(grpc_polling_entity* pollent, grpc_pollset_set* pss_dst); - -/** Delete the pollset or pollset_set in \a pollent from the destination + +/** Delete the pollset or pollset_set in \a pollent from the destination * pollset_set \a * pss_dst */ void grpc_polling_entity_del_from_pollset_set(grpc_polling_entity* pollent, grpc_pollset_set* pss_dst); - -#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_POLLING_ENTITY_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset.h b/contrib/libs/grpc/src/core/lib/iomgr/pollset.h index 28472b360d..ae71218395 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/pollset.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset.h @@ -1,43 +1,43 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_POLLSET_H -#define GRPC_CORE_LIB_IOMGR_POLLSET_H - -#include <grpc/support/port_platform.h> - -#include <grpc/support/sync.h> -#include <grpc/support/time.h> - -#include "src/core/lib/iomgr/exec_ctx.h" - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_H +#define GRPC_CORE_LIB_IOMGR_POLLSET_H + +#include <grpc/support/port_platform.h> + +#include <grpc/support/sync.h> +#include <grpc/support/time.h> + +#include "src/core/lib/iomgr/exec_ctx.h" + extern grpc_core::DebugOnlyTraceFlag grpc_trace_fd_refcount; - -/* A grpc_pollset is a set of file descriptors that a higher level item is - interested in. For example: - - a server will typically keep a pollset containing all connected channels, - so that it can find new calls to service - - a completion queue might keep a pollset with an entry for each transport - that is servicing a call that it's tracking */ - -typedef struct grpc_pollset grpc_pollset; -typedef struct grpc_pollset_worker grpc_pollset_worker; - + +/* A grpc_pollset is a set of file descriptors that a higher level item is + interested in. For example: + - a server will typically keep a pollset containing all connected channels, + so that it can find new calls to service + - a completion queue might keep a pollset with an entry for each transport + that is servicing a call that it's tracking */ + +typedef struct grpc_pollset grpc_pollset; +typedef struct grpc_pollset_worker grpc_pollset_worker; + typedef struct grpc_pollset_vtable { void (*global_init)(void); void (*global_shutdown)(void); @@ -56,44 +56,44 @@ void grpc_set_pollset_vtable(grpc_pollset_vtable* vtable); void grpc_pollset_global_init(void); void grpc_pollset_global_shutdown(void); -size_t grpc_pollset_size(void); +size_t grpc_pollset_size(void); /* Initialize a pollset: assumes *pollset contains all zeros */ void grpc_pollset_init(grpc_pollset* pollset, gpr_mu** mu); -/* Begin shutting down the pollset, and call closure when done. - * pollset's mutex must be held */ +/* Begin shutting down the pollset, and call closure when done. + * pollset's mutex must be held */ void grpc_pollset_shutdown(grpc_pollset* pollset, grpc_closure* closure); void grpc_pollset_destroy(grpc_pollset* pollset); - -/* Do some work on a pollset. - May involve invoking asynchronous callbacks, or actually polling file - descriptors. - Requires pollset's mutex locked. - May unlock its mutex during its execution. - - worker is a (platform-specific) handle that can be used to wake up - from grpc_pollset_work before any events are received and before the timeout - has expired. It is both initialized and destroyed by grpc_pollset_work. - Initialization of worker is guaranteed to occur BEFORE the - pollset's mutex is released for the first time by grpc_pollset_work - and it is guaranteed that it will not be released by grpc_pollset_work - AFTER worker has been destroyed. - + +/* Do some work on a pollset. + May involve invoking asynchronous callbacks, or actually polling file + descriptors. + Requires pollset's mutex locked. + May unlock its mutex during its execution. + + worker is a (platform-specific) handle that can be used to wake up + from grpc_pollset_work before any events are received and before the timeout + has expired. It is both initialized and destroyed by grpc_pollset_work. + Initialization of worker is guaranteed to occur BEFORE the + pollset's mutex is released for the first time by grpc_pollset_work + and it is guaranteed that it will not be released by grpc_pollset_work + AFTER worker has been destroyed. + It's legal for worker to be NULL: in that case, this specific thread can not be directly woken with a kick, but maybe be indirectly (with a kick against the pollset as a whole). - Tries not to block past deadline. - May call grpc_closure_list_run on grpc_closure_list, without holding the - pollset - lock */ + Tries not to block past deadline. + May call grpc_closure_list_run on grpc_closure_list, without holding the + pollset + lock */ grpc_error* grpc_pollset_work(grpc_pollset* pollset, grpc_pollset_worker** worker, grpc_millis deadline) GRPC_MUST_USE_RESULT; - -/* Break one polling thread out of polling work for this pollset. + +/* Break one polling thread out of polling work for this pollset. If specific_worker is non-NULL, then kick that worker. */ grpc_error* grpc_pollset_kick(grpc_pollset* pollset, grpc_pollset_worker* specific_worker) - GRPC_MUST_USE_RESULT; - -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_H */ + GRPC_MUST_USE_RESULT; + +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set.h b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set.h index d3355b8ff8..f629f2d99f 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set.h @@ -1,35 +1,35 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_POLLSET_SET_H -#define GRPC_CORE_LIB_IOMGR_POLLSET_SET_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_SET_H +#define GRPC_CORE_LIB_IOMGR_POLLSET_SET_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/pollset.h" - -/* A grpc_pollset_set is a set of pollsets that are interested in an - action. Adding a pollset to a pollset_set automatically adds any - fd's (etc) that have been registered with the set_set to that pollset. - Registering fd's automatically adds them to all current pollsets. */ - -typedef struct grpc_pollset_set grpc_pollset_set; - +#include "src/core/lib/iomgr/pollset.h" + +/* A grpc_pollset_set is a set of pollsets that are interested in an + action. Adding a pollset to a pollset_set automatically adds any + fd's (etc) that have been registered with the set_set to that pollset. + Registering fd's automatically adds them to all current pollsets. */ + +typedef struct grpc_pollset_set grpc_pollset_set; + typedef struct grpc_pollset_set_vtable { grpc_pollset_set* (*create)(void); void (*destroy)(grpc_pollset_set* pollset_set); @@ -38,7 +38,7 @@ typedef struct grpc_pollset_set_vtable { void (*add_pollset_set)(grpc_pollset_set* bag, grpc_pollset_set* item); void (*del_pollset_set)(grpc_pollset_set* bag, grpc_pollset_set* item); } grpc_pollset_set_vtable; - + void grpc_set_pollset_set_vtable(grpc_pollset_set_vtable* vtable); grpc_pollset_set* grpc_pollset_set_create(void); @@ -52,4 +52,4 @@ void grpc_pollset_set_add_pollset_set(grpc_pollset_set* bag, void grpc_pollset_set_del_pollset_set(grpc_pollset_set* bag, grpc_pollset_set* item); -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_windows.h index 5ac9d1823b..c2f7a0f22b 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset_set_windows.h @@ -1,26 +1,26 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/pollset_set.h" - -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H */ +#include "src/core/lib/iomgr/pollset_set.h" + +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_SET_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset_uv.h b/contrib/libs/grpc/src/core/lib/iomgr/pollset_uv.h index de82bcc1d3..f2f14cadf5 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/pollset_uv.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset_uv.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_POLLSET_UV_H -#define GRPC_CORE_LIB_IOMGR_POLLSET_UV_H - -extern int grpc_pollset_work_run_loop; - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_UV_H +#define GRPC_CORE_LIB_IOMGR_POLLSET_UV_H + +extern int grpc_pollset_work_run_loop; + typedef struct grpc_custom_poller_vtable { void (*init)(void); void (*run_loop)(int blocking); } grpc_custom_poller_vtable; - + void grpc_custom_pollset_global_init(grpc_custom_poller_vtable* vtable); void grpc_custom_pollset_global_shutdown(void); -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_UV_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/pollset_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/pollset_windows.h index e89758c694..5b431924bd 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/pollset_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/pollset_windows.h @@ -1,70 +1,70 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H + #include <grpc/support/port_platform.h> -#include <grpc/support/sync.h> - +#include <grpc/support/sync.h> + #include "src/core/lib/iomgr/port.h" #ifdef GRPC_WINSOCK_SOCKET -#include "src/core/lib/iomgr/socket_windows.h" - -/* There isn't really any such thing as a pollset under Windows, due to the - nature of the IO completion ports. A Windows "pollset" is merely a mutex - used to synchronize with the IOCP, and workers are condition variables - used to block threads until work is ready. */ - -typedef enum { - GRPC_POLLSET_WORKER_LINK_POLLSET = 0, - GRPC_POLLSET_WORKER_LINK_GLOBAL, - GRPC_POLLSET_WORKER_LINK_TYPES -} grpc_pollset_worker_link_type; - -typedef struct grpc_pollset_worker_link { +#include "src/core/lib/iomgr/socket_windows.h" + +/* There isn't really any such thing as a pollset under Windows, due to the + nature of the IO completion ports. A Windows "pollset" is merely a mutex + used to synchronize with the IOCP, and workers are condition variables + used to block threads until work is ready. */ + +typedef enum { + GRPC_POLLSET_WORKER_LINK_POLLSET = 0, + GRPC_POLLSET_WORKER_LINK_GLOBAL, + GRPC_POLLSET_WORKER_LINK_TYPES +} grpc_pollset_worker_link_type; + +typedef struct grpc_pollset_worker_link { struct grpc_pollset_worker* next; struct grpc_pollset_worker* prev; -} grpc_pollset_worker_link; - -struct grpc_pollset; -typedef struct grpc_pollset grpc_pollset; - -typedef struct grpc_pollset_worker { - gpr_cv cv; - int kicked; +} grpc_pollset_worker_link; + +struct grpc_pollset; +typedef struct grpc_pollset grpc_pollset; + +typedef struct grpc_pollset_worker { + gpr_cv cv; + int kicked; struct grpc_pollset* pollset; - grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES]; -} grpc_pollset_worker; - -struct grpc_pollset { - int shutting_down; - int kicked_without_pollers; - int is_iocp_worker; - grpc_pollset_worker root_worker; + grpc_pollset_worker_link links[GRPC_POLLSET_WORKER_LINK_TYPES]; +} grpc_pollset_worker; + +struct grpc_pollset { + int shutting_down; + int kicked_without_pollers; + int is_iocp_worker; + grpc_pollset_worker root_worker; grpc_closure* on_shutdown; -}; - -void grpc_pollset_global_init(void); -void grpc_pollset_global_shutdown(void); - +}; + +void grpc_pollset_global_init(void); +void grpc_pollset_global_shutdown(void); + #endif -#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_POLLSET_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/port.h b/contrib/libs/grpc/src/core/lib/iomgr/port.h index 2a8d67b261..c62fa8d357 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/port.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/port.h @@ -1,26 +1,26 @@ -/* - * +/* + * * Copyright 2016 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. - * - */ - -#include <grpc/support/port_platform.h> - -#ifndef GRPC_CORE_LIB_IOMGR_PORT_H -#define GRPC_CORE_LIB_IOMGR_PORT_H - + * + */ + +#include <grpc/support/port_platform.h> + +#ifndef GRPC_CORE_LIB_IOMGR_PORT_H +#define GRPC_CORE_LIB_IOMGR_PORT_H + #ifdef GRPC_UV #ifndef GRPC_CUSTOM_SOCKET #define GRPC_CUSTOM_SOCKET @@ -33,26 +33,26 @@ #endif #if defined(GRPC_CUSTOM_SOCKET) // Do Nothing -#elif defined(GPR_WINDOWS) -#define GRPC_WINSOCK_SOCKET 1 -#define GRPC_WINDOWS_SOCKETUTILS 1 +#elif defined(GPR_WINDOWS) +#define GRPC_WINSOCK_SOCKET 1 +#define GRPC_WINDOWS_SOCKETUTILS 1 #define GRPC_WINDOWS_SOCKET_ARES_EV_DRIVER 1 -#elif defined(GPR_ANDROID) -#define GRPC_HAVE_IPV6_RECVPKTINFO 1 -#define GRPC_HAVE_IP_PKTINFO 1 -#define GRPC_HAVE_MSG_NOSIGNAL 1 -#define GRPC_HAVE_UNIX_SOCKET 1 -#define GRPC_LINUX_EVENTFD 1 -#define GRPC_POSIX_SOCKET 1 -#define GRPC_POSIX_SOCKETUTILS 1 -#define GRPC_POSIX_WAKEUP_FD 1 -#elif defined(GPR_LINUX) +#elif defined(GPR_ANDROID) +#define GRPC_HAVE_IPV6_RECVPKTINFO 1 +#define GRPC_HAVE_IP_PKTINFO 1 +#define GRPC_HAVE_MSG_NOSIGNAL 1 +#define GRPC_HAVE_UNIX_SOCKET 1 +#define GRPC_LINUX_EVENTFD 1 +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_POSIX_WAKEUP_FD 1 +#elif defined(GPR_LINUX) #define GRPC_HAVE_ARPA_NAMESER 1 #define GRPC_HAVE_IFADDRS 1 -#define GRPC_HAVE_IPV6_RECVPKTINFO 1 -#define GRPC_HAVE_IP_PKTINFO 1 -#define GRPC_HAVE_MSG_NOSIGNAL 1 -#define GRPC_HAVE_UNIX_SOCKET 1 +#define GRPC_HAVE_IPV6_RECVPKTINFO 1 +#define GRPC_HAVE_IP_PKTINFO 1 +#define GRPC_HAVE_MSG_NOSIGNAL 1 +#define GRPC_HAVE_UNIX_SOCKET 1 /* Linux has TCP_INQ support since 4.18, but it is safe to set the socket option on older kernels. */ #define GRPC_HAVE_TCP_INQ 1 @@ -61,22 +61,22 @@ #define GRPC_LINUX_ERRQUEUE 1 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0) */ #endif /* LINUX_VERSION_CODE */ -#define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1 +#define GRPC_LINUX_MULTIPOLL_WITH_EPOLL 1 #define GRPC_POSIX_FORK 1 #define GRPC_POSIX_HOST_NAME_MAX 1 -#define GRPC_POSIX_SOCKET 1 -#define GRPC_POSIX_WAKEUP_FD 1 -#ifdef __GLIBC_PREREQ +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_WAKEUP_FD 1 +#ifdef __GLIBC_PREREQ #if __GLIBC_PREREQ(2, 4) #define GRPC_LINUX_EPOLL 1 #endif -#if __GLIBC_PREREQ(2, 9) +#if __GLIBC_PREREQ(2, 9) #define GRPC_LINUX_EPOLL_CREATE1 1 -#define GRPC_LINUX_EVENTFD 1 -#endif -#if __GLIBC_PREREQ(2, 10) -#define GRPC_LINUX_SOCKETUTILS 1 -#endif +#define GRPC_LINUX_EVENTFD 1 +#endif +#if __GLIBC_PREREQ(2, 10) +#define GRPC_LINUX_SOCKETUTILS 1 +#endif #if !(__GLIBC_PREREQ(2, 17)) /* * TCP_USER_TIMEOUT wasn't imported to glibc until 2.17. Use Linux system @@ -91,20 +91,20 @@ #define GRPC_LINUX_EVENTFD 1 #define GRPC_MSG_IOVLEN_TYPE int #endif -#ifndef GRPC_LINUX_EVENTFD -#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 -#endif -#ifndef GRPC_LINUX_SOCKETUTILS -#define GRPC_POSIX_SOCKETUTILS -#endif -#elif defined(GPR_APPLE) +#ifndef GRPC_LINUX_EVENTFD +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#endif +#ifndef GRPC_LINUX_SOCKETUTILS +#define GRPC_POSIX_SOCKETUTILS +#endif +#elif defined(GPR_APPLE) #define GRPC_HAVE_ARPA_NAMESER 1 #define GRPC_HAVE_IFADDRS 1 -#define GRPC_HAVE_SO_NOSIGPIPE 1 -#define GRPC_HAVE_UNIX_SOCKET 1 -#define GRPC_MSG_IOVLEN_TYPE int +#define GRPC_HAVE_SO_NOSIGPIPE 1 +#define GRPC_HAVE_UNIX_SOCKET 1 +#define GRPC_MSG_IOVLEN_TYPE int #define GRPC_POSIX_FORK 1 -#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 #ifdef GRPC_CFSTREAM #define GRPC_CFSTREAM_IOMGR 1 #define GRPC_CFSTREAM_CLIENT 1 @@ -126,22 +126,22 @@ #define GRPC_POSIX_SOCKET_UDP_SERVER 1 #define GRPC_POSIX_SOCKET_UTILS_COMMON 1 #else -#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKET 1 #endif -#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_POSIX_SYSCONF 1 -#define GRPC_POSIX_WAKEUP_FD 1 -#elif defined(GPR_FREEBSD) +#define GRPC_POSIX_WAKEUP_FD 1 +#elif defined(GPR_FREEBSD) #define GRPC_HAVE_ARPA_NAMESER 1 #define GRPC_HAVE_IFADDRS 1 -#define GRPC_HAVE_IPV6_RECVPKTINFO 1 -#define GRPC_HAVE_SO_NOSIGPIPE 1 -#define GRPC_HAVE_UNIX_SOCKET 1 +#define GRPC_HAVE_IPV6_RECVPKTINFO 1 +#define GRPC_HAVE_SO_NOSIGPIPE 1 +#define GRPC_HAVE_UNIX_SOCKET 1 #define GRPC_POSIX_FORK 1 -#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 -#define GRPC_POSIX_SOCKET 1 -#define GRPC_POSIX_SOCKETUTILS 1 -#define GRPC_POSIX_WAKEUP_FD 1 +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_POSIX_WAKEUP_FD 1 #elif defined(GPR_OPENBSD) #define GRPC_HAVE_IFADDRS 1 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 @@ -162,12 +162,12 @@ #define GRPC_POSIX_SOCKET 1 #define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_POSIX_WAKEUP_FD 1 -#elif defined(GPR_NACL) +#elif defined(GPR_NACL) #define GRPC_HAVE_ARPA_NAMESER 1 -#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 -#define GRPC_POSIX_SOCKET 1 -#define GRPC_POSIX_SOCKETUTILS 1 -#define GRPC_POSIX_WAKEUP_FD 1 +#define GRPC_POSIX_NO_SPECIAL_WAKEUP_FD 1 +#define GRPC_POSIX_SOCKET 1 +#define GRPC_POSIX_SOCKETUTILS 1 +#define GRPC_POSIX_WAKEUP_FD 1 #elif defined(GPR_FUCHSIA) #define GRPC_HAVE_IFADDRS 1 #define GRPC_HAVE_IPV6_RECVPKTINFO 1 @@ -184,17 +184,17 @@ // TODO(rudominer) Check this does something we want. #define GRPC_POSIX_SOCKETUTILS 1 #define GRPC_TIMER_USE_GENERIC 1 -#elif !defined(GPR_NO_AUTODETECT_PLATFORM) -#error "Platform not recognized" -#endif - -#if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ +#elif !defined(GPR_NO_AUTODETECT_PLATFORM) +#error "Platform not recognized" +#endif + +#if defined(GRPC_POSIX_SOCKET) + defined(GRPC_WINSOCK_SOCKET) + \ defined(GRPC_CUSTOM_SOCKET) + defined(GRPC_CFSTREAM) != \ - 1 + 1 #error \ "Must define exactly one of GRPC_POSIX_SOCKET, GRPC_WINSOCK_SOCKET, GRPC_CUSTOM_SOCKET" -#endif - +#endif + #ifdef GRPC_POSIX_SOCKET #define GRPC_POSIX_SOCKET_ARES_EV_DRIVER 1 #define GRPC_POSIX_SOCKET_EV 1 @@ -221,4 +221,4 @@ #define GRPC_GETHOSTNAME_FALLBACK 1 #endif -#endif /* GRPC_CORE_LIB_IOMGR_PORT_H */ +#endif /* GRPC_CORE_LIB_IOMGR_PORT_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address.h b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address.h index 57126c7c93..7ddda895fb 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/resolve_address.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/resolve_address.h @@ -1,27 +1,27 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H -#define GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H +#define GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H + #include <grpc/support/port_platform.h> -#include <stddef.h> +#include <stddef.h> #include "src/core/lib/iomgr/port.h" @@ -37,16 +37,16 @@ #include <sys/socket.h> #endif -#include "src/core/lib/iomgr/pollset_set.h" - -#define GRPC_MAX_SOCKADDR_SIZE 128 - +#include "src/core/lib/iomgr/pollset_set.h" + +#define GRPC_MAX_SOCKADDR_SIZE 128 + struct grpc_resolved_address { - char addr[GRPC_MAX_SOCKADDR_SIZE]; + char addr[GRPC_MAX_SOCKADDR_SIZE]; socklen_t len; }; struct grpc_resolved_addresses { - size_t naddrs; + size_t naddrs; grpc_resolved_address* addrs; }; typedef struct grpc_address_resolver_vtable { @@ -61,21 +61,21 @@ typedef struct grpc_address_resolver_vtable { void grpc_set_resolver_impl(grpc_address_resolver_vtable* vtable); -/* Asynchronously resolve addr. Use default_port if a port isn't designated - in addr, otherwise use the port in addr. */ +/* Asynchronously resolve addr. Use default_port if a port isn't designated + in addr, otherwise use the port in addr. */ /* TODO(apolcyn): add a timeout here */ void grpc_resolve_address(const char* addr, const char* default_port, grpc_pollset_set* interested_parties, grpc_closure* on_done, grpc_resolved_addresses** addresses); -/* Destroy resolved addresses */ +/* Destroy resolved addresses */ void grpc_resolved_addresses_destroy(grpc_resolved_addresses* addresses); - + /* Resolve addr in a blocking fashion. On success, - result must be freed with grpc_resolved_addresses_destroy. */ + result must be freed with grpc_resolved_addresses_destroy. */ grpc_error* grpc_blocking_resolve_address(const char* name, const char* default_port, grpc_resolved_addresses** addresses); - -#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_RESOLVE_ADDRESS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.h b/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.h index ec89a92020..e590f58f09 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/resource_quota.h @@ -1,70 +1,70 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H -#define GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H +#define GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H + #include <grpc/support/port_platform.h> -#include <grpc/grpc.h> - +#include <grpc/grpc.h> + #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/closure.h" - -/** \file Tracks resource usage against a pool. - - The current implementation tracks only memory usage, but in the future - this may be extended to (for example) threads and file descriptors. - - A grpc_resource_quota represents the pooled resources, and - grpc_resource_user instances attach to the quota and consume those - resources. They also offer a vector for reclamation: if we become - resource constrained, grpc_resource_user instances are asked (in turn) to - free up whatever they can so that the system as a whole can make progress. - - There are three kinds of reclamation that take place, in order of increasing - invasiveness: - - an internal reclamation, where cached resource at the resource user level - is returned to the quota - - a benign reclamation phase, whereby resources that are in use but are not - helping anything make progress are reclaimed - - a destructive reclamation, whereby resources that are helping something - make progress may be enacted so that at least one part of the system can - complete. - - Only one reclamation will be outstanding for a given quota at a given time. - On each reclamation attempt, the kinds of reclamation are tried in order of - increasing invasiveness, stopping at the first one that succeeds. Thus, on a - given reclamation attempt, if internal and benign reclamation both fail, it - will wind up doing a destructive reclamation. However, the next reclamation - attempt may then be able to get what it needs via internal or benign - reclamation, due to resources that may have been freed up by the destructive - reclamation in the previous attempt. - - Future work will be to expose the current resource pressure so that back - pressure can be applied to avoid reclamation phases starting. - - Resource users own references to resource quotas, and resource quotas - maintain lists of users (which users arrange to leave before they are - destroyed) */ - + +/** \file Tracks resource usage against a pool. + + The current implementation tracks only memory usage, but in the future + this may be extended to (for example) threads and file descriptors. + + A grpc_resource_quota represents the pooled resources, and + grpc_resource_user instances attach to the quota and consume those + resources. They also offer a vector for reclamation: if we become + resource constrained, grpc_resource_user instances are asked (in turn) to + free up whatever they can so that the system as a whole can make progress. + + There are three kinds of reclamation that take place, in order of increasing + invasiveness: + - an internal reclamation, where cached resource at the resource user level + is returned to the quota + - a benign reclamation phase, whereby resources that are in use but are not + helping anything make progress are reclaimed + - a destructive reclamation, whereby resources that are helping something + make progress may be enacted so that at least one part of the system can + complete. + + Only one reclamation will be outstanding for a given quota at a given time. + On each reclamation attempt, the kinds of reclamation are tried in order of + increasing invasiveness, stopping at the first one that succeeds. Thus, on a + given reclamation attempt, if internal and benign reclamation both fail, it + will wind up doing a destructive reclamation. However, the next reclamation + attempt may then be able to get what it needs via internal or benign + reclamation, due to resources that may have been freed up by the destructive + reclamation in the previous attempt. + + Future work will be to expose the current resource pressure so that back + pressure can be applied to avoid reclamation phases starting. + + Resource users own references to resource quotas, and resource quotas + maintain lists of users (which users arrange to leave before they are + destroyed) */ + extern grpc_core::TraceFlag grpc_resource_quota_trace; - + // TODO(juanlishen): This is a hack. We need to do real accounting instead of // hard coding. constexpr size_t GRPC_RESOURCE_QUOTA_CALL_SIZE = 15 * 1024; @@ -75,7 +75,7 @@ grpc_resource_quota* grpc_resource_quota_ref_internal( void grpc_resource_quota_unref_internal(grpc_resource_quota* resource_quota); grpc_resource_quota* grpc_resource_quota_from_channel_args( const grpc_channel_args* channel_args, bool create = true); - + /* Return a number indicating current memory pressure: 0.0 ==> no memory usage 1.0 ==> maximum memory usage */ @@ -84,20 +84,20 @@ double grpc_resource_quota_get_memory_pressure( size_t grpc_resource_quota_peek_size(grpc_resource_quota* resource_quota); -typedef struct grpc_resource_user grpc_resource_user; - +typedef struct grpc_resource_user grpc_resource_user; + grpc_resource_user* grpc_resource_user_create( grpc_resource_quota* resource_quota, const char* name); - -/* Returns a borrowed reference to the underlying resource quota for this - resource user. */ + +/* Returns a borrowed reference to the underlying resource quota for this + resource user. */ grpc_resource_quota* grpc_resource_user_quota( grpc_resource_user* resource_user); - + void grpc_resource_user_ref(grpc_resource_user* resource_user); void grpc_resource_user_unref(grpc_resource_user* resource_user); void grpc_resource_user_shutdown(grpc_resource_user* resource_user); - + /* Attempts to get quota from the resource_user to create 'thread_count' number * of threads. Returns true if successful (i.e the caller is now free to create * 'thread_count' number of threads) or false if quota is not available */ @@ -133,45 +133,45 @@ bool grpc_resource_user_safe_alloc(grpc_resource_user* resource_user, bool grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size, grpc_closure* optional_on_done) GRPC_MUST_USE_RESULT; -/* Release memory back to the quota */ +/* Release memory back to the quota */ void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size); -/* Post a memory reclaimer to the resource user. Only one benign and one - destructive reclaimer can be posted at once. When executed, the reclaimer - MUST call grpc_resource_user_finish_reclamation before it completes, to - return control to the resource quota. */ +/* Post a memory reclaimer to the resource user. Only one benign and one + destructive reclaimer can be posted at once. When executed, the reclaimer + MUST call grpc_resource_user_finish_reclamation before it completes, to + return control to the resource quota. */ void grpc_resource_user_post_reclaimer(grpc_resource_user* resource_user, bool destructive, grpc_closure* closure); -/* Finish a reclamation step */ +/* Finish a reclamation step */ void grpc_resource_user_finish_reclamation(grpc_resource_user* resource_user); - -/* Helper to allocate slices from a resource user */ -typedef struct grpc_resource_user_slice_allocator { - /* Closure for when a resource user allocation completes */ - grpc_closure on_allocated; - /* Closure to call when slices have been allocated */ - grpc_closure on_done; - /* Length of slices to allocate on the current request */ - size_t length; - /* Number of slices to allocate on the current request */ - size_t count; - /* Destination for slices to allocate on the current request */ + +/* Helper to allocate slices from a resource user */ +typedef struct grpc_resource_user_slice_allocator { + /* Closure for when a resource user allocation completes */ + grpc_closure on_allocated; + /* Closure to call when slices have been allocated */ + grpc_closure on_done; + /* Length of slices to allocate on the current request */ + size_t length; + /* Number of slices to allocate on the current request */ + size_t count; + /* Destination for slices to allocate on the current request */ grpc_slice_buffer* dest; - /* Parent resource user */ + /* Parent resource user */ grpc_resource_user* resource_user; -} grpc_resource_user_slice_allocator; - -/* Initialize a slice allocator. - When an allocation is completed, calls \a cb with arg \p. */ -void grpc_resource_user_slice_allocator_init( +} grpc_resource_user_slice_allocator; + +/* Initialize a slice allocator. + When an allocation is completed, calls \a cb with arg \p. */ +void grpc_resource_user_slice_allocator_init( grpc_resource_user_slice_allocator* slice_allocator, grpc_resource_user* resource_user, grpc_iomgr_cb_func cb, void* p); - -/* Allocate \a count slices of length \a length into \a dest. Only one request + +/* Allocate \a count slices of length \a length into \a dest. Only one request can be outstanding at a time. Returns whether the slice was allocated inline in the function. If true, the \a slice_allocator->on_allocated callback will not be called. */ bool grpc_resource_user_alloc_slices( grpc_resource_user_slice_allocator* slice_allocator, size_t length, size_t count, grpc_slice_buffer* dest) GRPC_MUST_USE_RESULT; - -#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr.h b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr.h index 5edf735cd1..ce06ac66b6 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr.h @@ -1,32 +1,32 @@ -/* - * +/* + * * 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. - * - */ - -/* This header transitively includes other headers that care about include - * order, so it should be included first. As a consequence, it should not be - * included in any other header. */ - -#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_H -#define GRPC_CORE_LIB_IOMGR_SOCKADDR_H - + * + */ + +/* This header transitively includes other headers that care about include + * order, so it should be included first. As a consequence, it should not be + * included in any other header. */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_H +#define GRPC_CORE_LIB_IOMGR_SOCKADDR_H + #include <grpc/support/port_platform.h> - + #include "src/core/lib/iomgr/sockaddr_custom.h" #include "src/core/lib/iomgr/sockaddr_posix.h" -#include "src/core/lib/iomgr/sockaddr_windows.h" - -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_H */ +#include "src/core/lib/iomgr/sockaddr_windows.h" + +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_posix.h index 3cedd9082d..a8dfddc43d 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_posix.h @@ -1,36 +1,36 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H -#define GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H +#define GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H + #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" #ifdef GRPC_POSIX_SOCKET_SOCKADDR -#include <arpa/inet.h> -#include <netdb.h> -#include <netinet/in.h> -#include <sys/socket.h> -#include <sys/types.h> -#include <unistd.h> - +#include <arpa/inet.h> +#include <netdb.h> +#include <netinet/in.h> +#include <sys/socket.h> +#include <sys/types.h> +#include <unistd.h> + typedef struct sockaddr grpc_sockaddr; typedef struct sockaddr_in grpc_sockaddr_in; typedef struct in_addr grpc_in_addr; @@ -52,4 +52,4 @@ typedef struct in6_addr grpc_in6_addr; #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H */ +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h index eeedeeb90c..e96e390f4a 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_utils.h @@ -1,63 +1,63 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H -#define GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H +#define GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> -#include "src/core/lib/iomgr/resolve_address.h" - -/* Returns true if addr is an IPv4-mapped IPv6 address within the - ::ffff:0.0.0.0/96 range, or false otherwise. - - If addr4_out is non-NULL, the inner IPv4 address will be copied here when - returning true. */ +#include "src/core/lib/iomgr/resolve_address.h" + +/* Returns true if addr is an IPv4-mapped IPv6 address within the + ::ffff:0.0.0.0/96 range, or false otherwise. + + If addr4_out is non-NULL, the inner IPv4 address will be copied here when + returning true. */ int grpc_sockaddr_is_v4mapped(const grpc_resolved_address* addr, grpc_resolved_address* addr4_out); - -/* If addr is an AF_INET address, writes the corresponding ::ffff:0.0.0.0/96 - address to addr6_out and returns true. Otherwise returns false. */ + +/* If addr is an AF_INET address, writes the corresponding ::ffff:0.0.0.0/96 + address to addr6_out and returns true. Otherwise returns false. */ int grpc_sockaddr_to_v4mapped(const grpc_resolved_address* addr, grpc_resolved_address* addr6_out); - -/* If addr is ::, 0.0.0.0, or ::ffff:0.0.0.0, writes the port number to + +/* If addr is ::, 0.0.0.0, or ::ffff:0.0.0.0, writes the port number to *port_out (if not NULL) and returns true, otherwise returns false. */ int grpc_sockaddr_is_wildcard(const grpc_resolved_address* addr, int* port_out); - -/* Writes 0.0.0.0:port and [::]:port to separate sockaddrs. */ + +/* Writes 0.0.0.0:port and [::]:port to separate sockaddrs. */ void grpc_sockaddr_make_wildcards(int port, grpc_resolved_address* wild4_out, grpc_resolved_address* wild6_out); - -/* Writes 0.0.0.0:port. */ + +/* Writes 0.0.0.0:port. */ void grpc_sockaddr_make_wildcard4(int port, grpc_resolved_address* wild_out); - -/* Writes [::]:port. */ + +/* Writes [::]:port. */ void grpc_sockaddr_make_wildcard6(int port, grpc_resolved_address* wild_out); - -/* Return the IP port number of a sockaddr */ + +/* Return the IP port number of a sockaddr */ int grpc_sockaddr_get_port(const grpc_resolved_address* addr); - -/* Set IP port number of a sockaddr */ + +/* Set IP port number of a sockaddr */ int grpc_sockaddr_set_port(const grpc_resolved_address* addr, int port); - + // Converts a sockaddr into a newly-allocated human-readable string. // // Currently, only the AF_INET and AF_INET6 families are recognized. @@ -65,10 +65,10 @@ int grpc_sockaddr_set_port(const grpc_resolved_address* addr, int port); // displayed as plain IPv4. TString grpc_sockaddr_to_string(const grpc_resolved_address* addr, bool normalize); - + void grpc_string_to_sockaddr(grpc_resolved_address* out, const char* addr, int port); - + /* Returns the URI string corresponding to \a addr */ TString grpc_sockaddr_to_uri(const grpc_resolved_address* addr); @@ -77,4 +77,4 @@ const char* grpc_sockaddr_get_uri_scheme(const grpc_resolved_address* addr); int grpc_sockaddr_get_family(const grpc_resolved_address* resolved_addr); -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_UTILS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_windows.h index 9faebbc254..593b22abf2 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/sockaddr_windows.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 GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H + #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" @@ -27,12 +27,12 @@ #define OPTIONAL -#include <winsock2.h> -#include <ws2tcpip.h> - -// must be included after the above -#include <mswsock.h> - +#include <winsock2.h> +#include <ws2tcpip.h> + +// must be included after the above +#include <mswsock.h> + #undef OPTIONAL typedef struct sockaddr grpc_sockaddr; @@ -56,4 +56,4 @@ typedef struct in6_addr grpc_in6_addr; #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_SOCKADDR_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_mutator.h b/contrib/libs/grpc/src/core/lib/iomgr/socket_mutator.h index 9f77a3b266..0ddb85050e 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/socket_mutator.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_mutator.h @@ -1,60 +1,60 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H -#define GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H +#define GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> -#include <grpc/support/sync.h> - +#include <grpc/impl/codegen/grpc_types.h> +#include <grpc/support/sync.h> + #include <stdbool.h> - -/** The virtual table of grpc_socket_mutator */ + +/** The virtual table of grpc_socket_mutator */ struct grpc_socket_mutator_vtable { /** Mutates the socket options of \a fd */ bool (*mutate_fd)(int fd, grpc_socket_mutator* mutator); - /** Compare socket mutator \a a and \a b */ + /** Compare socket mutator \a a and \a b */ int (*compare)(grpc_socket_mutator* a, grpc_socket_mutator* b); - /** Destroys the socket mutator instance */ + /** Destroys the socket mutator instance */ void (*destroy)(grpc_socket_mutator* mutator); }; -/** The Socket Mutator interface allows changes on socket options */ -struct grpc_socket_mutator { +/** The Socket Mutator interface allows changes on socket options */ +struct grpc_socket_mutator { const grpc_socket_mutator_vtable* vtable; - gpr_refcount refcount; -}; - -/** called by concrete implementations to initialize the base struct */ + gpr_refcount refcount; +}; + +/** called by concrete implementations to initialize the base struct */ void grpc_socket_mutator_init(grpc_socket_mutator* mutator, const grpc_socket_mutator_vtable* vtable); - -/** Wrap \a mutator as a grpc_arg */ + +/** Wrap \a mutator as a grpc_arg */ grpc_arg grpc_socket_mutator_to_arg(grpc_socket_mutator* mutator); - -/** Perform the file descriptor mutation operation of \a mutator on \a fd */ + +/** Perform the file descriptor mutation operation of \a mutator on \a fd */ bool grpc_socket_mutator_mutate_fd(grpc_socket_mutator* mutator, int fd); - -/** Compare if \a a and \a b are the same mutator or have same settings */ + +/** Compare if \a a and \a b are the same mutator or have same settings */ int grpc_socket_mutator_compare(grpc_socket_mutator* a, grpc_socket_mutator* b); - + grpc_socket_mutator* grpc_socket_mutator_ref(grpc_socket_mutator* mutator); void grpc_socket_mutator_unref(grpc_socket_mutator* mutator); - -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_MUTATOR_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils.h b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils.h index 14bb081e93..84f4adee9e 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils.h @@ -1,28 +1,28 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H -#define GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H +#define GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - +#include <stddef.h> + // TODO(juanlishen): The following functions might be simple enough to implement // ourselves, so that they don't cause any portability hassle. @@ -41,7 +41,7 @@ uint32_t grpc_ntohl(uint32_t netlong); /* A wrapper for inet_pton on POSIX and WINDOWS */ int grpc_inet_pton(int af, const char* src, void* dst); -/* A wrapper for inet_ntop on POSIX systems and InetNtop on Windows systems */ +/* A wrapper for inet_ntop on POSIX systems and InetNtop on Windows systems */ const char* grpc_inet_ntop(int af, const void* src, char* dst, size_t size); - -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h index b4dc909d1e..70af9c91b7 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_utils_posix.h @@ -1,36 +1,36 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H -#define GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H +#define GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/resolve_address.h" - -#include <sys/socket.h> -#include <unistd.h> - -#include <grpc/impl/codegen/grpc_types.h> -#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/resolve_address.h" + +#include <sys/socket.h> +#include <unistd.h> + +#include <grpc/impl/codegen/grpc_types.h> +#include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/socket_factory_posix.h" -#include "src/core/lib/iomgr/socket_mutator.h" - +#include "src/core/lib/iomgr/socket_mutator.h" + #ifdef GRPC_LINUX_ERRQUEUE #ifndef SO_ZEROCOPY #define SO_ZEROCOPY 60 @@ -40,31 +40,31 @@ #endif #endif /* ifdef GRPC_LINUX_ERRQUEUE */ -/* a wrapper for accept or accept4 */ +/* a wrapper for accept or accept4 */ int grpc_accept4(int sockfd, grpc_resolved_address* resolved_addr, int nonblock, - int cloexec); - + int cloexec); + /* set a socket to use zerocopy */ grpc_error* grpc_set_socket_zerocopy(int fd); -/* set a socket to non blocking mode */ +/* set a socket to non blocking mode */ grpc_error* grpc_set_socket_nonblocking(int fd, int non_blocking); - -/* set a socket to close on exec */ + +/* set a socket to close on exec */ grpc_error* grpc_set_socket_cloexec(int fd, int close_on_exec); - -/* set a socket to reuse old addresses */ + +/* set a socket to reuse old addresses */ grpc_error* grpc_set_socket_reuse_addr(int fd, int reuse); - + /* return true if SO_REUSEPORT is supported */ bool grpc_is_socket_reuse_port_supported(); -/* disable nagle */ +/* disable nagle */ grpc_error* grpc_set_socket_low_latency(int fd, int low_latency); - -/* set SO_REUSEPORT */ + +/* set SO_REUSEPORT */ grpc_error* grpc_set_socket_reuse_port(int fd, int reuse); - + /* Configure the default values for TCP_USER_TIMEOUT */ void config_default_tcp_user_timeout(bool enable, int timeout, bool is_client); @@ -72,92 +72,92 @@ void config_default_tcp_user_timeout(bool enable, int timeout, bool is_client); grpc_error* grpc_set_socket_tcp_user_timeout( int fd, const grpc_channel_args* channel_args, bool is_client); -/* Returns true if this system can create AF_INET6 sockets bound to ::1. - The value is probed once, and cached for the life of the process. - - This is more restrictive than checking for socket(AF_INET6) to succeed, - because Linux with "net.ipv6.conf.all.disable_ipv6 = 1" is able to create - and bind IPv6 sockets, but cannot connect to a getsockname() of [::]:port - without a valid loopback interface. Rather than expose this half-broken - state to library users, we turn off IPv6 sockets. */ -int grpc_ipv6_loopback_available(void); - -/* Tries to set SO_NOSIGPIPE if available on this platform. - If SO_NO_SIGPIPE is not available, returns 1. */ +/* Returns true if this system can create AF_INET6 sockets bound to ::1. + The value is probed once, and cached for the life of the process. + + This is more restrictive than checking for socket(AF_INET6) to succeed, + because Linux with "net.ipv6.conf.all.disable_ipv6 = 1" is able to create + and bind IPv6 sockets, but cannot connect to a getsockname() of [::]:port + without a valid loopback interface. Rather than expose this half-broken + state to library users, we turn off IPv6 sockets. */ +int grpc_ipv6_loopback_available(void); + +/* Tries to set SO_NOSIGPIPE if available on this platform. + If SO_NO_SIGPIPE is not available, returns 1. */ grpc_error* grpc_set_socket_no_sigpipe_if_possible(int fd); - -/* Tries to set IP_PKTINFO if available on this platform. - If IP_PKTINFO is not available, returns 1. */ + +/* Tries to set IP_PKTINFO if available on this platform. + If IP_PKTINFO is not available, returns 1. */ grpc_error* grpc_set_socket_ip_pktinfo_if_possible(int fd); - -/* Tries to set IPV6_RECVPKTINFO if available on this platform. - If IPV6_RECVPKTINFO is not available, returns 1. */ + +/* Tries to set IPV6_RECVPKTINFO if available on this platform. + If IPV6_RECVPKTINFO is not available, returns 1. */ grpc_error* grpc_set_socket_ipv6_recvpktinfo_if_possible(int fd); - -/* Tries to set the socket's send buffer to given size. */ + +/* Tries to set the socket's send buffer to given size. */ grpc_error* grpc_set_socket_sndbuf(int fd, int buffer_size_bytes); - -/* Tries to set the socket's receive buffer to given size. */ + +/* Tries to set the socket's receive buffer to given size. */ grpc_error* grpc_set_socket_rcvbuf(int fd, int buffer_size_bytes); - -/* Tries to set the socket using a grpc_socket_mutator */ + +/* Tries to set the socket using a grpc_socket_mutator */ grpc_error* grpc_set_socket_with_mutator(int fd, grpc_socket_mutator* mutator); - + /* Extracts the first socket mutator from args if any and applies on the fd. */ grpc_error* grpc_apply_socket_mutator_in_args(int fd, const grpc_channel_args* args); -/* An enum to keep track of IPv4/IPv6 socket modes. - - Currently, this information is only used when a socket is first created, but - in the future we may wish to store it alongside the fd. This would let calls - like sendto() know which family to use without asking the kernel first. */ -typedef enum grpc_dualstack_mode { - /* Uninitialized, or a non-IP socket. */ - GRPC_DSMODE_NONE, - /* AF_INET only. */ - GRPC_DSMODE_IPV4, - /* AF_INET6 only, because IPV6_V6ONLY could not be cleared. */ - GRPC_DSMODE_IPV6, - /* AF_INET6, which also supports ::ffff-mapped IPv4 addresses. */ - GRPC_DSMODE_DUALSTACK -} grpc_dualstack_mode; - -/* Only tests should use this flag. */ -extern int grpc_forbid_dualstack_sockets_for_testing; - +/* An enum to keep track of IPv4/IPv6 socket modes. + + Currently, this information is only used when a socket is first created, but + in the future we may wish to store it alongside the fd. This would let calls + like sendto() know which family to use without asking the kernel first. */ +typedef enum grpc_dualstack_mode { + /* Uninitialized, or a non-IP socket. */ + GRPC_DSMODE_NONE, + /* AF_INET only. */ + GRPC_DSMODE_IPV4, + /* AF_INET6 only, because IPV6_V6ONLY could not be cleared. */ + GRPC_DSMODE_IPV6, + /* AF_INET6, which also supports ::ffff-mapped IPv4 addresses. */ + GRPC_DSMODE_DUALSTACK +} grpc_dualstack_mode; + +/* Only tests should use this flag. */ +extern int grpc_forbid_dualstack_sockets_for_testing; + /* Tries to set the socket to dualstack. Returns 1 on success. */ int grpc_set_socket_dualstack(int fd); -/* Creates a new socket for connecting to (or listening on) an address. - - If addr is AF_INET6, this creates an IPv6 socket first. If that fails, - and addr is within ::ffff:0.0.0.0/96, then it automatically falls back to - an IPv4 socket. - - If addr is AF_INET, AF_UNIX, or anything else, then this is similar to - calling socket() directly. - - Returns an fd on success, otherwise returns -1 with errno set to the result - of a failed socket() call. - - The *dsmode output indicates which address family was actually created. - The recommended way to use this is: - - First convert to IPv6 using grpc_sockaddr_to_v4mapped(). - - Create the socket. - - If *dsmode is IPV4, use grpc_sockaddr_is_v4mapped() to convert back to - IPv4, so that bind() or connect() see the correct family. - Also, it's important to distinguish between DUALSTACK and IPV6 when - listening on the [::] wildcard address. */ +/* Creates a new socket for connecting to (or listening on) an address. + + If addr is AF_INET6, this creates an IPv6 socket first. If that fails, + and addr is within ::ffff:0.0.0.0/96, then it automatically falls back to + an IPv4 socket. + + If addr is AF_INET, AF_UNIX, or anything else, then this is similar to + calling socket() directly. + + Returns an fd on success, otherwise returns -1 with errno set to the result + of a failed socket() call. + + The *dsmode output indicates which address family was actually created. + The recommended way to use this is: + - First convert to IPv6 using grpc_sockaddr_to_v4mapped(). + - Create the socket. + - If *dsmode is IPV4, use grpc_sockaddr_is_v4mapped() to convert back to + IPv4, so that bind() or connect() see the correct family. + Also, it's important to distinguish between DUALSTACK and IPV6 when + listening on the [::] wildcard address. */ grpc_error* grpc_create_dualstack_socket(const grpc_resolved_address* addr, - int type, int protocol, + int type, int protocol, grpc_dualstack_mode* dsmode, int* newfd); - + /* Same as grpc_create_dualstack_socket(), but use the given socket factory (if non-null) to create the socket, rather than calling socket() directly. */ grpc_error* grpc_create_dualstack_socket_using_factory( grpc_socket_factory* factory, const grpc_resolved_address* addr, int type, int protocol, grpc_dualstack_mode* dsmode, int* newfd); -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_UTILS_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.h index 78f79453c6..32132458c5 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/socket_windows.h @@ -1,119 +1,119 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H - -#include <grpc/support/port_platform.h> + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H + +#include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" #ifdef GRPC_WINSOCK_SOCKET -#include <winsock2.h> - -#include <grpc/support/atm.h> -#include <grpc/support/sync.h> - +#include <winsock2.h> + +#include <grpc/support/atm.h> +#include <grpc/support/sync.h> + #include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/iomgr_internal.h" - +#include "src/core/lib/iomgr/iomgr_internal.h" + #ifndef WSA_FLAG_NO_HANDLE_INHERIT #define WSA_FLAG_NO_HANDLE_INHERIT 0x80 #endif -/* This holds the data for an outstanding read or write on a socket. - The mutex to protect the concurrent access to that data is the one - inside the winsocket wrapper. */ -typedef struct grpc_winsocket_callback_info { - /* This is supposed to be a WSAOVERLAPPED, but in order to get that - definition, we need to include ws2tcpip.h, which needs to be included - from the top, otherwise it'll clash with a previous inclusion of - windows.h that in turns includes winsock.h. If anyone knows a way - to do it properly, feel free to send a patch. */ - OVERLAPPED overlapped; - /* The callback information for the pending operation. May be empty if the - caller hasn't registered a callback yet. */ +/* This holds the data for an outstanding read or write on a socket. + The mutex to protect the concurrent access to that data is the one + inside the winsocket wrapper. */ +typedef struct grpc_winsocket_callback_info { + /* This is supposed to be a WSAOVERLAPPED, but in order to get that + definition, we need to include ws2tcpip.h, which needs to be included + from the top, otherwise it'll clash with a previous inclusion of + windows.h that in turns includes winsock.h. If anyone knows a way + to do it properly, feel free to send a patch. */ + OVERLAPPED overlapped; + /* The callback information for the pending operation. May be empty if the + caller hasn't registered a callback yet. */ grpc_closure* closure; - /* A boolean to describe if the IO Completion Port got a notification for - that operation. This will happen if the operation completed before the - called had time to register a callback. We could avoid that behavior - altogether by forcing the caller to always register its callback before - proceeding queue an operation, but it is frequent for an IO Completion - Port to trigger quickly. This way we avoid a context switch for calling - the callback. We also simplify the read / write operations to avoid having - to hold a mutex for a long amount of time. */ - int has_pending_iocp; - /* The results of the overlapped operation. */ + /* A boolean to describe if the IO Completion Port got a notification for + that operation. This will happen if the operation completed before the + called had time to register a callback. We could avoid that behavior + altogether by forcing the caller to always register its callback before + proceeding queue an operation, but it is frequent for an IO Completion + Port to trigger quickly. This way we avoid a context switch for calling + the callback. We also simplify the read / write operations to avoid having + to hold a mutex for a long amount of time. */ + int has_pending_iocp; + /* The results of the overlapped operation. */ DWORD bytes_transferred; - int wsa_error; -} grpc_winsocket_callback_info; - -/* This is a wrapper to a Windows socket. A socket can have one outstanding - read, and one outstanding write. Doing an asynchronous accept means waiting - for a read operation. Doing an asynchronous connect means waiting for a - write operation. These are completely arbitrary ties between the operation - and the kind of event, because we can have one overlapped per pending - operation, whichever its nature is. So we could have more dedicated pending - operation callbacks for connect and listen. But given the scope of listen - and accept, we don't need to go to that extent and waste memory. Also, this - is closer to what happens in posix world. */ -typedef struct grpc_winsocket { - SOCKET socket; - bool destroy_called; - - grpc_winsocket_callback_info write_info; - grpc_winsocket_callback_info read_info; - - gpr_mu state_mu; - bool shutdown_called; - - /* You can't add the same socket twice to the same IO Completion Port. - This prevents that. */ - int added_to_iocp; - - grpc_closure shutdown_closure; - - /* A label for iomgr to track outstanding objects */ - grpc_iomgr_object iomgr_object; -} grpc_winsocket; - -/* Create a wrapped windows handle. This takes ownership of it, meaning that - it will be responsible for closing it. */ + int wsa_error; +} grpc_winsocket_callback_info; + +/* This is a wrapper to a Windows socket. A socket can have one outstanding + read, and one outstanding write. Doing an asynchronous accept means waiting + for a read operation. Doing an asynchronous connect means waiting for a + write operation. These are completely arbitrary ties between the operation + and the kind of event, because we can have one overlapped per pending + operation, whichever its nature is. So we could have more dedicated pending + operation callbacks for connect and listen. But given the scope of listen + and accept, we don't need to go to that extent and waste memory. Also, this + is closer to what happens in posix world. */ +typedef struct grpc_winsocket { + SOCKET socket; + bool destroy_called; + + grpc_winsocket_callback_info write_info; + grpc_winsocket_callback_info read_info; + + gpr_mu state_mu; + bool shutdown_called; + + /* You can't add the same socket twice to the same IO Completion Port. + This prevents that. */ + int added_to_iocp; + + grpc_closure shutdown_closure; + + /* A label for iomgr to track outstanding objects */ + grpc_iomgr_object iomgr_object; +} grpc_winsocket; + +/* Create a wrapped windows handle. This takes ownership of it, meaning that + it will be responsible for closing it. */ grpc_winsocket* grpc_winsocket_create(SOCKET socket, const char* name); - + SOCKET grpc_winsocket_wrapped_socket(grpc_winsocket* socket); -/* Initiate an asynchronous shutdown of the socket. Will call off any pending - operation to cancel them. */ +/* Initiate an asynchronous shutdown of the socket. Will call off any pending + operation to cancel them. */ void grpc_winsocket_shutdown(grpc_winsocket* socket); - -/* Destroy a socket. Should only be called if there's no pending operation. */ + +/* Destroy a socket. Should only be called if there's no pending operation. */ void grpc_winsocket_destroy(grpc_winsocket* socket); - + void grpc_socket_notify_on_write(grpc_winsocket* winsocket, grpc_closure* closure); - + void grpc_socket_notify_on_read(grpc_winsocket* winsocket, grpc_closure* closure); - + void grpc_socket_become_ready(grpc_winsocket* winsocket, grpc_winsocket_callback_info* ci); - + /* Returns true if this system can create AF_INET6 sockets bound to ::1. The value is probed once, and cached for the life of the process. */ int grpc_ipv6_loopback_available(void); @@ -124,4 +124,4 @@ DWORD grpc_get_default_wsa_socket_flags(); #endif -#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_SOCKET_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client.h index d209eeb8c2..0197d15954 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client.h @@ -1,52 +1,52 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H -#define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H +#define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H + #include <grpc/support/port_platform.h> -#include <grpc/impl/codegen/grpc_types.h> -#include <grpc/support/time.h> -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/pollset_set.h" -#include "src/core/lib/iomgr/resolve_address.h" - +#include <grpc/impl/codegen/grpc_types.h> +#include <grpc/support/time.h> +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/pollset_set.h" +#include "src/core/lib/iomgr/resolve_address.h" + typedef struct grpc_tcp_client_vtable { void (*connect)(grpc_closure* on_connect, grpc_endpoint** endpoint, grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args, const grpc_resolved_address* addr, grpc_millis deadline); } grpc_tcp_client_vtable; - -/* Asynchronously connect to an address (specified as (addr, len)), and call - cb with arg and the completed connection when done (or call cb with arg and - NULL on failure). - interested_parties points to a set of pollsets that would be interested - in this connection being established (in order to continue their work) */ + +/* Asynchronously connect to an address (specified as (addr, len)), and call + cb with arg and the completed connection when done (or call cb with arg and + NULL on failure). + interested_parties points to a set of pollsets that would be interested + in this connection being established (in order to continue their work) */ void grpc_tcp_client_connect(grpc_closure* on_connect, grpc_endpoint** endpoint, grpc_pollset_set* interested_parties, const grpc_channel_args* channel_args, const grpc_resolved_address* addr, grpc_millis deadline); - + void grpc_tcp_client_global_init(); void grpc_set_tcp_client_impl(grpc_tcp_client_vtable* impl); -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h index 6f61866fc4..26d64b0c62 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_client_posix.h @@ -1,32 +1,32 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H -#define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H +#define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/ev_posix.h" -#include "src/core/lib/iomgr/tcp_client.h" - +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/ev_posix.h" +#include "src/core/lib/iomgr/tcp_client.h" + /* Create an endpoint from a connected grpc_fd. - + fd: a connected FD. Ownership is taken. channel_args: may contain custom settings for the endpoint addr_str: destination address in printable format @@ -65,4 +65,4 @@ void grpc_tcp_client_create_from_prepared_fd( const grpc_channel_args* channel_args, const grpc_resolved_address* addr, grpc_millis deadline, grpc_endpoint** ep); -#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ +#endif /* GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.h index eff825cb92..5821198f99 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_posix.h @@ -1,60 +1,60 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TCP_POSIX_H -#define GRPC_CORE_LIB_IOMGR_TCP_POSIX_H -/* - Low level TCP "bottom half" implementation, for use by transports built on - top of a TCP connection. - - Note that this file does not (yet) include APIs for creating the socket in - the first place. - - All calls passing slice transfer ownership of a slice refcount unless - otherwise specified. -*/ - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TCP_POSIX_H +#define GRPC_CORE_LIB_IOMGR_TCP_POSIX_H +/* + Low level TCP "bottom half" implementation, for use by transports built on + top of a TCP connection. + + Note that this file does not (yet) include APIs for creating the socket in + the first place. + + All calls passing slice transfer ownership of a slice refcount unless + otherwise specified. +*/ + #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/iomgr/buffer_list.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/ev_posix.h" - +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/ev_posix.h" + extern grpc_core::TraceFlag grpc_tcp_trace; - -/* Create a tcp endpoint given a file desciptor and a read slice size. - Takes ownership of fd. */ + +/* Create a tcp endpoint given a file desciptor and a read slice size. + Takes ownership of fd. */ grpc_endpoint* grpc_tcp_create(grpc_fd* fd, const grpc_channel_args* args, const char* peer_string); - -/* Return the tcp endpoint's fd, or -1 if this is not available. Does not - release the fd. - Requires: ep must be a tcp endpoint. - */ + +/* Return the tcp endpoint's fd, or -1 if this is not available. Does not + release the fd. + Requires: ep must be a tcp endpoint. + */ int grpc_tcp_fd(grpc_endpoint* ep); - -/* Destroy the tcp endpoint without closing its fd. *fd will be set and done - * will be called when the endpoint is destroyed. - * Requires: ep must be a tcp endpoint and fd must not be NULL. */ + +/* Destroy the tcp endpoint without closing its fd. *fd will be set and done + * will be called when the endpoint is destroyed. + * Requires: ep must be a tcp endpoint and fd must not be NULL. */ void grpc_tcp_destroy_and_release_fd(grpc_endpoint* ep, int* fd, grpc_closure* done); - -#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_TCP_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h index 6ba3513da5..31abe0ffde 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_server.h @@ -1,53 +1,53 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TCP_SERVER_H -#define GRPC_CORE_LIB_IOMGR_TCP_SERVER_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TCP_SERVER_H +#define GRPC_CORE_LIB_IOMGR_TCP_SERVER_H + #include <grpc/support/port_platform.h> -#include <grpc/grpc.h> +#include <grpc/grpc.h> #include <grpc/impl/codegen/grpc_types.h> - + #include <vector> -#include "src/core/lib/iomgr/closure.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/resolve_address.h" - -/* Forward decl of grpc_tcp_server */ -typedef struct grpc_tcp_server grpc_tcp_server; - -typedef struct grpc_tcp_server_acceptor { - /* grpc_tcp_server_cb functions share a ref on from_server that is valid - until the function returns. */ +#include "src/core/lib/iomgr/closure.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/resolve_address.h" + +/* Forward decl of grpc_tcp_server */ +typedef struct grpc_tcp_server grpc_tcp_server; + +typedef struct grpc_tcp_server_acceptor { + /* grpc_tcp_server_cb functions share a ref on from_server that is valid + until the function returns. */ grpc_tcp_server* from_server; - /* Indices that may be passed to grpc_tcp_server_port_fd(). */ - unsigned port_index; - unsigned fd_index; + /* Indices that may be passed to grpc_tcp_server_port_fd(). */ + unsigned port_index; + unsigned fd_index; /* Data when the connection is passed to tcp_server from external. */ bool external_connection; int listener_fd; grpc_byte_buffer* pending_data; -} grpc_tcp_server_acceptor; - -/* Called for newly connected TCP connections. - Takes ownership of acceptor. */ +} grpc_tcp_server_acceptor; + +/* Called for newly connected TCP connections. + Takes ownership of acceptor. */ typedef void (*grpc_tcp_server_cb)(void* arg, grpc_endpoint* ep, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor); @@ -61,7 +61,7 @@ class TcpServerFdHandler { grpc_byte_buffer* pending_read) = 0; }; } // namespace grpc_core - + typedef struct grpc_tcp_server_vtable { grpc_error* (*create)(grpc_closure* shutdown_complete, const grpc_channel_args* args, @@ -81,65 +81,65 @@ typedef struct grpc_tcp_server_vtable { void (*shutdown_listeners)(grpc_tcp_server* s); } grpc_tcp_server_vtable; -/* Create a server, initially not bound to any ports. The caller owns one ref. - If shutdown_complete is not NULL, it will be used by - grpc_tcp_server_unref() when the ref count reaches zero. */ +/* Create a server, initially not bound to any ports. The caller owns one ref. + If shutdown_complete is not NULL, it will be used by + grpc_tcp_server_unref() when the ref count reaches zero. */ grpc_error* grpc_tcp_server_create(grpc_closure* shutdown_complete, const grpc_channel_args* args, grpc_tcp_server** server); - -/* Start listening to bound ports */ + +/* Start listening to bound ports */ void grpc_tcp_server_start(grpc_tcp_server* server, const std::vector<grpc_pollset*>* pollsets, grpc_tcp_server_cb on_accept_cb, void* cb_arg); - -/* Add a port to the server, returning the newly allocated port on success, or - -1 on failure. - - The :: and 0.0.0.0 wildcard addresses are treated identically, accepting - both IPv4 and IPv6 connections, but :: is the preferred style. This usually - creates one socket, but possibly two on systems which support IPv6, - but not dualstack sockets. */ -/* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle - all of the multiple socket port matching logic in one place */ + +/* Add a port to the server, returning the newly allocated port on success, or + -1 on failure. + + The :: and 0.0.0.0 wildcard addresses are treated identically, accepting + both IPv4 and IPv6 connections, but :: is the preferred style. This usually + creates one socket, but possibly two on systems which support IPv6, + but not dualstack sockets. */ +/* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle + all of the multiple socket port matching logic in one place */ grpc_error* grpc_tcp_server_add_port(grpc_tcp_server* s, const grpc_resolved_address* addr, int* out_port); - + /* Create and return a TcpServerFdHandler so that it can be used by upper layer to hand over an externally connected fd to the grpc server. */ grpc_core::TcpServerFdHandler* grpc_tcp_server_create_fd_handler( grpc_tcp_server* s); -/* Number of fds at the given port_index, or 0 if port_index is out of - bounds. */ +/* Number of fds at the given port_index, or 0 if port_index is out of + bounds. */ unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server* s, unsigned port_index); - -/* Returns the file descriptor of the Mth (fd_index) listening socket of the Nth - (port_index) call to add_port() on this server, or -1 if the indices are out - of bounds. The file descriptor remains owned by the server, and will be - cleaned up when the ref count reaches zero. */ + +/* Returns the file descriptor of the Mth (fd_index) listening socket of the Nth + (port_index) call to add_port() on this server, or -1 if the indices are out + of bounds. The file descriptor remains owned by the server, and will be + cleaned up when the ref count reaches zero. */ int grpc_tcp_server_port_fd(grpc_tcp_server* s, unsigned port_index, - unsigned fd_index); - -/* Ref s and return s. */ + unsigned fd_index); + +/* Ref s and return s. */ grpc_tcp_server* grpc_tcp_server_ref(grpc_tcp_server* s); - -/* shutdown_starting is called when ref count has reached zero and the server is - about to be destroyed. The server will be deleted after it returns. Calling - grpc_tcp_server_ref() from it has no effect. */ + +/* shutdown_starting is called when ref count has reached zero and the server is + about to be destroyed. The server will be deleted after it returns. Calling + grpc_tcp_server_ref() from it has no effect. */ void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server* s, grpc_closure* shutdown_starting); - -/* If the refcount drops to zero, enqueue calls on exec_ctx to - shutdown_listeners and delete s. */ + +/* If the refcount drops to zero, enqueue calls on exec_ctx to + shutdown_listeners and delete s. */ void grpc_tcp_server_unref(grpc_tcp_server* s); - -/* Shutdown the fds of listeners. */ + +/* Shutdown the fds of listeners. */ void grpc_tcp_server_shutdown_listeners(grpc_tcp_server* s); - + void grpc_tcp_server_global_init(); void grpc_set_tcp_server_impl(grpc_tcp_server_vtable* impl); -#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ +#endif /* GRPC_CORE_LIB_IOMGR_TCP_SERVER_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.h b/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.h index 04ef8102b6..aa5e8de735 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/tcp_windows.h @@ -1,53 +1,53 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H -#define GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H -/* - Low level TCP "bottom half" implementation, for use by transports built on - top of a TCP connection. - - Note that this file does not (yet) include APIs for creating the socket in - the first place. - - All calls passing slice transfer ownership of a slice refcount unless - otherwise specified. -*/ - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H +#define GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H +/* + Low level TCP "bottom half" implementation, for use by transports built on + top of a TCP connection. + + Note that this file does not (yet) include APIs for creating the socket in + the first place. + + All calls passing slice transfer ownership of a slice refcount unless + otherwise specified. +*/ + #include <grpc/support/port_platform.h> #include "src/core/lib/iomgr/port.h" #ifdef GRPC_WINSOCK_SOCKET -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/socket_windows.h" - -/* Create a tcp endpoint given a winsock handle. - * Takes ownership of the handle. - */ +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/socket_windows.h" + +/* Create a tcp endpoint given a winsock handle. + * Takes ownership of the handle. + */ grpc_endpoint* grpc_tcp_create(grpc_winsocket* socket, grpc_channel_args* channel_args, const char* peer_string); - + grpc_error* grpc_tcp_prepare_socket(SOCKET sock); - + grpc_error* grpc_tcp_set_non_block(SOCKET sock); #endif -#endif /* GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H */ +#endif /* GRPC_CORE_LIB_IOMGR_TCP_WINDOWS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/time_averaged_stats.h b/contrib/libs/grpc/src/core/lib/iomgr/time_averaged_stats.h index 877d1bec0e..1a4688d136 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/time_averaged_stats.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/time_averaged_stats.h @@ -1,72 +1,72 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H -#define GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H - -/* This tracks a time-decaying weighted average. It works by collecting - batches of samples and then mixing their average into a time-decaying - weighted mean. It is designed for batch operations where we do many adds - before updating the average. */ - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H +#define GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H + +/* This tracks a time-decaying weighted average. It works by collecting + batches of samples and then mixing their average into a time-decaying + weighted mean. It is designed for batch operations where we do many adds + before updating the average. */ + struct grpc_time_averaged_stats { - /* The initial average value. This is the reported average until the first - grpc_time_averaged_stats_update_average call. If a positive regress_weight - is used, we also regress towards this value on each update. */ - double init_avg; - /* The sample weight of "init_avg" that is mixed in with each call to - grpc_time_averaged_stats_update_average. If the calls to - grpc_time_averaged_stats_add_sample stop, this will cause the average to - regress back to the mean. This should be non-negative. Set it to 0 to - disable the bias. A value of 1 has the effect of adding in 1 bonus sample - with value init_avg to each sample period. */ - double regress_weight; - /* This determines the rate of decay of the time-averaging from one period - to the next by scaling the aggregate_total_weight of samples from prior - periods when combining with the latest period. It should be in the range - [0,1]. A higher value adapts more slowly. With a value of 0.5, if the - batches each have k samples, the samples_in_avg_ will grow to 2 k, so the - weighting of the time average will eventually be 1/3 new batch and 2/3 - old average. */ - double persistence_factor; - - /* The total value of samples since the last UpdateAverage(). */ - double batch_total_value; - /* The number of samples since the last UpdateAverage(). */ - double batch_num_samples; - /* The time-decayed sum of batch_num_samples_ over previous batches. This is - the "weight" of the old aggregate_weighted_avg_ when updating the - average. */ - double aggregate_total_weight; - /* A time-decayed average of the (batch_total_value_ / batch_num_samples_), - computed by decaying the samples_in_avg_ weight in the weighted average. */ - double aggregate_weighted_avg; + /* The initial average value. This is the reported average until the first + grpc_time_averaged_stats_update_average call. If a positive regress_weight + is used, we also regress towards this value on each update. */ + double init_avg; + /* The sample weight of "init_avg" that is mixed in with each call to + grpc_time_averaged_stats_update_average. If the calls to + grpc_time_averaged_stats_add_sample stop, this will cause the average to + regress back to the mean. This should be non-negative. Set it to 0 to + disable the bias. A value of 1 has the effect of adding in 1 bonus sample + with value init_avg to each sample period. */ + double regress_weight; + /* This determines the rate of decay of the time-averaging from one period + to the next by scaling the aggregate_total_weight of samples from prior + periods when combining with the latest period. It should be in the range + [0,1]. A higher value adapts more slowly. With a value of 0.5, if the + batches each have k samples, the samples_in_avg_ will grow to 2 k, so the + weighting of the time average will eventually be 1/3 new batch and 2/3 + old average. */ + double persistence_factor; + + /* The total value of samples since the last UpdateAverage(). */ + double batch_total_value; + /* The number of samples since the last UpdateAverage(). */ + double batch_num_samples; + /* The time-decayed sum of batch_num_samples_ over previous batches. This is + the "weight" of the old aggregate_weighted_avg_ when updating the + average. */ + double aggregate_total_weight; + /* A time-decayed average of the (batch_total_value_ / batch_num_samples_), + computed by decaying the samples_in_avg_ weight in the weighted average. */ + double aggregate_weighted_avg; }; -/* See the comments on the members above for an explanation of init_avg, - regress_weight, and persistence_factor. */ -void grpc_time_averaged_stats_init(grpc_time_averaged_stats* stats, - double init_avg, double regress_weight, - double persistence_factor); -/* Add a sample to the current batch. */ -void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats* stats, - double value); -/* Complete a batch and compute the new estimate of the average sample - value. */ -double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats); - -#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ +/* See the comments on the members above for an explanation of init_avg, + regress_weight, and persistence_factor. */ +void grpc_time_averaged_stats_init(grpc_time_averaged_stats* stats, + double init_avg, double regress_weight, + double persistence_factor); +/* Add a sample to the current batch. */ +void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats* stats, + double value); +/* Complete a batch and compute the new estimate of the average sample + value. */ +double grpc_time_averaged_stats_update_average(grpc_time_averaged_stats* stats); + +#endif /* GRPC_CORE_LIB_IOMGR_TIME_AVERAGED_STATS_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/timer.h b/contrib/libs/grpc/src/core/lib/iomgr/timer.h index 11da149652..3fe0be99de 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/timer.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/timer.h @@ -1,32 +1,32 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TIMER_H -#define GRPC_CORE_LIB_IOMGR_TIMER_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TIMER_H +#define GRPC_CORE_LIB_IOMGR_TIMER_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/port.h" - -#include <grpc/support/time.h> -#include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/iomgr/iomgr.h" - +#include "src/core/lib/iomgr/port.h" + +#include <grpc/support/time.h> +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/iomgr.h" + typedef struct grpc_timer { grpc_millis deadline; // Uninitialized if not using heap, or INVALID_HEAP_INDEX if not in heap. @@ -38,7 +38,7 @@ typedef struct grpc_timer { #ifndef NDEBUG struct grpc_timer* hash_table_next; #endif - + // Optional field used by custom timers void* custom_timer; } grpc_timer; @@ -60,68 +60,68 @@ typedef struct grpc_timer_vtable { void (*consume_kick)(void); } grpc_timer_vtable; -/* Initialize *timer. When expired or canceled, closure will be called with - error set to indicate if it expired (GRPC_ERROR_NONE) or was canceled +/* Initialize *timer. When expired or canceled, closure will be called with + error set to indicate if it expired (GRPC_ERROR_NONE) or was canceled (GRPC_ERROR_CANCELLED). *closure is guaranteed to be called exactly once, and - application code should check the error to determine how it was invoked. The - application callback is also responsible for maintaining information about + application code should check the error to determine how it was invoked. The + application callback is also responsible for maintaining information about when to free up any user-level state. Behavior is undefined for a deadline of GRPC_MILLIS_INF_FUTURE. */ void grpc_timer_init(grpc_timer* timer, grpc_millis deadline, grpc_closure* closure); - + /* Initialize *timer without setting it. This can later be passed through the regular init or cancel */ void grpc_timer_init_unset(grpc_timer* timer); -/* Note that there is no timer destroy function. This is because the - timer is a one-time occurrence with a guarantee that the callback will - be called exactly once, either at expiration or cancellation. Thus, all - the internal timer event management state is destroyed just before - that callback is invoked. If the user has additional state associated with - the timer, the user is responsible for determining when it is safe to - destroy that state. */ - -/* Cancel an *timer. - There are three cases: - 1. We normally cancel the timer - 2. The timer has already run - 3. We can't cancel the timer because it is "in flight". - - In all of these cases, the cancellation is still considered successful. - They are essentially distinguished in that the timer_cb will be run - exactly once from either the cancellation (with error GRPC_ERROR_CANCELLED) - or from the activation (with error GRPC_ERROR_NONE). - - Note carefully that the callback function MAY occur in the same callstack - as grpc_timer_cancel. It's expected that most timers will be cancelled (their - primary use is to implement deadlines), and so this code is optimized such - that cancellation costs as little as possible. Making callbacks run inline - matches this aim. - - Requires: cancel() must happen after init() on a given timer */ +/* Note that there is no timer destroy function. This is because the + timer is a one-time occurrence with a guarantee that the callback will + be called exactly once, either at expiration or cancellation. Thus, all + the internal timer event management state is destroyed just before + that callback is invoked. If the user has additional state associated with + the timer, the user is responsible for determining when it is safe to + destroy that state. */ + +/* Cancel an *timer. + There are three cases: + 1. We normally cancel the timer + 2. The timer has already run + 3. We can't cancel the timer because it is "in flight". + + In all of these cases, the cancellation is still considered successful. + They are essentially distinguished in that the timer_cb will be run + exactly once from either the cancellation (with error GRPC_ERROR_CANCELLED) + or from the activation (with error GRPC_ERROR_NONE). + + Note carefully that the callback function MAY occur in the same callstack + as grpc_timer_cancel. It's expected that most timers will be cancelled (their + primary use is to implement deadlines), and so this code is optimized such + that cancellation costs as little as possible. Making callbacks run inline + matches this aim. + + Requires: cancel() must happen after init() on a given timer */ void grpc_timer_cancel(grpc_timer* timer); - -/* iomgr internal api for dealing with timers */ - -/* Check for timers to be run, and run them. - Return true if timer callbacks were executed. - If next is non-null, TRY to update *next with the next running timer - IF that timer occurs before *next current value. - *next is never guaranteed to be updated on any given execution; however, - with high probability at least one thread in the system will see an update - at any time slice. */ + +/* iomgr internal api for dealing with timers */ + +/* Check for timers to be run, and run them. + Return true if timer callbacks were executed. + If next is non-null, TRY to update *next with the next running timer + IF that timer occurs before *next current value. + *next is never guaranteed to be updated on any given execution; however, + with high probability at least one thread in the system will see an update + at any time slice. */ grpc_timer_check_result grpc_timer_check(grpc_millis* next); void grpc_timer_list_init(); void grpc_timer_list_shutdown(); - + /* Consume a kick issued by grpc_kick_poller */ void grpc_timer_consume_kick(void); -/* the following must be implemented by each iomgr implementation */ -void grpc_kick_poller(void); - +/* the following must be implemented by each iomgr implementation */ +void grpc_kick_poller(void); + /* Sets the timer implementation */ void grpc_set_timer_impl(grpc_timer_vtable* vtable); -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_H */ +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h b/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h index 97a4513355..b5ee254473 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/timer_generic.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H -#define GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H +#define GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H + #include <grpc/support/port_platform.h> -#include <grpc/support/time.h> -#include "src/core/lib/iomgr/exec_ctx.h" - -struct grpc_timer { +#include <grpc/support/time.h> +#include "src/core/lib/iomgr/exec_ctx.h" + +struct grpc_timer { gpr_atm deadline; - uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */ + uint32_t heap_index; /* INVALID_HEAP_INDEX if not in heap */ bool pending; struct grpc_timer* next; struct grpc_timer* prev; @@ -34,6 +34,6 @@ struct grpc_timer { #ifndef NDEBUG struct grpc_timer* hash_table_next; #endif -}; - -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H */ +}; + +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_GENERIC_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/timer_heap.h b/contrib/libs/grpc/src/core/lib/iomgr/timer_heap.h index 2b08c65108..e8ea01db48 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/timer_heap.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/timer_heap.h @@ -1,43 +1,43 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H -#define GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H +#define GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/timer.h" - +#include "src/core/lib/iomgr/timer.h" + struct grpc_timer_heap { grpc_timer** timers; - uint32_t timer_count; - uint32_t timer_capacity; + uint32_t timer_count; + uint32_t timer_capacity; }; /* return true if the new timer is the first timer in the heap */ bool grpc_timer_heap_add(grpc_timer_heap* heap, grpc_timer* timer); - + void grpc_timer_heap_init(grpc_timer_heap* heap); void grpc_timer_heap_destroy(grpc_timer_heap* heap); - + void grpc_timer_heap_remove(grpc_timer_heap* heap, grpc_timer* timer); grpc_timer* grpc_timer_heap_top(grpc_timer_heap* heap); void grpc_timer_heap_pop(grpc_timer_heap* heap); - + bool grpc_timer_heap_is_empty(grpc_timer_heap* heap); - -#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h index 6cda332a5b..8ba3680c71 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/udp_server.h @@ -1,39 +1,39 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_UDP_SERVER_H -#define GRPC_CORE_LIB_IOMGR_UDP_SERVER_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_UDP_SERVER_H +#define GRPC_CORE_LIB_IOMGR_UDP_SERVER_H + #include <grpc/support/port_platform.h> #include <vector> -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/ev_posix.h" -#include "src/core/lib/iomgr/resolve_address.h" - -/* Forward decl of struct grpc_server */ -/* This is not typedef'ed to avoid a typedef-redefinition error */ -struct grpc_server; - -/* Forward decl of grpc_udp_server */ -typedef struct grpc_udp_server grpc_udp_server; - +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/ev_posix.h" +#include "src/core/lib/iomgr/resolve_address.h" + +/* Forward decl of struct grpc_server */ +/* This is not typedef'ed to avoid a typedef-redefinition error */ +struct grpc_server; + +/* Forward decl of grpc_udp_server */ +typedef struct grpc_udp_server grpc_udp_server; + /* An interface associated with a socket. udp server delivers I/O event on that * socket to the subclass of this interface which is created through * GrpcUdpHandlerFactory. @@ -42,10 +42,10 @@ class GrpcUdpHandler { public: GrpcUdpHandler(grpc_fd* /* emfd */, void* /* user_data */) {} virtual ~GrpcUdpHandler() {} - + // Interfaces to be implemented by subclasses to do the actual setup/tear down // or I/O. - + // Called when data is available to read from the socket. Returns true if // there is more data to read after this call. virtual bool Read() = 0; @@ -70,35 +70,35 @@ class GrpcUdpHandlerFactory { virtual void DestroyUdpHandler(GrpcUdpHandler* handler) = 0; }; -/* Create a server, initially not bound to any ports */ +/* Create a server, initially not bound to any ports */ grpc_udp_server* grpc_udp_server_create(const grpc_channel_args* args); - + /* Start listening to bound ports. user_data is passed to callbacks. */ void grpc_udp_server_start(grpc_udp_server* udp_server, const std::vector<grpc_pollset*>* pollsets, void* user_data); - + int grpc_udp_server_get_fd(grpc_udp_server* s, unsigned port_index); - -/* Add a port to the server, returning port number on success, or negative - on failure. - + +/* Add a port to the server, returning port number on success, or negative + on failure. + Create |num_listeners| sockets for given address to listen on using SO_REUSEPORT if supported. - The :: and 0.0.0.0 wildcard addresses are treated identically, accepting + The :: and 0.0.0.0 wildcard addresses are treated identically, accepting both IPv4 and IPv6 connections, but :: is the preferred style. This usually creates |num_listeners| sockets, but possibly 2 * |num_listeners| on systems which support IPv6, but not dualstack sockets. */ - -/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle - all of the multiple socket port matching logic in one place */ + +/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle + all of the multiple socket port matching logic in one place */ int grpc_udp_server_add_port(grpc_udp_server* s, const grpc_resolved_address* addr, int rcv_buf_size, int snd_buf_size, GrpcUdpHandlerFactory* handler_factory, size_t num_listeners); - + void grpc_udp_server_destroy(grpc_udp_server* server, grpc_closure* on_done); - -#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_UDP_SERVER_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h index 962adde71c..648d6ee01a 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/unix_sockets_posix.h @@ -1,45 +1,45 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H -#define GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H +#define GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> -#include "src/core/lib/iomgr/port.h" - -#include <grpc/support/string_util.h> - -#include "src/core/lib/iomgr/resolve_address.h" - -void grpc_create_socketpair_if_unix(int sv[2]); - +#include "src/core/lib/iomgr/port.h" + +#include <grpc/support/string_util.h> + +#include "src/core/lib/iomgr/resolve_address.h" + +void grpc_create_socketpair_if_unix(int sv[2]); + grpc_error* grpc_resolve_unix_domain_address( const char* name, grpc_resolved_addresses** addresses); - + int grpc_is_unix_socket(const grpc_resolved_address* resolved_addr); - -void grpc_unlink_if_unix_domain_socket( + +void grpc_unlink_if_unix_domain_socket( const grpc_resolved_address* resolved_addr); - + TString grpc_sockaddr_to_uri_unix_if_possible( const grpc_resolved_address* resolved_addr); - -#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_UNIX_SOCKETS_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_pipe.h b/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_pipe.h index 1756976305..808a808e85 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_pipe.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_pipe.h @@ -1,28 +1,28 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H -#define GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H - + * + */ + +#ifndef GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H +#define GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/wakeup_fd_posix.h" - +#include "src/core/lib/iomgr/wakeup_fd_posix.h" + extern const grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable; - -#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H */ + +#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_PIPE_H */ diff --git a/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_posix.h b/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_posix.h index 670c319593..f6832a1d33 100644 --- a/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_posix.h +++ b/contrib/libs/grpc/src/core/lib/iomgr/wakeup_fd_posix.h @@ -1,96 +1,96 @@ -/* - * +/* + * * 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. - * - */ - -/* - * wakeup_fd abstracts the concept of a file descriptor for the purpose of - * waking up a thread in select()/poll()/epoll_wait()/etc. - - * The poll() family of system calls provide a way for a thread to block until - * there is activity on one (or more) of a set of file descriptors. An - * application may wish to wake up this thread to do non file related work. The - * typical way to do this is to add a pipe to the set of file descriptors, then - * write to the pipe to wake up the thread in poll(). - * - * Linux has a lighter weight eventfd specifically designed for this purpose. - * wakeup_fd abstracts the difference between the two. - * - * Setup: - * 1. Before calling anything, call global_init() at least once. + * + */ + +/* + * wakeup_fd abstracts the concept of a file descriptor for the purpose of + * waking up a thread in select()/poll()/epoll_wait()/etc. + + * The poll() family of system calls provide a way for a thread to block until + * there is activity on one (or more) of a set of file descriptors. An + * application may wish to wake up this thread to do non file related work. The + * typical way to do this is to add a pipe to the set of file descriptors, then + * write to the pipe to wake up the thread in poll(). + * + * Linux has a lighter weight eventfd specifically designed for this purpose. + * wakeup_fd abstracts the difference between the two. + * + * Setup: + * 1. Before calling anything, call global_init() at least once. * 1. Call grpc_wakeup_fd_init() to set up a wakeup_fd. - * 2. Add the result of GRPC_WAKEUP_FD_FD to the set of monitored file - * descriptors for the poll() style API you are using. Monitor the file - * descriptor for readability. - * 3. To tear down, call grpc_wakeup_fd_destroy(). This closes the underlying - * file descriptor. - * - * Usage: - * 1. To wake up a polling thread, call grpc_wakeup_fd_wakeup() on a wakeup_fd - * it is monitoring. - * 2. If the polling thread was awakened by a wakeup_fd event, call - * grpc_wakeup_fd_consume_wakeup() on it. - */ -#ifndef GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H -#define GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H - + * 2. Add the result of GRPC_WAKEUP_FD_FD to the set of monitored file + * descriptors for the poll() style API you are using. Monitor the file + * descriptor for readability. + * 3. To tear down, call grpc_wakeup_fd_destroy(). This closes the underlying + * file descriptor. + * + * Usage: + * 1. To wake up a polling thread, call grpc_wakeup_fd_wakeup() on a wakeup_fd + * it is monitoring. + * 2. If the polling thread was awakened by a wakeup_fd event, call + * grpc_wakeup_fd_consume_wakeup() on it. + */ +#ifndef GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H +#define GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/error.h" - -void grpc_wakeup_fd_global_init(void); -void grpc_wakeup_fd_global_destroy(void); - -/* Force using the fallback implementation. This is intended for testing - * purposes only.*/ -void grpc_wakeup_fd_global_init_force_fallback(void); - -int grpc_has_wakeup_fd(void); -int grpc_cv_wakeup_fds_enabled(void); -void grpc_enable_cv_wakeup_fds(int enable); - -typedef struct grpc_wakeup_fd grpc_wakeup_fd; - -typedef struct grpc_wakeup_fd_vtable { - grpc_error* (*init)(grpc_wakeup_fd* fd_info); - grpc_error* (*consume)(grpc_wakeup_fd* fd_info); - grpc_error* (*wakeup)(grpc_wakeup_fd* fd_info); - void (*destroy)(grpc_wakeup_fd* fd_info); - /* Must be called before calling any other functions */ - int (*check_availability)(void); -} grpc_wakeup_fd_vtable; - -struct grpc_wakeup_fd { - int read_fd; - int write_fd; -}; - -extern int grpc_allow_specialized_wakeup_fd; -extern int grpc_allow_pipe_wakeup_fd; - -#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd) - -grpc_error* grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT; -grpc_error* grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info) - GRPC_MUST_USE_RESULT; -grpc_error* grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT; -void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info); - -/* Defined in some specialized implementation's .c file, or by - * wakeup_fd_nospecial.c if no such implementation exists. */ -extern const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable; - -#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H */ +#include "src/core/lib/iomgr/error.h" + +void grpc_wakeup_fd_global_init(void); +void grpc_wakeup_fd_global_destroy(void); + +/* Force using the fallback implementation. This is intended for testing + * purposes only.*/ +void grpc_wakeup_fd_global_init_force_fallback(void); + +int grpc_has_wakeup_fd(void); +int grpc_cv_wakeup_fds_enabled(void); +void grpc_enable_cv_wakeup_fds(int enable); + +typedef struct grpc_wakeup_fd grpc_wakeup_fd; + +typedef struct grpc_wakeup_fd_vtable { + grpc_error* (*init)(grpc_wakeup_fd* fd_info); + grpc_error* (*consume)(grpc_wakeup_fd* fd_info); + grpc_error* (*wakeup)(grpc_wakeup_fd* fd_info); + void (*destroy)(grpc_wakeup_fd* fd_info); + /* Must be called before calling any other functions */ + int (*check_availability)(void); +} grpc_wakeup_fd_vtable; + +struct grpc_wakeup_fd { + int read_fd; + int write_fd; +}; + +extern int grpc_allow_specialized_wakeup_fd; +extern int grpc_allow_pipe_wakeup_fd; + +#define GRPC_WAKEUP_FD_GET_READ_FD(fd_info) ((fd_info)->read_fd) + +grpc_error* grpc_wakeup_fd_init(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT; +grpc_error* grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd* fd_info) + GRPC_MUST_USE_RESULT; +grpc_error* grpc_wakeup_fd_wakeup(grpc_wakeup_fd* fd_info) GRPC_MUST_USE_RESULT; +void grpc_wakeup_fd_destroy(grpc_wakeup_fd* fd_info); + +/* Defined in some specialized implementation's .c file, or by + * wakeup_fd_nospecial.c if no such implementation exists. */ +extern const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable; + +#endif /* GRPC_CORE_LIB_IOMGR_WAKEUP_FD_POSIX_H */ diff --git a/contrib/libs/grpc/src/core/lib/json/json.h b/contrib/libs/grpc/src/core/lib/json/json.h index f426fbf1dd..32dea4bacc 100644 --- a/contrib/libs/grpc/src/core/lib/json/json.h +++ b/contrib/libs/grpc/src/core/lib/json/json.h @@ -1,37 +1,37 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_JSON_JSON_H -#define GRPC_CORE_LIB_JSON_JSON_H - + * + */ + +#ifndef GRPC_CORE_LIB_JSON_JSON_H +#define GRPC_CORE_LIB_JSON_JSON_H + #include <grpc/support/port_platform.h> -#include <stdlib.h> - +#include <stdlib.h> + #include <map> #include <util/generic/string.h> #include <util/string/cast.h> #include <vector> - + #include "y_absl/strings/string_view.h" #include "src/core/lib/iomgr/error.h" - + namespace grpc_core { // A JSON value, which can be any one of object, array, string, @@ -52,15 +52,15 @@ class Json { OBJECT, ARRAY }; - + using Object = std::map<TString, Json>; using Array = std::vector<Json>; - + // Parses JSON string from json_str. On error, sets *error. static Json Parse(y_absl::string_view json_str, grpc_error** error); - + Json() = default; - + // Copyable. Json(const Json& other) { CopyFrom(other); } Json& operator=(const Json& other) { @@ -238,4 +238,4 @@ class Json { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_JSON_JSON_H */ +#endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d b/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d index 153de91752..30f17e0899 100644 --- a/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d +++ b/contrib/libs/grpc/src/core/lib/profiling/stap_probes.d @@ -1,7 +1,7 @@ -provider _stap { - probe add_mark(int tag); - probe add_important_mark(int tag); - probe timing_ns_begin(int tag); - probe timing_ns_end(int tag); -}; - +provider _stap { + probe add_mark(int tag); + probe add_important_mark(int tag); + probe timing_ns_begin(int tag); + probe timing_ns_end(int tag); +}; + diff --git a/contrib/libs/grpc/src/core/lib/profiling/timers.h b/contrib/libs/grpc/src/core/lib/profiling/timers.h index 7ff72783ec..4448c3564d 100644 --- a/contrib/libs/grpc/src/core/lib/profiling/timers.h +++ b/contrib/libs/grpc/src/core/lib/profiling/timers.h @@ -1,94 +1,94 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_PROFILING_TIMERS_H -#define GRPC_CORE_LIB_PROFILING_TIMERS_H - -void gpr_timers_global_init(void); -void gpr_timers_global_destroy(void); - + * + */ + +#ifndef GRPC_CORE_LIB_PROFILING_TIMERS_H +#define GRPC_CORE_LIB_PROFILING_TIMERS_H + +void gpr_timers_global_init(void); +void gpr_timers_global_destroy(void); + void gpr_timer_add_mark(const char* tagstr, int important, const char* file, - int line); + int line); void gpr_timer_begin(const char* tagstr, int important, const char* file, - int line); + int line); void gpr_timer_end(const char* tagstr, int important, const char* file, - int line); - + int line); + void gpr_timers_set_log_filename(const char* filename); - -void gpr_timer_set_enabled(int enabled); - + +void gpr_timer_set_enabled(int enabled); + #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER) + \ defined(GRPC_CUSTOM_PROFILER)) -/* No profiling. No-op all the things. */ -#define GPR_TIMER_MARK(tag, important) \ - do { \ - } while (0) - +/* No profiling. No-op all the things. */ +#define GPR_TIMER_MARK(tag, important) \ + do { \ + } while (0) + #define GPR_TIMER_SCOPE(tag, important) \ - do { \ - } while (0) - -#else /* at least one profiler requested... */ -/* ... hopefully only one. */ -#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER) -#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive." -#endif + do { \ + } while (0) + +#else /* at least one profiler requested... */ +/* ... hopefully only one. */ +#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER) +#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive." +#endif #if defined(GRPC_STAP_PROFILER) && defined(GRPC_CUSTOM_PROFILER) #error "GRPC_STAP_PROFILER and GRPC_CUSTOM_PROFILER are mutually exclusive." #endif #if defined(GRPC_CUSTOM_PROFILER) && defined(GRPC_BASIC_PROFILER) #error "GRPC_CUSTOM_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive." #endif - -/* Generic profiling interface. */ -#define GPR_TIMER_MARK(tag, important) \ - gpr_timer_add_mark(tag, important, __FILE__, __LINE__); - -#ifdef GRPC_STAP_PROFILER -/* Empty placeholder for now. */ -#endif /* GRPC_STAP_PROFILER */ - -#ifdef GRPC_BASIC_PROFILER -/* Empty placeholder for now. */ -#endif /* GRPC_BASIC_PROFILER */ - -namespace grpc { -class ProfileScope { - public: + +/* Generic profiling interface. */ +#define GPR_TIMER_MARK(tag, important) \ + gpr_timer_add_mark(tag, important, __FILE__, __LINE__); + +#ifdef GRPC_STAP_PROFILER +/* Empty placeholder for now. */ +#endif /* GRPC_STAP_PROFILER */ + +#ifdef GRPC_BASIC_PROFILER +/* Empty placeholder for now. */ +#endif /* GRPC_BASIC_PROFILER */ + +namespace grpc { +class ProfileScope { + public: ProfileScope(const char* desc, bool important, const char* file, int line) : desc_(desc) { gpr_timer_begin(desc_, important ? 1 : 0, file, line); - } + } ~ProfileScope() { gpr_timer_end(desc_, 0, "n/a", 0); } - - private: + + private: const char* const desc_; -}; +}; } // namespace grpc - + #define GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line) prefix##line #define GPR_TIMER_SCOPE_NAME(prefix, line) \ GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line) #define GPR_TIMER_SCOPE(tag, important) \ ::grpc::ProfileScope GPR_TIMER_SCOPE_NAME(_profile_scope_, __LINE__)( \ (tag), (important), __FILE__, __LINE__) - + #endif /* at least one profiler requested. */ -#endif /* GRPC_CORE_LIB_PROFILING_TIMERS_H */ +#endif /* GRPC_CORE_LIB_PROFILING_TIMERS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/context/security_context.h b/contrib/libs/grpc/src/core/lib/security/context/security_context.h index b1991089ae..92dba476fd 100644 --- a/contrib/libs/grpc/src/core/lib/security/context/security_context.h +++ b/contrib/libs/grpc/src/core/lib/security/context/security_context.h @@ -1,48 +1,48 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H -#define GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H +#define GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H + #include <grpc/support/port_platform.h> #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/security/credentials/credentials.h" + extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount; - -/* --- grpc_auth_context --- - - High level authentication context object. Can optionally be chained. */ - -/* Property names are always NULL terminated. */ - + +/* --- grpc_auth_context --- + + High level authentication context object. Can optionally be chained. */ + +/* Property names are always NULL terminated. */ + struct grpc_auth_property_array { grpc_auth_property* array = nullptr; size_t count = 0; size_t capacity = 0; -}; - +}; + void grpc_auth_property_reset(grpc_auth_property* property); - + // This type is forward declared as a C struct and we cannot define it as a // class. Otherwise, compiler will complain about type mismatch due to // -Wmismatched-tags. @@ -60,7 +60,7 @@ struct grpc_auth_context peer_identity_property_name_ = chained_->peer_identity_property_name_; } } - + ~grpc_auth_context() { chained_.reset(DEBUG_LOCATION, "chained"); if (properties_.array != nullptr) { @@ -70,7 +70,7 @@ struct grpc_auth_context gpr_free(properties_.array); } } - + const grpc_auth_context* chained() const { return chained_.get(); } const grpc_auth_property_array& properties() const { return properties_; } @@ -94,20 +94,20 @@ struct grpc_auth_context const char* peer_identity_property_name_ = nullptr; }; -/* --- grpc_security_context_extension --- - - Extension to the security context that may be set in a filter and accessed - later by a higher level method on a grpc_call object. */ - +/* --- grpc_security_context_extension --- + + Extension to the security context that may be set in a filter and accessed + later by a higher level method on a grpc_call object. */ + struct grpc_security_context_extension { void* instance = nullptr; void (*destroy)(void*) = nullptr; }; - -/* --- grpc_client_security_context --- - - Internal client-side security context. */ - + +/* --- grpc_client_security_context --- + + Internal client-side security context. */ + struct grpc_client_security_context { explicit grpc_client_security_context( grpc_core::RefCountedPtr<grpc_call_credentials> creds) @@ -116,35 +116,35 @@ struct grpc_client_security_context { grpc_core::RefCountedPtr<grpc_call_credentials> creds; grpc_core::RefCountedPtr<grpc_auth_context> auth_context; - grpc_security_context_extension extension; + grpc_security_context_extension extension; }; - + grpc_client_security_context* grpc_client_security_context_create( grpc_core::Arena* arena, grpc_call_credentials* creds); void grpc_client_security_context_destroy(void* ctx); - -/* --- grpc_server_security_context --- - - Internal server-side security context. */ - + +/* --- grpc_server_security_context --- + + Internal server-side security context. */ + struct grpc_server_security_context { grpc_server_security_context() = default; ~grpc_server_security_context(); grpc_core::RefCountedPtr<grpc_auth_context> auth_context; - grpc_security_context_extension extension; + grpc_security_context_extension extension; }; - + grpc_server_security_context* grpc_server_security_context_create( grpc_core::Arena* arena); void grpc_server_security_context_destroy(void* ctx); - -/* --- Channel args for auth context --- */ -#define GRPC_AUTH_CONTEXT_ARG "grpc.auth_context" - + +/* --- Channel args for auth context --- */ +#define GRPC_AUTH_CONTEXT_ARG "grpc.auth_context" + grpc_arg grpc_auth_context_to_arg(grpc_auth_context* c); grpc_auth_context* grpc_auth_context_from_arg(const grpc_arg* arg); grpc_auth_context* grpc_find_auth_context_in_args( const grpc_channel_args* args); - -#endif /* GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_CONTEXT_SECURITY_CONTEXT_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h index 5bebb9bd5a..052146adc4 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/composite/composite_credentials.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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> @@ -26,10 +26,10 @@ #include "y_absl/container/inlined_vector.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/security/credentials/credentials.h" + /* -- Composite channel credentials. -- */ - + class grpc_composite_channel_credentials : public grpc_channel_credentials { public: grpc_composite_channel_credentials( @@ -38,20 +38,20 @@ class grpc_composite_channel_credentials : public grpc_channel_credentials { : grpc_channel_credentials(channel_creds->type()), inner_creds_(std::move(channel_creds)), call_creds_(std::move(call_creds)) {} - + ~grpc_composite_channel_credentials() override = default; - + grpc_core::RefCountedPtr<grpc_channel_credentials> duplicate_without_call_credentials() override { return inner_creds_; } - + grpc_core::RefCountedPtr<grpc_channel_security_connector> create_security_connector( grpc_core::RefCountedPtr<grpc_call_credentials> call_creds, const char* target, const grpc_channel_args* args, grpc_channel_args** new_args) override; - + grpc_channel_args* update_arguments(grpc_channel_args* args) override { return inner_creds_->update_arguments(args); } @@ -67,13 +67,13 @@ class grpc_composite_channel_credentials : public grpc_channel_credentials { grpc_core::RefCountedPtr<grpc_call_credentials> call_creds_; }; -/* -- Composite call credentials. -- */ - +/* -- Composite call credentials. -- */ + class grpc_composite_call_credentials : public grpc_call_credentials { public: using CallCredentialsList = y_absl::InlinedVector<grpc_core::RefCountedPtr<grpc_call_credentials>, 2>; - + grpc_composite_call_credentials( grpc_core::RefCountedPtr<grpc_call_credentials> creds1, grpc_core::RefCountedPtr<grpc_call_credentials> creds2); @@ -102,5 +102,5 @@ class grpc_composite_call_credentials : public grpc_call_credentials { CallCredentialsList inner_; }; -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_COMPOSITE_COMPOSITE_CREDENTIALS_H \ */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h index 15a85cbd0b..df71f4fee3 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/credentials.h @@ -1,98 +1,98 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <string.h> #include <util/generic/string.h> -#include <grpc/grpc.h> -#include <grpc/grpc_security.h> -#include <grpc/support/sync.h> -#include "src/core/lib/transport/metadata_batch.h" - +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/support/sync.h> +#include "src/core/lib/transport/metadata_batch.h" + #include "src/core/lib/gprpp/ref_counted.h" -#include "src/core/lib/http/httpcli.h" -#include "src/core/lib/http/parser.h" -#include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/http/httpcli.h" +#include "src/core/lib/http/parser.h" +#include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/security/security_connector/security_connector.h" - -struct grpc_http_response; - -/* --- Constants. --- */ - -typedef enum { - GRPC_CREDENTIALS_OK = 0, - GRPC_CREDENTIALS_ERROR -} grpc_credentials_status; - -#define GRPC_FAKE_TRANSPORT_SECURITY_TYPE "fake" - -#define GRPC_CHANNEL_CREDENTIALS_TYPE_SSL "Ssl" -#define GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY \ - "FakeTransportSecurity" + +struct grpc_http_response; + +/* --- Constants. --- */ + +typedef enum { + GRPC_CREDENTIALS_OK = 0, + GRPC_CREDENTIALS_ERROR +} grpc_credentials_status; + +#define GRPC_FAKE_TRANSPORT_SECURITY_TYPE "fake" + +#define GRPC_CHANNEL_CREDENTIALS_TYPE_SSL "Ssl" +#define GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY \ + "FakeTransportSecurity" #define GRPC_CHANNEL_CREDENTIALS_TYPE_GOOGLE_DEFAULT "GoogleDefault" - -#define GRPC_CALL_CREDENTIALS_TYPE_OAUTH2 "Oauth2" -#define GRPC_CALL_CREDENTIALS_TYPE_JWT "Jwt" -#define GRPC_CALL_CREDENTIALS_TYPE_IAM "Iam" -#define GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE "Composite" - -#define GRPC_AUTHORIZATION_METADATA_KEY "authorization" -#define GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY \ - "x-goog-iam-authorization-token" -#define GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY "x-goog-iam-authority-selector" - -#define GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS 60 - + +#define GRPC_CALL_CREDENTIALS_TYPE_OAUTH2 "Oauth2" +#define GRPC_CALL_CREDENTIALS_TYPE_JWT "Jwt" +#define GRPC_CALL_CREDENTIALS_TYPE_IAM "Iam" +#define GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE "Composite" + +#define GRPC_AUTHORIZATION_METADATA_KEY "authorization" +#define GRPC_IAM_AUTHORIZATION_TOKEN_METADATA_KEY \ + "x-goog-iam-authorization-token" +#define GRPC_IAM_AUTHORITY_SELECTOR_METADATA_KEY "x-goog-iam-authority-selector" + +#define GRPC_SECURE_TOKEN_REFRESH_THRESHOLD_SECS 60 + #define GRPC_COMPUTE_ENGINE_METADATA_HOST "metadata.google.internal." -#define GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH \ - "/computeMetadata/v1/instance/service-accounts/default/token" - +#define GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH \ + "/computeMetadata/v1/instance/service-accounts/default/token" + #define GRPC_GOOGLE_OAUTH2_SERVICE_HOST "oauth2.googleapis.com" #define GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH "/token" - -#define GRPC_SERVICE_ACCOUNT_POST_BODY_PREFIX \ - "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" \ - "assertion=" - -#define GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING \ - "client_id=%s&client_secret=%s&refresh_token=%s&grant_type=refresh_token" - -/* --- Google utils --- */ - -/* It is the caller's responsibility to gpr_free the result if not NULL. */ + +#define GRPC_SERVICE_ACCOUNT_POST_BODY_PREFIX \ + "grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&" \ + "assertion=" + +#define GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING \ + "client_id=%s&client_secret=%s&refresh_token=%s&grant_type=refresh_token" + +/* --- Google utils --- */ + +/* It is the caller's responsibility to gpr_free the result if not NULL. */ TString grpc_get_well_known_google_credentials_file_path(void); - -/* Implementation function for the different platforms. */ + +/* Implementation function for the different platforms. */ TString grpc_get_well_known_google_credentials_file_path_impl(void); - -/* Override for testing only. Not thread-safe */ + +/* Override for testing only. Not thread-safe */ typedef TString (*grpc_well_known_credentials_path_getter)(void); -void grpc_override_well_known_credentials_path_getter( - grpc_well_known_credentials_path_getter getter); - -/* --- grpc_channel_credentials. --- */ - +void grpc_override_well_known_credentials_path_getter( + grpc_well_known_credentials_path_getter getter); + +/* --- grpc_channel_credentials. --- */ + #define GRPC_ARG_CHANNEL_CREDENTIALS "grpc.channel_credentials" // This type is forward declared as a C struct and we cannot define it as a @@ -103,7 +103,7 @@ struct grpc_channel_credentials public: explicit grpc_channel_credentials(const char* type) : type_(type) {} virtual ~grpc_channel_credentials() = default; - + // Creates a security connector for the channel. May also create new channel // args for the channel to be used in place of the passed in const args if // returned non NULL. In that case the caller is responsible for destroying @@ -113,7 +113,7 @@ struct grpc_channel_credentials grpc_core::RefCountedPtr<grpc_call_credentials> call_creds, const char* target, const grpc_channel_args* args, grpc_channel_args** new_args) = 0; - + // Creates a version of the channel credentials without any attached call // credentials. This can be used in order to open a channel to a non-trusted // gRPC load balancer. @@ -122,7 +122,7 @@ struct grpc_channel_credentials // By default we just increment the refcount. return Ref(); } - + // Allows credentials to optionally modify a parent channel's args. // By default, leave channel args as is. The callee takes ownership // of the passed-in channel args, and the caller takes ownership @@ -130,20 +130,20 @@ struct grpc_channel_credentials virtual grpc_channel_args* update_arguments(grpc_channel_args* args) { return args; } - + const char* type() const { return type_; } - + private: const char* type_; }; - + /* Util to encapsulate the channel credentials in a channel arg. */ grpc_arg grpc_channel_credentials_to_arg(grpc_channel_credentials* credentials); - + /* Util to get the channel credentials from a channel arg. */ grpc_channel_credentials* grpc_channel_credentials_from_arg( const grpc_arg* arg); - + /* Util to find the channel credentials from channel args. */ grpc_channel_credentials* grpc_channel_credentials_find_in_args( const grpc_channel_args* args); @@ -157,15 +157,15 @@ struct grpc_credentials_mdelem_array { /// Takes a new ref to \a md. void grpc_credentials_mdelem_array_add(grpc_credentials_mdelem_array* list, grpc_mdelem md); - + /// Appends all elements from \a src to \a dst, taking a new ref to each one. void grpc_credentials_mdelem_array_append(grpc_credentials_mdelem_array* dst, grpc_credentials_mdelem_array* src); - + void grpc_credentials_mdelem_array_destroy(grpc_credentials_mdelem_array* list); -/* --- grpc_call_credentials. --- */ - +/* --- grpc_call_credentials. --- */ + // This type is forward declared as a C struct and we cannot define it as a // class. Otherwise, compiler will complain about type mismatch due to // -Wmismatched-tags. @@ -178,7 +178,7 @@ struct grpc_call_credentials : type_(type), min_security_level_(min_security_level) {} virtual ~grpc_call_credentials() = default; - + // Returns true if completed synchronously, in which case \a error will // be set to indicate the result. Otherwise, \a on_request_metadata will // be invoked asynchronously when complete. \a md_array will be populated @@ -188,13 +188,13 @@ struct grpc_call_credentials grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, grpc_error** error) = 0; - + // Cancels a pending asynchronous operation started by // grpc_call_credentials_get_request_metadata() with the corresponding // value of \a md_array. virtual void cancel_get_request_metadata( grpc_credentials_mdelem_array* md_array, grpc_error* error) = 0; - + virtual grpc_security_level min_security_level() const { return min_security_level_; } @@ -210,13 +210,13 @@ struct grpc_call_credentials const grpc_security_level min_security_level_; }; -/* Metadata-only credentials with the specified key and value where - asynchronicity can be simulated for testing. */ +/* Metadata-only credentials with the specified key and value where + asynchronicity can be simulated for testing. */ grpc_call_credentials* grpc_md_only_test_credentials_create( const char* md_key, const char* md_value, bool is_async); - -/* --- grpc_server_credentials. --- */ - + +/* --- grpc_server_credentials. --- */ + // This type is forward declared as a C struct and we cannot define it as a // class. Otherwise, compiler will complain about type mismatch due to // -Wmismatched-tags. @@ -224,20 +224,20 @@ struct grpc_server_credentials : public grpc_core::RefCounted<grpc_server_credentials> { public: explicit grpc_server_credentials(const char* type) : type_(type) {} - + virtual ~grpc_server_credentials() { DestroyProcessor(); } - + virtual grpc_core::RefCountedPtr<grpc_server_security_connector> create_security_connector() = 0; - + const char* type() const { return type_; } - + const grpc_auth_metadata_processor& auth_metadata_processor() const { return processor_; } void set_auth_metadata_processor( const grpc_auth_metadata_processor& processor); - + private: void DestroyProcessor() { if (processor_.destroy != nullptr && processor_.state != nullptr) { @@ -250,15 +250,15 @@ struct grpc_server_credentials grpc_auth_metadata_processor(); // Zero-initialize the C struct. }; -#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials" - +#define GRPC_SERVER_CREDENTIALS_ARG "grpc.server_credentials" + grpc_arg grpc_server_credentials_to_arg(grpc_server_credentials* c); grpc_server_credentials* grpc_server_credentials_from_arg(const grpc_arg* arg); grpc_server_credentials* grpc_find_server_credentials_in_args( const grpc_channel_args* args); - -/* -- Credentials Metadata Request. -- */ - + +/* -- Credentials Metadata Request. -- */ + struct grpc_credentials_metadata_request { explicit grpc_credentials_metadata_request( grpc_core::RefCountedPtr<grpc_call_credentials> creds) @@ -268,18 +268,18 @@ struct grpc_credentials_metadata_request { } grpc_core::RefCountedPtr<grpc_call_credentials> creds; - grpc_http_response response; + grpc_http_response response; }; - + inline grpc_credentials_metadata_request* grpc_credentials_metadata_request_create( grpc_core::RefCountedPtr<grpc_call_credentials> creds) { return new grpc_credentials_metadata_request(std::move(creds)); } - + inline void grpc_credentials_metadata_request_destroy( grpc_credentials_metadata_request* r) { delete r; } - -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h index 27f3a28451..34417d50df 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/fake/fake_credentials.h @@ -1,42 +1,42 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <string.h> -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/security/credentials/credentials.h" + #define GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS \ "grpc.fake_security.expected_targets" -/* -- Fake transport security credentials. -- */ - -/* Creates a fake transport security credentials object for testing. */ +/* -- Fake transport security credentials. -- */ + +/* Creates a fake transport security credentials object for testing. */ grpc_channel_credentials* grpc_fake_transport_security_credentials_create(void); - -/* Creates a fake server transport security credentials object for testing. */ + +/* Creates a fake server transport security credentials object for testing. */ grpc_server_credentials* grpc_fake_transport_security_server_credentials_create( - void); - + void); + /* Used to verify the target names given to the fake transport security * connector. * @@ -55,8 +55,8 @@ grpc_arg grpc_fake_transport_expected_targets_arg(char* expected_targets); const char* grpc_fake_transport_get_expected_targets( const grpc_channel_args* args); -/* -- Metadata-only Test credentials. -- */ - +/* -- Metadata-only Test credentials. -- */ + class grpc_md_only_test_credentials : public grpc_call_credentials { public: grpc_md_only_test_credentials(const char* md_key, const char* md_value, @@ -67,7 +67,7 @@ class grpc_md_only_test_credentials : public grpc_call_credentials { grpc_slice_from_copied_string(md_value))), is_async_(is_async) {} ~grpc_md_only_test_credentials() override { GRPC_MDELEM_UNREF(md_); } - + bool get_request_metadata(grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, @@ -84,4 +84,4 @@ class grpc_md_only_test_credentials : public grpc_call_credentials { bool is_async_; }; -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_FAKE_FAKE_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.h index 8a945da31e..3c5a87817b 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/google_default/google_default_credentials.h @@ -1,45 +1,45 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H - -#include <grpc/support/port_platform.h> - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H + +#include <grpc/support/port_platform.h> + #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/security/credentials/credentials.h" - -#define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud" -#define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \ - "application_default_credentials.json" - -#ifdef GPR_WINDOWS -#define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "APPDATA" -#define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \ - GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \ - "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE -#else -#define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "HOME" -#define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \ - ".config/" GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \ - "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE -#endif - +#include "src/core/lib/security/credentials/credentials.h" + +#define GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY "gcloud" +#define GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE \ + "application_default_credentials.json" + +#ifdef GPR_WINDOWS +#define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "APPDATA" +#define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \ + GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \ + "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE +#else +#define GRPC_GOOGLE_CREDENTIALS_PATH_ENV_VAR "HOME" +#define GRPC_GOOGLE_CREDENTIALS_PATH_SUFFIX \ + ".config/" GRPC_GOOGLE_CLOUD_SDK_CONFIG_DIRECTORY \ + "/" GRPC_GOOGLE_WELL_KNOWN_CREDENTIALS_FILE +#endif + class grpc_google_default_channel_credentials : public grpc_channel_credentials { public: @@ -78,10 +78,10 @@ typedef bool (*grpc_gce_tenancy_checker)(void); void set_gce_tenancy_checker_for_testing(grpc_gce_tenancy_checker checker); // TEST-ONLY. Reset the internal global state. -void grpc_flush_cached_google_default_credentials(void); - +void grpc_flush_cached_google_default_credentials(void); + } // namespace internal } // namespace grpc_core -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_GOOGLE_DEFAULT_GOOGLE_DEFAULT_CREDENTIALS_H \ */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h index 76b6acfa28..8b3503254c 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/iam/iam_credentials.h @@ -1,36 +1,36 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/security/credentials/credentials.h" + class grpc_google_iam_credentials : public grpc_call_credentials { public: grpc_google_iam_credentials(const char* token, const char* authority_selector); ~grpc_google_iam_credentials() override; - + bool get_request_metadata(grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, @@ -46,4 +46,4 @@ class grpc_google_iam_credentials : public grpc_call_credentials { const TString debug_string_; }; -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_IAM_IAM_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h index b9a41c6b2b..302d13693c 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/json_token.h @@ -1,37 +1,37 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include <openssl/rsa.h> - -#include "src/core/lib/json/json.h" - -/* --- Constants. --- */ - +#include <grpc/slice.h> +#include <openssl/rsa.h> + +#include "src/core/lib/json/json.h" + +/* --- Constants. --- */ + #define GRPC_JWT_OAUTH2_AUDIENCE "https://oauth2.googleapis.com/token" - -/* --- auth_json_key parsing. --- */ - + +/* --- auth_json_key parsing. --- */ + struct grpc_auth_json_key { const char* type; char* private_key_id; @@ -39,37 +39,37 @@ struct grpc_auth_json_key { char* client_email; RSA* private_key; }; -/* Returns 1 if the object is valid, 0 otherwise. */ +/* Returns 1 if the object is valid, 0 otherwise. */ int grpc_auth_json_key_is_valid(const grpc_auth_json_key* json_key); - -/* Creates a json_key object from string. Returns an invalid object if a parsing - error has been encountered. */ -grpc_auth_json_key grpc_auth_json_key_create_from_string( + +/* Creates a json_key object from string. Returns an invalid object if a parsing + error has been encountered. */ +grpc_auth_json_key grpc_auth_json_key_create_from_string( const char* json_string); - -/* Creates a json_key object from parsed json. Returns an invalid object if a - parsing error has been encountered. */ + +/* Creates a json_key object from parsed json. Returns an invalid object if a + parsing error has been encountered. */ grpc_auth_json_key grpc_auth_json_key_create_from_json( const grpc_core::Json& json); - -/* Destructs the object. */ + +/* Destructs the object. */ void grpc_auth_json_key_destruct(grpc_auth_json_key* json_key); - -/* --- json token encoding and signing. --- */ - -/* Caller is responsible for calling gpr_free on the returned value. May return - NULL on invalid input. The scope parameter may be NULL. */ + +/* --- json token encoding and signing. --- */ + +/* Caller is responsible for calling gpr_free on the returned value. May return + NULL on invalid input. The scope parameter may be NULL. */ char* grpc_jwt_encode_and_sign(const grpc_auth_json_key* json_key, const char* audience, gpr_timespec token_lifetime, const char* scope); - -/* Override encode_and_sign function for testing. */ + +/* Override encode_and_sign function for testing. */ typedef char* (*grpc_jwt_encode_and_sign_override)( const grpc_auth_json_key* json_key, const char* audience, gpr_timespec token_lifetime, const char* scope); - -/* Set a custom encode_and_sign override for testing. */ -void grpc_jwt_encode_and_sign_set_override( - grpc_jwt_encode_and_sign_override func); - -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H */ + +/* Set a custom encode_and_sign override for testing. */ +void grpc_jwt_encode_and_sign_set_override( + grpc_jwt_encode_and_sign_override func); + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JSON_TOKEN_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h index 9b60deacb5..7e4b2a84fb 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_credentials.h @@ -1,24 +1,24 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> @@ -27,16 +27,16 @@ #include "y_absl/strings/str_format.h" #include "y_absl/time/time.h" -#include "src/core/lib/security/credentials/credentials.h" -#include "src/core/lib/security/credentials/jwt/json_token.h" - +#include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/security/credentials/jwt/json_token.h" + class grpc_service_account_jwt_access_credentials : public grpc_call_credentials { public: grpc_service_account_jwt_access_credentials(grpc_auth_json_key key, gpr_timespec token_lifetime); ~grpc_service_account_jwt_access_credentials() override; - + bool get_request_metadata(grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, @@ -58,23 +58,23 @@ class grpc_service_account_jwt_access_credentials private: void reset_cache(); - // Have a simple cache for now with just 1 entry. We could have a map based on - // the service_url for a more sophisticated one. + // Have a simple cache for now with just 1 entry. We could have a map based on + // the service_url for a more sophisticated one. gpr_mu cache_mu_; - struct { + struct { grpc_mdelem jwt_md = GRPC_MDNULL; char* service_url = nullptr; - gpr_timespec jwt_expiration; + gpr_timespec jwt_expiration; } cached_; - + grpc_auth_json_key key_; gpr_timespec jwt_lifetime_; }; - -// Private constructor for jwt credentials from an already parsed json key. -// Takes ownership of the key. + +// Private constructor for jwt credentials from an already parsed json key. +// Takes ownership of the key. grpc_core::RefCountedPtr<grpc_call_credentials> -grpc_service_account_jwt_access_credentials_create_from_auth_json_key( +grpc_service_account_jwt_access_credentials_create_from_auth_json_key( grpc_auth_json_key key, gpr_timespec token_lifetime); - -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h index 66ddbf2206..2b1b55065f 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/jwt/jwt_verifier.h @@ -1,64 +1,64 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/json/json.h" - -#include <grpc/slice.h> -#include <grpc/support/time.h> - -/* --- Constants. --- */ - -#define GRPC_OPENID_CONFIG_URL_SUFFIX "/.well-known/openid-configuration" -#define GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN "gserviceaccount.com" -#define GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX \ - "www.googleapis.com/robot/v1/metadata/x509" - -/* --- grpc_jwt_verifier_status. --- */ - -typedef enum { - GRPC_JWT_VERIFIER_OK = 0, - GRPC_JWT_VERIFIER_BAD_SIGNATURE, - GRPC_JWT_VERIFIER_BAD_FORMAT, - GRPC_JWT_VERIFIER_BAD_AUDIENCE, - GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, - GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE, - GRPC_JWT_VERIFIER_BAD_SUBJECT, - GRPC_JWT_VERIFIER_GENERIC_ERROR -} grpc_jwt_verifier_status; - +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/json/json.h" + +#include <grpc/slice.h> +#include <grpc/support/time.h> + +/* --- Constants. --- */ + +#define GRPC_OPENID_CONFIG_URL_SUFFIX "/.well-known/openid-configuration" +#define GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN "gserviceaccount.com" +#define GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX \ + "www.googleapis.com/robot/v1/metadata/x509" + +/* --- grpc_jwt_verifier_status. --- */ + +typedef enum { + GRPC_JWT_VERIFIER_OK = 0, + GRPC_JWT_VERIFIER_BAD_SIGNATURE, + GRPC_JWT_VERIFIER_BAD_FORMAT, + GRPC_JWT_VERIFIER_BAD_AUDIENCE, + GRPC_JWT_VERIFIER_KEY_RETRIEVAL_ERROR, + GRPC_JWT_VERIFIER_TIME_CONSTRAINT_FAILURE, + GRPC_JWT_VERIFIER_BAD_SUBJECT, + GRPC_JWT_VERIFIER_GENERIC_ERROR +} grpc_jwt_verifier_status; + const char* grpc_jwt_verifier_status_to_string(grpc_jwt_verifier_status status); - -/* --- grpc_jwt_claims. --- */ - -typedef struct grpc_jwt_claims grpc_jwt_claims; - + +/* --- grpc_jwt_claims. --- */ + +typedef struct grpc_jwt_claims grpc_jwt_claims; + void grpc_jwt_claims_destroy(grpc_jwt_claims* claims); - -/* Returns the whole JSON tree of the claims. */ + +/* Returns the whole JSON tree of the claims. */ const grpc_core::Json* grpc_jwt_claims_json(const grpc_jwt_claims* claims); - -/* Access to registered claims in https://tools.ietf.org/html/rfc7519#page-9 */ + +/* Access to registered claims in https://tools.ietf.org/html/rfc7519#page-9 */ const char* grpc_jwt_claims_subject(const grpc_jwt_claims* claims); const char* grpc_jwt_claims_issuer(const grpc_jwt_claims* claims); const char* grpc_jwt_claims_id(const grpc_jwt_claims* claims); @@ -66,57 +66,57 @@ const char* grpc_jwt_claims_audience(const grpc_jwt_claims* claims); gpr_timespec grpc_jwt_claims_issued_at(const grpc_jwt_claims* claims); gpr_timespec grpc_jwt_claims_expires_at(const grpc_jwt_claims* claims); gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims* claims); - -/* --- grpc_jwt_verifier. --- */ - -typedef struct grpc_jwt_verifier grpc_jwt_verifier; - + +/* --- grpc_jwt_verifier. --- */ + +typedef struct grpc_jwt_verifier grpc_jwt_verifier; + struct grpc_jwt_verifier_email_domain_key_url_mapping { - /* The email domain is the part after the @ sign. */ + /* The email domain is the part after the @ sign. */ const char* email_domain; - - /* The key url prefix will be used to get the public key from the issuer: - https://<key_url_prefix>/<issuer_email> - Therefore the key_url_prefix must NOT contain https://. */ + + /* The key url prefix will be used to get the public key from the issuer: + https://<key_url_prefix>/<issuer_email> + Therefore the key_url_prefix must NOT contain https://. */ const char* key_url_prefix; }; -/* Globals to control the verifier. Not thread-safe. */ -extern gpr_timespec grpc_jwt_verifier_clock_skew; +/* Globals to control the verifier. Not thread-safe. */ +extern gpr_timespec grpc_jwt_verifier_clock_skew; extern grpc_millis grpc_jwt_verifier_max_delay; - -/* The verifier can be created with some custom mappings to help with key - discovery in the case where the issuer is an email address. - mappings can be NULL in which case num_mappings MUST be 0. - A verifier object has one built-in mapping (unless overridden): - GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN -> - GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX.*/ + +/* The verifier can be created with some custom mappings to help with key + discovery in the case where the issuer is an email address. + mappings can be NULL in which case num_mappings MUST be 0. + A verifier object has one built-in mapping (unless overridden): + GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN -> + GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX.*/ grpc_jwt_verifier* grpc_jwt_verifier_create( const grpc_jwt_verifier_email_domain_key_url_mapping* mappings, - size_t num_mappings); - -/*The verifier must not be destroyed if there are still outstanding callbacks.*/ + size_t num_mappings); + +/*The verifier must not be destroyed if there are still outstanding callbacks.*/ void grpc_jwt_verifier_destroy(grpc_jwt_verifier* verifier); - -/* User provided callback that will be called when the verification of the JWT - is done (maybe in another thread). - It is the responsibility of the callee to call grpc_jwt_claims_destroy on - the claims. */ + +/* User provided callback that will be called when the verification of the JWT + is done (maybe in another thread). + It is the responsibility of the callee to call grpc_jwt_claims_destroy on + the claims. */ typedef void (*grpc_jwt_verification_done_cb)(void* user_data, - grpc_jwt_verifier_status status, + grpc_jwt_verifier_status status, grpc_jwt_claims* claims); - -/* Verifies for the JWT for the given expected audience. */ + +/* Verifies for the JWT for the given expected audience. */ void grpc_jwt_verifier_verify(grpc_jwt_verifier* verifier, grpc_pollset* pollset, const char* jwt, const char* audience, - grpc_jwt_verification_done_cb cb, + grpc_jwt_verification_done_cb cb, void* user_data); - -/* --- TESTING ONLY exposed functions. --- */ - + +/* --- TESTING ONLY exposed functions. --- */ + grpc_jwt_claims* grpc_jwt_claims_from_json(grpc_core::Json json); grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims* claims, const char* audience); const char* grpc_jwt_issuer_email_domain(const char* issuer); - -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_JWT_JWT_VERIFIER_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h index fd886405cf..1ba0ef64cc 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/oauth2/oauth2_credentials.h @@ -1,67 +1,67 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> #include <grpc/grpc_security.h> -#include "src/core/lib/json/json.h" -#include "src/core/lib/security/credentials/credentials.h" +#include "src/core/lib/json/json.h" +#include "src/core/lib/security/credentials/credentials.h" #include "src/core/lib/uri/uri_parser.h" - + // Constants. #define GRPC_STS_POST_MINIMAL_BODY_FORMAT_STRING \ "grant_type=urn:ietf:params:oauth:grant-type:token-exchange&subject_token=%" \ "s&subject_token_type=%s" -// auth_refresh_token parsing. +// auth_refresh_token parsing. struct grpc_auth_refresh_token { const char* type; char* client_id; char* client_secret; char* refresh_token; }; -/// Returns 1 if the object is valid, 0 otherwise. -int grpc_auth_refresh_token_is_valid( +/// Returns 1 if the object is valid, 0 otherwise. +int grpc_auth_refresh_token_is_valid( const grpc_auth_refresh_token* refresh_token); - -/// Creates a refresh token object from string. Returns an invalid object if a -/// parsing error has been encountered. -grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string( + +/// Creates a refresh token object from string. Returns an invalid object if a +/// parsing error has been encountered. +grpc_auth_refresh_token grpc_auth_refresh_token_create_from_string( const char* json_string); - -/// Creates a refresh token object from parsed json. Returns an invalid object -/// if a parsing error has been encountered. -grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json( + +/// Creates a refresh token object from parsed json. Returns an invalid object +/// if a parsing error has been encountered. +grpc_auth_refresh_token grpc_auth_refresh_token_create_from_json( const grpc_core::Json& json); - -/// Destructs the object. + +/// Destructs the object. void grpc_auth_refresh_token_destruct(grpc_auth_refresh_token* refresh_token); - -// -- Oauth2 Token Fetcher credentials -- -// -// This object is a base for credentials that need to acquire an oauth2 token -// from an http service. - + +// -- Oauth2 Token Fetcher credentials -- +// +// This object is a base for credentials that need to acquire an oauth2 token +// from an http service. + struct grpc_oauth2_pending_get_request_metadata { grpc_credentials_mdelem_array* md_array; grpc_closure* on_request_metadata; @@ -73,7 +73,7 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { public: grpc_oauth2_token_fetcher_credentials(); ~grpc_oauth2_token_fetcher_credentials() override; - + bool get_request_metadata(grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, @@ -103,13 +103,13 @@ class grpc_oauth2_token_fetcher_credentials : public grpc_call_credentials { grpc_polling_entity pollent_; }; -// Google refresh token credentials. +// Google refresh token credentials. class grpc_google_refresh_token_credentials final : public grpc_oauth2_token_fetcher_credentials { public: grpc_google_refresh_token_credentials(grpc_auth_refresh_token refresh_token); ~grpc_google_refresh_token_credentials() override; - + const grpc_auth_refresh_token& refresh_token() const { return refresh_token_; } @@ -127,12 +127,12 @@ class grpc_google_refresh_token_credentials final grpc_closure http_post_cb_closure_; }; -// Access token credentials. +// Access token credentials. class grpc_access_token_credentials final : public grpc_call_credentials { public: grpc_access_token_credentials(const char* access_token); ~grpc_access_token_credentials() override; - + bool get_request_metadata(grpc_polling_entity* pollent, grpc_auth_metadata_context context, grpc_credentials_mdelem_array* md_array, @@ -148,18 +148,18 @@ class grpc_access_token_credentials final : public grpc_call_credentials { grpc_mdelem access_token_md_; }; -// Private constructor for refresh token credentials from an already parsed -// refresh token. Takes ownership of the refresh token. +// Private constructor for refresh token credentials from an already parsed +// refresh token. Takes ownership of the refresh token. grpc_core::RefCountedPtr<grpc_call_credentials> -grpc_refresh_token_credentials_create_from_auth_refresh_token( - grpc_auth_refresh_token token); - -// Exposed for testing only. -grpc_credentials_status -grpc_oauth2_token_fetcher_credentials_parse_server_response( +grpc_refresh_token_credentials_create_from_auth_refresh_token( + grpc_auth_refresh_token token); + +// Exposed for testing only. +grpc_credentials_status +grpc_oauth2_token_fetcher_credentials_parse_server_response( const struct grpc_http_response* response, grpc_mdelem* token_md, grpc_millis* token_lifetime); - + namespace grpc_core { // Exposed for testing only. This function validates the options, ensuring that // the required fields are set, and outputs the parsed URL of the STS token @@ -168,4 +168,4 @@ grpc_error* ValidateStsCredentialsOptions( const grpc_sts_credentials_options* options, grpc_uri** sts_url); } // namespace grpc_core -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_OAUTH2_OAUTH2_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h index 78bca05fb9..30309179db 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/plugin/plugin_credentials.h @@ -1,28 +1,28 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/security/credentials/credentials.h" + extern grpc_core::TraceFlag grpc_plugin_credentials_trace; // This type is forward declared as a C struct and we cannot define it as a @@ -48,7 +48,7 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { grpc_credentials_mdelem_array* md_array, grpc_closure* on_request_metadata, grpc_error** error) override; - + void cancel_get_request_metadata(grpc_credentials_mdelem_array* md_array, grpc_error* error) override; @@ -69,4 +69,4 @@ struct grpc_plugin_credentials final : public grpc_call_credentials { pending_request* pending_requests_ = nullptr; }; -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_PLUGIN_PLUGIN_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h index 4c90813f8d..546e970087 100644 --- a/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h +++ b/contrib/libs/grpc/src/core/lib/security/credentials/ssl/ssl_credentials.h @@ -1,29 +1,29 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H -#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H - + * + */ +#ifndef GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H +#define GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/security/credentials/credentials.h" - +#include "src/core/lib/security/credentials/credentials.h" + #include "src/core/lib/security/security_connector/ssl/ssl_security_connector.h" - + class grpc_ssl_credentials : public grpc_channel_credentials { public: grpc_ssl_credentials(const char* pem_root_certs, @@ -67,7 +67,7 @@ class grpc_ssl_server_credentials final : public grpc_server_credentials { grpc_ssl_server_credentials( const grpc_ssl_server_credentials_options& options); ~grpc_ssl_server_credentials() override; - + grpc_core::RefCountedPtr<grpc_server_security_connector> create_security_connector() override; @@ -106,4 +106,4 @@ tsi_ssl_pem_key_cert_pair* grpc_convert_grpc_to_tsi_cert_pairs( void grpc_tsi_ssl_pem_key_cert_pairs_destroy(tsi_ssl_pem_key_cert_pair* kp, size_t num_key_cert_pairs); -#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_CREDENTIALS_SSL_SSL_CREDENTIALS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/transport/auth_filters.h b/contrib/libs/grpc/src/core/lib/security/transport/auth_filters.h index ae31b1d578..63c2b4f4fa 100644 --- a/contrib/libs/grpc/src/core/lib/security/transport/auth_filters.h +++ b/contrib/libs/grpc/src/core/lib/security/transport/auth_filters.h @@ -1,35 +1,35 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H -#define GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H +#define GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H + #include <grpc/support/port_platform.h> #include <grpc/grpc_security.h> -#include "src/core/lib/channel/channel_stack.h" - -extern const grpc_channel_filter grpc_client_auth_filter; -extern const grpc_channel_filter grpc_server_auth_filter; - +#include "src/core/lib/channel/channel_stack.h" + +extern const grpc_channel_filter grpc_client_auth_filter; +extern const grpc_channel_filter grpc_server_auth_filter; + void grpc_auth_metadata_context_build( const char* url_scheme, const grpc_slice& call_host, const grpc_slice& call_method, grpc_auth_context* auth_context, grpc_auth_metadata_context* auth_md_context); -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */ +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_AUTH_FILTERS_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.h b/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.h index e7e3351678..38b5fbfcd5 100644 --- a/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.h +++ b/contrib/libs/grpc/src/core/lib/security/transport/secure_endpoint.h @@ -1,34 +1,34 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H -#define GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H +#define GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H + #include <grpc/support/port_platform.h> -#include <grpc/slice.h> -#include "src/core/lib/iomgr/endpoint.h" - -struct tsi_frame_protector; +#include <grpc/slice.h> +#include "src/core/lib/iomgr/endpoint.h" + +struct tsi_frame_protector; struct tsi_zero_copy_grpc_protector; - + extern grpc_core::TraceFlag grpc_trace_secure_endpoint; - + /* Takes ownership of protector, zero_copy_protector, and to_wrap, and refs * leftover_slices. If zero_copy_protector is not NULL, protector will never be * used. */ @@ -37,5 +37,5 @@ grpc_endpoint* grpc_secure_endpoint_create( struct tsi_zero_copy_grpc_protector* zero_copy_protector, grpc_endpoint* to_wrap, grpc_slice* leftover_slices, size_t leftover_nslices); - -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.h b/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.h index a9e1fe83d4..f4b22ef318 100644 --- a/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.h +++ b/contrib/libs/grpc/src/core/lib/security/transport/security_handshaker.h @@ -1,39 +1,39 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H -#define GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H +#define GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/channel/handshaker.h" +#include "src/core/lib/channel/handshaker.h" #include "src/core/lib/security/security_connector/security_connector.h" - + namespace grpc_core { -/// Creates a security handshaker using \a handshaker. +/// Creates a security handshaker using \a handshaker. RefCountedPtr<Handshaker> SecurityHandshakerCreate( tsi_handshaker* handshaker, grpc_security_connector* connector, const grpc_channel_args* args); - -/// Registers security handshaker factories. + +/// Registers security handshaker factories. void SecurityRegisterHandshakerFactories(); - + } // namespace grpc_core // TODO(arjunroy): This is transitional to account for the new handshaker API @@ -42,4 +42,4 @@ grpc_handshaker* grpc_security_handshaker_create( tsi_handshaker* handshaker, grpc_security_connector* connector, const grpc_channel_args* args); -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURITY_HANDSHAKER_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/transport/tsi_error.h b/contrib/libs/grpc/src/core/lib/security/transport/tsi_error.h index 16e04f70f1..4d7377c307 100644 --- a/contrib/libs/grpc/src/core/lib/security/transport/tsi_error.h +++ b/contrib/libs/grpc/src/core/lib/security/transport/tsi_error.h @@ -1,29 +1,29 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H -#define GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H +#define GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/iomgr/error.h" +#include "src/core/lib/iomgr/error.h" #include "src/core/tsi/transport_security_interface.h" - + grpc_error* grpc_set_tsi_error_result(grpc_error* error, tsi_result result); - -#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_TSI_ERROR_H */ diff --git a/contrib/libs/grpc/src/core/lib/security/util/json_util.h b/contrib/libs/grpc/src/core/lib/security/util/json_util.h index 42f7005e00..3338c6569d 100644 --- a/contrib/libs/grpc/src/core/lib/security/util/json_util.h +++ b/contrib/libs/grpc/src/core/lib/security/util/json_util.h @@ -1,44 +1,44 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H -#define GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H - + * + */ + +#ifndef GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H +#define GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H + #include <grpc/support/port_platform.h> -#include <stdbool.h> - +#include <stdbool.h> + #include "src/core/lib/iomgr/error.h" -#include "src/core/lib/json/json.h" - -// Constants. -#define GRPC_AUTH_JSON_TYPE_INVALID "invalid" -#define GRPC_AUTH_JSON_TYPE_SERVICE_ACCOUNT "service_account" -#define GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER "authorized_user" - -// Gets a child property from a json node. +#include "src/core/lib/json/json.h" + +// Constants. +#define GRPC_AUTH_JSON_TYPE_INVALID "invalid" +#define GRPC_AUTH_JSON_TYPE_SERVICE_ACCOUNT "service_account" +#define GRPC_AUTH_JSON_TYPE_AUTHORIZED_USER "authorized_user" + +// Gets a child property from a json node. const char* grpc_json_get_string_property(const grpc_core::Json& json, const char* prop_name, grpc_error** error); - -// Copies the value of the json child property specified by prop_name. -// Returns false if the property was not found. + +// Copies the value of the json child property specified by prop_name. +// Returns false if the property was not found. bool grpc_copy_json_string_property(const grpc_core::Json& json, const char* prop_name, char** copied_value); - -#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ + +#endif /* GRPC_CORE_LIB_SECURITY_UTIL_JSON_UTIL_H */ diff --git a/contrib/libs/grpc/src/core/lib/slice/percent_encoding.h b/contrib/libs/grpc/src/core/lib/slice/percent_encoding.h index 43b20f090f..1d703b18a3 100644 --- a/contrib/libs/grpc/src/core/lib/slice/percent_encoding.h +++ b/contrib/libs/grpc/src/core/lib/slice/percent_encoding.h @@ -1,65 +1,65 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H -#define GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H - -/* Percent encoding and decoding of slices. - Transforms arbitrary strings into safe-for-transmission strings by using - variants of percent encoding (RFC 3986). - Two major variants are supplied: one that strictly matches URL encoding, - and another which applies percent encoding only to non-http2 header - bytes (the 'compatible' variant) */ - + * + */ + +#ifndef GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H +#define GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H + +/* Percent encoding and decoding of slices. + Transforms arbitrary strings into safe-for-transmission strings by using + variants of percent encoding (RFC 3986). + Two major variants are supplied: one that strictly matches URL encoding, + and another which applies percent encoding only to non-http2 header + bytes (the 'compatible' variant) */ + #include <grpc/support/port_platform.h> -#include <stdbool.h> - -#include <grpc/slice.h> - -/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in - grpc_percent_encode_slice, grpc_strict_percent_decode_slice). - Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines - */ -extern const uint8_t grpc_url_percent_encoding_unreserved_bytes[256 / 8]; -/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in - grpc_percent_encode_slice, grpc_strict_percent_decode_slice). - Flags ascii7 non-control characters excluding '%' as unreserved bytes for the - percent encoding routines */ -extern const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8]; - -/* Percent-encode a slice, returning the new slice (this cannot fail): - unreserved_bytes is a bitfield indicating which bytes are considered - unreserved and thus do not need percent encoding */ +#include <stdbool.h> + +#include <grpc/slice.h> + +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + grpc_percent_encode_slice, grpc_strict_percent_decode_slice). + Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines + */ +extern const uint8_t grpc_url_percent_encoding_unreserved_bytes[256 / 8]; +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + grpc_percent_encode_slice, grpc_strict_percent_decode_slice). + Flags ascii7 non-control characters excluding '%' as unreserved bytes for the + percent encoding routines */ +extern const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8]; + +/* Percent-encode a slice, returning the new slice (this cannot fail): + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ grpc_slice grpc_percent_encode_slice(const grpc_slice& slice, const uint8_t* unreserved_bytes); -/* Percent-decode a slice, strictly. - If the input is legal (contains no unreserved bytes, and legal % encodings), - returns true and sets *slice_out to the decoded slice. - If the input is not legal, returns false and leaves *slice_out untouched. - unreserved_bytes is a bitfield indicating which bytes are considered - unreserved and thus do not need percent encoding */ +/* Percent-decode a slice, strictly. + If the input is legal (contains no unreserved bytes, and legal % encodings), + returns true and sets *slice_out to the decoded slice. + If the input is not legal, returns false and leaves *slice_out untouched. + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ bool grpc_strict_percent_decode_slice(const grpc_slice& slice_in, const uint8_t* unreserved_bytes, grpc_slice* slice_out); -/* Percent-decode a slice, permissively. - If a % triplet can not be decoded, pass it through verbatim. - This cannot fail. */ +/* Percent-decode a slice, permissively. + If a % triplet can not be decoded, pass it through verbatim. + This cannot fail. */ grpc_slice grpc_permissive_percent_decode_slice(const grpc_slice& slice_in); - -#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ + +#endif /* GRPC_CORE_LIB_SLICE_PERCENT_ENCODING_H */ diff --git a/contrib/libs/grpc/src/core/lib/slice/slice_internal.h b/contrib/libs/grpc/src/core/lib/slice/slice_internal.h index 8a17b6e72e..2880cd1fb1 100644 --- a/contrib/libs/grpc/src/core/lib/slice/slice_internal.h +++ b/contrib/libs/grpc/src/core/lib/slice/slice_internal.h @@ -1,32 +1,32 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H -#define GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H - + * + */ + +#ifndef GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H +#define GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H + #include <grpc/support/port_platform.h> #include <grpc/support/log.h> -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> #include <string.h> - + #include "src/core/lib/gpr/murmur_hash.h" #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted.h" @@ -279,7 +279,7 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_slice_buffer* sb); void grpc_slice_buffer_partial_unref_internal(grpc_slice_buffer* sb, size_t idx); void grpc_slice_buffer_destroy_internal(grpc_slice_buffer* sb); - + // Returns a pointer to the first slice in the slice buffer without giving // ownership to or a reference count on that slice. inline grpc_slice* grpc_slice_buffer_peek_first(grpc_slice_buffer* sb) { @@ -362,4 +362,4 @@ inline bool operator==(const grpc_slice& s1, const grpc_slice& s2) { return grpc_slice_eq(s1, s2); } -#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ +#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */ diff --git a/contrib/libs/grpc/src/core/lib/slice/slice_string_helpers.h b/contrib/libs/grpc/src/core/lib/slice/slice_string_helpers.h index 6551a6df75..b9ad320765 100644 --- a/contrib/libs/grpc/src/core/lib/slice/slice_string_helpers.h +++ b/contrib/libs/grpc/src/core/lib/slice/slice_string_helpers.h @@ -1,49 +1,49 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H -#define GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H - + * + */ + +#ifndef GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H +#define GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H + #include <grpc/support/port_platform.h> #include <stdbool.h> -#include <stddef.h> - -#include <grpc/slice.h> -#include <grpc/slice_buffer.h> - +#include <stddef.h> + +#include <grpc/slice.h> +#include <grpc/slice_buffer.h> + #include "src/core/lib/gpr/string.h" - -/* Calls gpr_dump on a slice. */ + +/* Calls gpr_dump on a slice. */ char* grpc_dump_slice(const grpc_slice& slice, uint32_t flags); /* Calls gpr_dump on a slice and returns the result as a slice. */ grpc_slice grpc_dump_slice_to_slice(const grpc_slice& slice, uint32_t flags); - -/** Split \a str by the separator \a sep. Results are stored in \a dst, which - * should be a properly initialized instance. */ + +/** Split \a str by the separator \a sep. Results are stored in \a dst, which + * should be a properly initialized instance. */ void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst); - + /** Split \a str by the separator \a sep and remove the leading and trailing * spaces of each resulting token. Results are stored in \a dst, which should be * a properly initialized instance. */ void grpc_slice_split_without_space(grpc_slice str, const char* sep, grpc_slice_buffer* dst); - + bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result); -#endif /* GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H */ +#endif /* GRPC_CORE_LIB_SLICE_SLICE_STRING_HELPERS_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/README.md b/contrib/libs/grpc/src/core/lib/surface/README.md index 74cbd71131..c809639055 100644 --- a/contrib/libs/grpc/src/core/lib/surface/README.md +++ b/contrib/libs/grpc/src/core/lib/surface/README.md @@ -1,4 +1,4 @@ -# Surface - -Surface provides the bulk of the gRPC Core public API, and translates it into -calls against core components. +# Surface + +Surface provides the bulk of the gRPC Core public API, and translates it into +calls against core components. diff --git a/contrib/libs/grpc/src/core/lib/surface/api_trace.h b/contrib/libs/grpc/src/core/lib/surface/api_trace.h index 51d1f52223..4b0275a184 100644 --- a/contrib/libs/grpc/src/core/lib/surface/api_trace.h +++ b/contrib/libs/grpc/src/core/lib/surface/api_trace.h @@ -1,52 +1,52 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_API_TRACE_H -#define GRPC_CORE_LIB_SURFACE_API_TRACE_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_API_TRACE_H +#define GRPC_CORE_LIB_SURFACE_API_TRACE_H + #include <grpc/support/port_platform.h> -#include <grpc/support/log.h> -#include "src/core/lib/debug/trace.h" - +#include <grpc/support/log.h> +#include "src/core/lib/debug/trace.h" + extern grpc_core::TraceFlag grpc_api_trace; - -/* Provide unwrapping macros because we're in C89 and variadic macros weren't - introduced until C99... */ -#define GRPC_API_TRACE_UNWRAP0() -#define GRPC_API_TRACE_UNWRAP1(a) , a -#define GRPC_API_TRACE_UNWRAP2(a, b) , a, b -#define GRPC_API_TRACE_UNWRAP3(a, b, c) , a, b, c -#define GRPC_API_TRACE_UNWRAP4(a, b, c, d) , a, b, c, d -#define GRPC_API_TRACE_UNWRAP5(a, b, c, d, e) , a, b, c, d, e -#define GRPC_API_TRACE_UNWRAP6(a, b, c, d, e, f) , a, b, c, d, e, f -#define GRPC_API_TRACE_UNWRAP7(a, b, c, d, e, f, g) , a, b, c, d, e, f, g -#define GRPC_API_TRACE_UNWRAP8(a, b, c, d, e, f, g, h) , a, b, c, d, e, f, g, h -#define GRPC_API_TRACE_UNWRAP9(a, b, c, d, e, f, g, h, i) \ - , a, b, c, d, e, f, g, h, i -#define GRPC_API_TRACE_UNWRAP10(a, b, c, d, e, f, g, h, i, j) \ - , a, b, c, d, e, f, g, h, i, j - -/* Due to the limitations of C89's preprocessor, the arity of the var-arg list - 'nargs' must be specified. */ -#define GRPC_API_TRACE(fmt, nargs, args) \ + +/* Provide unwrapping macros because we're in C89 and variadic macros weren't + introduced until C99... */ +#define GRPC_API_TRACE_UNWRAP0() +#define GRPC_API_TRACE_UNWRAP1(a) , a +#define GRPC_API_TRACE_UNWRAP2(a, b) , a, b +#define GRPC_API_TRACE_UNWRAP3(a, b, c) , a, b, c +#define GRPC_API_TRACE_UNWRAP4(a, b, c, d) , a, b, c, d +#define GRPC_API_TRACE_UNWRAP5(a, b, c, d, e) , a, b, c, d, e +#define GRPC_API_TRACE_UNWRAP6(a, b, c, d, e, f) , a, b, c, d, e, f +#define GRPC_API_TRACE_UNWRAP7(a, b, c, d, e, f, g) , a, b, c, d, e, f, g +#define GRPC_API_TRACE_UNWRAP8(a, b, c, d, e, f, g, h) , a, b, c, d, e, f, g, h +#define GRPC_API_TRACE_UNWRAP9(a, b, c, d, e, f, g, h, i) \ + , a, b, c, d, e, f, g, h, i +#define GRPC_API_TRACE_UNWRAP10(a, b, c, d, e, f, g, h, i, j) \ + , a, b, c, d, e, f, g, h, i, j + +/* Due to the limitations of C89's preprocessor, the arity of the var-arg list + 'nargs' must be specified. */ +#define GRPC_API_TRACE(fmt, nargs, args) \ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ - gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ - } - -#endif /* GRPC_CORE_LIB_SURFACE_API_TRACE_H */ + gpr_log(GPR_INFO, fmt GRPC_API_TRACE_UNWRAP##nargs args); \ + } + +#endif /* GRPC_CORE_LIB_SURFACE_API_TRACE_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/call.h b/contrib/libs/grpc/src/core/lib/surface/call.h index 34d01db902..f385533d48 100644 --- a/contrib/libs/grpc/src/core/lib/surface/call.h +++ b/contrib/libs/grpc/src/core/lib/surface/call.h @@ -1,126 +1,126 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_CALL_H -#define GRPC_CORE_LIB_SURFACE_CALL_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_CALL_H +#define GRPC_CORE_LIB_SURFACE_CALL_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/channel/channel_stack.h" -#include "src/core/lib/channel/context.h" +#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/context.h" #include "src/core/lib/gprpp/arena.h" -#include "src/core/lib/surface/api_trace.h" +#include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/server.h" - -#include <grpc/grpc.h> -#include <grpc/impl/codegen/compression_types.h> - + +#include <grpc/grpc.h> +#include <grpc/impl/codegen/compression_types.h> + typedef void (*grpc_ioreq_completion_func)(grpc_call* call, int success, void* user_data); - -typedef struct grpc_call_create_args { + +typedef struct grpc_call_create_args { grpc_channel* channel; grpc_core::Server* server; - + grpc_call* parent; - uint32_t propagation_mask; - + uint32_t propagation_mask; + grpc_completion_queue* cq; - /* if not NULL, it'll be used in lieu of cq */ + /* if not NULL, it'll be used in lieu of cq */ grpc_pollset_set* pollset_set_alternative; - + const void* server_transport_data; - + grpc_mdelem* add_initial_metadata; - size_t add_initial_metadata_count; - + size_t add_initial_metadata_count; + grpc_millis send_deadline; -} grpc_call_create_args; - -/* Create a new call based on \a args. - Regardless of success or failure, always returns a valid new call into *call - */ +} grpc_call_create_args; + +/* Create a new call based on \a args. + Regardless of success or failure, always returns a valid new call into *call + */ grpc_error* grpc_call_create(const grpc_call_create_args* args, grpc_call** call); - + void grpc_call_set_completion_queue(grpc_call* call, grpc_completion_queue* cq); - + #ifndef NDEBUG void grpc_call_internal_ref(grpc_call* call, const char* reason); void grpc_call_internal_unref(grpc_call* call, const char* reason); -#define GRPC_CALL_INTERNAL_REF(call, reason) \ - grpc_call_internal_ref(call, reason) +#define GRPC_CALL_INTERNAL_REF(call, reason) \ + grpc_call_internal_ref(call, reason) #define GRPC_CALL_INTERNAL_UNREF(call, reason) \ grpc_call_internal_unref(call, reason) -#else +#else void grpc_call_internal_ref(grpc_call* call); void grpc_call_internal_unref(grpc_call* call); -#define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call) +#define GRPC_CALL_INTERNAL_REF(call, reason) grpc_call_internal_ref(call) #define GRPC_CALL_INTERNAL_UNREF(call, reason) grpc_call_internal_unref(call) -#endif - +#endif + grpc_core::Arena* grpc_call_get_arena(grpc_call* call); grpc_call_stack* grpc_call_get_call_stack(grpc_call* call); - + grpc_call_error grpc_call_start_batch_and_execute(grpc_call* call, const grpc_op* ops, - size_t nops, + size_t nops, grpc_closure* closure); - + /* gRPC core internal version of grpc_call_cancel that does not create * exec_ctx. */ void grpc_call_cancel_internal(grpc_call* call); -/* Given the top call_element, get the call object. */ +/* Given the top call_element, get the call object. */ grpc_call* grpc_call_from_top_element(grpc_call_element* surface_element); - + void grpc_call_log_batch(const char* file, int line, gpr_log_severity severity, const grpc_op* ops, size_t nops); - -/* Set a context pointer. - No thread safety guarantees are made wrt this value. */ + +/* Set a context pointer. + No thread safety guarantees are made wrt this value. */ /* TODO(#9731): add exec_ctx to destroy */ void grpc_call_context_set(grpc_call* call, grpc_context_index elem, void* value, void (*destroy)(void* value)); -/* Get a context pointer. */ +/* Get a context pointer. */ void* grpc_call_context_get(grpc_call* call, grpc_context_index elem); - + #define GRPC_CALL_LOG_BATCH(sev, ops, nops) \ do { \ if (GRPC_TRACE_FLAG_ENABLED(grpc_api_trace)) { \ grpc_call_log_batch(sev, ops, nops); \ } \ } while (0) - + uint8_t grpc_call_is_client(grpc_call* call); - + /* Get the estimated memory size for a call BESIDES the call stack. Combined * with the size of the call stack, it helps estimate the arena size for the * initial call. */ size_t grpc_call_get_initial_size_estimate(); -/* Return an appropriate compression algorithm for the requested compression \a - * level in the context of \a call. */ -grpc_compression_algorithm grpc_call_compression_for_level( +/* Return an appropriate compression algorithm for the requested compression \a + * level in the context of \a call. */ +grpc_compression_algorithm grpc_call_compression_for_level( grpc_call* call, grpc_compression_level level); - + extern grpc_core::TraceFlag grpc_call_error_trace; extern grpc_core::TraceFlag grpc_compression_trace; - -#endif /* GRPC_CORE_LIB_SURFACE_CALL_H */ + +#endif /* GRPC_CORE_LIB_SURFACE_CALL_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/call_test_only.h b/contrib/libs/grpc/src/core/lib/surface/call_test_only.h index dbd1a866ca..c15be27d69 100644 --- a/contrib/libs/grpc/src/core/lib/surface/call_test_only.h +++ b/contrib/libs/grpc/src/core/lib/surface/call_test_only.h @@ -1,43 +1,43 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H -#define GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H +#define GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H + #include <grpc/support/port_platform.h> -#include <grpc/grpc.h> - +#include <grpc/grpc.h> + /** Return the message compression algorithm from \a call. - * - * \warning This function should \b only be used in test code. */ -grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm( + * + * \warning This function should \b only be used in test code. */ +grpc_compression_algorithm grpc_call_test_only_get_compression_algorithm( grpc_call* call); - -/** Return the message flags from \a call. - * - * \warning This function should \b only be used in test code. */ + +/** Return the message flags from \a call. + * + * \warning This function should \b only be used in test code. */ uint32_t grpc_call_test_only_get_message_flags(grpc_call* call); - -/** Returns a bitset for the encodings (compression algorithms) supported by \a - * call's peer. - * - * To be indexed by grpc_compression_algorithm enum values. */ + +/** Returns a bitset for the encodings (compression algorithms) supported by \a + * call's peer. + * + * To be indexed by grpc_compression_algorithm enum values. */ uint32_t grpc_call_test_only_get_encodings_accepted_by_peer(grpc_call* call); - -#endif /* GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H */ + +#endif /* GRPC_CORE_LIB_SURFACE_CALL_TEST_ONLY_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/channel.h b/contrib/libs/grpc/src/core/lib/surface/channel.h index e49b9261f7..8f0f4233b6 100644 --- a/contrib/libs/grpc/src/core/lib/surface/channel.h +++ b/contrib/libs/grpc/src/core/lib/surface/channel.h @@ -1,41 +1,41 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_CHANNEL_H -#define GRPC_CORE_LIB_SURFACE_CHANNEL_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_CHANNEL_H +#define GRPC_CORE_LIB_SURFACE_CHANNEL_H + #include <grpc/support/port_platform.h> #include <map> -#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channel_stack_builder.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/surface/channel_stack_type.h" #include "src/core/lib/transport/metadata.h" - + grpc_channel* grpc_channel_create(const char* target, const grpc_channel_args* args, - grpc_channel_stack_type channel_stack_type, + grpc_channel_stack_type channel_stack_type, grpc_transport* optional_transport, grpc_resource_user* resource_user = nullptr); - + /** The same as grpc_channel_destroy, but doesn't create an ExecCtx, and so * is safe to use from within core. */ void grpc_channel_destroy_internal(grpc_channel* channel); @@ -44,22 +44,22 @@ grpc_channel* grpc_channel_create_with_builder( grpc_channel_stack_builder* builder, grpc_channel_stack_type channel_stack_type); -/** Create a call given a grpc_channel, in order to call \a method. - Progress is tied to activity on \a pollset_set. The returned call object is - meant to be used with \a grpc_call_start_batch_and_execute, which relies on - callbacks to signal completions. \a method and \a host need - only live through the invocation of this function. If \a parent_call is - non-NULL, it must be a server-side call. It will be used to propagate - properties from the server call to this new client call, depending on the - value of \a propagation_mask (see propagation_bits.h for possible values) */ +/** Create a call given a grpc_channel, in order to call \a method. + Progress is tied to activity on \a pollset_set. The returned call object is + meant to be used with \a grpc_call_start_batch_and_execute, which relies on + callbacks to signal completions. \a method and \a host need + only live through the invocation of this function. If \a parent_call is + non-NULL, it must be a server-side call. It will be used to propagate + properties from the server call to this new client call, depending on the + value of \a propagation_mask (see propagation_bits.h for possible values) */ grpc_call* grpc_channel_create_pollset_set_call( grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, grpc_pollset_set* pollset_set, const grpc_slice& method, const grpc_slice* host, grpc_millis deadline, void* reserved); - -/** Get a (borrowed) pointer to this channels underlying channel stack */ + +/** Get a (borrowed) pointer to this channels underlying channel stack */ grpc_channel_stack* grpc_channel_get_channel_stack(grpc_channel* channel); - + grpc_core::channelz::ChannelNode* grpc_channel_get_channelz_node( grpc_channel* channel); @@ -144,30 +144,30 @@ inline void grpc_channel_internal_unref(grpc_channel* channel, const char* reason) { GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(channel), reason); } -#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ - grpc_channel_internal_ref(channel, reason) +#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ + grpc_channel_internal_ref(channel, reason) #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \ grpc_channel_internal_unref(channel, reason) -#else +#else inline void grpc_channel_internal_ref(grpc_channel* channel) { GRPC_CHANNEL_STACK_REF(CHANNEL_STACK_FROM_CHANNEL(channel), "unused"); } inline void grpc_channel_internal_unref(grpc_channel* channel) { GRPC_CHANNEL_STACK_UNREF(CHANNEL_STACK_FROM_CHANNEL(channel), "unused"); } -#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ - grpc_channel_internal_ref(channel) +#define GRPC_CHANNEL_INTERNAL_REF(channel, reason) \ + grpc_channel_internal_ref(channel) #define GRPC_CHANNEL_INTERNAL_UNREF(channel, reason) \ grpc_channel_internal_unref(channel) -#endif - +#endif + // Return the channel's compression options. -grpc_compression_options grpc_channel_compression_options( +grpc_compression_options grpc_channel_compression_options( const grpc_channel* channel); - + // Ping the channels peer (load balanced channels will select one sub-channel to // ping); if the channel is not connected, posts a failed. void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq, void* tag, void* reserved); -#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */ +#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/channel_init.h b/contrib/libs/grpc/src/core/lib/surface/channel_init.h index d17a721606..12337945a0 100644 --- a/contrib/libs/grpc/src/core/lib/surface/channel_init.h +++ b/contrib/libs/grpc/src/core/lib/surface/channel_init.h @@ -1,78 +1,78 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H -#define GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H +#define GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/channel/channel_stack_builder.h" -#include "src/core/lib/surface/channel_stack_type.h" -#include "src/core/lib/transport/transport.h" - -#define GRPC_CHANNEL_INIT_BUILTIN_PRIORITY 10000 - -/// This module provides a way for plugins (and the grpc core library itself) -/// to register mutators for channel stacks. -/// It also provides a universal entry path to run those mutators to build -/// a channel stack for various subsystems. - -/// One stage of mutation: call functions against \a builder to influence the -/// finally constructed channel stack +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/surface/channel_stack_type.h" +#include "src/core/lib/transport/transport.h" + +#define GRPC_CHANNEL_INIT_BUILTIN_PRIORITY 10000 + +/// This module provides a way for plugins (and the grpc core library itself) +/// to register mutators for channel stacks. +/// It also provides a universal entry path to run those mutators to build +/// a channel stack for various subsystems. + +/// One stage of mutation: call functions against \a builder to influence the +/// finally constructed channel stack typedef bool (*grpc_channel_init_stage)(grpc_channel_stack_builder* builder, void* arg); - -/// Global initialization of the system -void grpc_channel_init_init(void); - -/// Register one stage of mutators. -/// Stages are run in priority order (lowest to highest), and then in -/// registration order (in the case of a tie). -/// Stages are registered against one of the pre-determined channel stack -/// types. + +/// Global initialization of the system +void grpc_channel_init_init(void); + +/// Register one stage of mutators. +/// Stages are run in priority order (lowest to highest), and then in +/// registration order (in the case of a tie). +/// Stages are registered against one of the pre-determined channel stack +/// types. /// If the channel stack type is GRPC_CLIENT_SUBCHANNEL, the caller should /// ensure that subchannels with different filter lists will always have /// different channel args. This requires setting a channel arg in case the /// registration function relies on some condition other than channel args to /// decide whether to add a filter or not. -void grpc_channel_init_register_stage(grpc_channel_stack_type type, - int priority, - grpc_channel_init_stage stage_fn, +void grpc_channel_init_register_stage(grpc_channel_stack_type type, + int priority, + grpc_channel_init_stage stage_fn, void* stage_arg); - -/// Finalize registration. No more calls to grpc_channel_init_register_stage are -/// allowed. -void grpc_channel_init_finalize(void); -/// Shutdown the channel init system -void grpc_channel_init_shutdown(void); - -/// Construct a channel stack of some sort: see channel_stack.h for details -/// \a type is the type of channel stack to create -/// \a prefix_bytes is the number of bytes before the channel stack to allocate -/// \a args are configuration arguments for the channel stack -/// \a initial_refs is the initial refcount to give the channel stack -/// \a destroy and \a destroy_arg specify how to destroy the channel stack -/// if destroy_arg is NULL, the returned value from this function will be -/// substituted -/// \a optional_transport is either NULL or a constructed transport object -/// Returns a pointer to the base of the memory allocated (the actual channel -/// stack object will be prefix_bytes past that pointer) + +/// Finalize registration. No more calls to grpc_channel_init_register_stage are +/// allowed. +void grpc_channel_init_finalize(void); +/// Shutdown the channel init system +void grpc_channel_init_shutdown(void); + +/// Construct a channel stack of some sort: see channel_stack.h for details +/// \a type is the type of channel stack to create +/// \a prefix_bytes is the number of bytes before the channel stack to allocate +/// \a args are configuration arguments for the channel stack +/// \a initial_refs is the initial refcount to give the channel stack +/// \a destroy and \a destroy_arg specify how to destroy the channel stack +/// if destroy_arg is NULL, the returned value from this function will be +/// substituted +/// \a optional_transport is either NULL or a constructed transport object +/// Returns a pointer to the base of the memory allocated (the actual channel +/// stack object will be prefix_bytes past that pointer) bool grpc_channel_init_create_stack(grpc_channel_stack_builder* builder, - grpc_channel_stack_type type); - -#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */ + grpc_channel_stack_type type); + +#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_INIT_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/channel_stack_type.h b/contrib/libs/grpc/src/core/lib/surface/channel_stack_type.h index 8a3c08e1cc..6eb92e3008 100644 --- a/contrib/libs/grpc/src/core/lib/surface/channel_stack_type.h +++ b/contrib/libs/grpc/src/core/lib/surface/channel_stack_type.h @@ -1,47 +1,47 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H -#define GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H +#define GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H + #include <grpc/support/port_platform.h> -#include <stdbool.h> - -typedef enum { - // normal top-half client channel with load-balancing, connection management - GRPC_CLIENT_CHANNEL, - // bottom-half of a client channel: everything that happens post-load - // balancing (bound to a specific transport) - GRPC_CLIENT_SUBCHANNEL, - // a permanently broken client channel - GRPC_CLIENT_LAME_CHANNEL, - // a directly connected client channel (without load-balancing, directly talks - // to a transport) - GRPC_CLIENT_DIRECT_CHANNEL, - // server side channel - GRPC_SERVER_CHANNEL, - // must be last - GRPC_NUM_CHANNEL_STACK_TYPES -} grpc_channel_stack_type; - -bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type); - +#include <stdbool.h> + +typedef enum { + // normal top-half client channel with load-balancing, connection management + GRPC_CLIENT_CHANNEL, + // bottom-half of a client channel: everything that happens post-load + // balancing (bound to a specific transport) + GRPC_CLIENT_SUBCHANNEL, + // a permanently broken client channel + GRPC_CLIENT_LAME_CHANNEL, + // a directly connected client channel (without load-balancing, directly talks + // to a transport) + GRPC_CLIENT_DIRECT_CHANNEL, + // server side channel + GRPC_SERVER_CHANNEL, + // must be last + GRPC_NUM_CHANNEL_STACK_TYPES +} grpc_channel_stack_type; + +bool grpc_channel_stack_type_is_client(grpc_channel_stack_type type); + const char* grpc_channel_stack_type_string(grpc_channel_stack_type type); -#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ +#endif /* GRPC_CORE_LIB_SURFACE_CHANNEL_STACK_TYPE_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/completion_queue.h b/contrib/libs/grpc/src/core/lib/surface/completion_queue.h index 4a114be828..78f2c686a2 100644 --- a/contrib/libs/grpc/src/core/lib/surface/completion_queue.h +++ b/contrib/libs/grpc/src/core/lib/surface/completion_queue.h @@ -1,97 +1,97 @@ -/* - * +/* + * * Copyright 2015-2016 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 GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H -#define GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H - -/* Internal API for completion queues */ - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H +#define GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H + +/* Internal API for completion queues */ + #include <grpc/support/port_platform.h> -#include <grpc/grpc.h> +#include <grpc/grpc.h> #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/iomgr/pollset.h" - -/* These trace flags default to 1. The corresponding lines are only traced - if grpc_api_trace is also truthy */ +#include "src/core/lib/iomgr/pollset.h" + +/* These trace flags default to 1. The corresponding lines are only traced + if grpc_api_trace is also truthy */ extern grpc_core::TraceFlag grpc_cq_pluck_trace; extern grpc_core::TraceFlag grpc_trace_operation_failures; extern grpc_core::DebugOnlyTraceFlag grpc_trace_pending_tags; extern grpc_core::DebugOnlyTraceFlag grpc_trace_cq_refcount; - -typedef struct grpc_cq_completion { + +typedef struct grpc_cq_completion { grpc_core::ManualConstructor<grpc_core::MultiProducerSingleConsumerQueue> node; - /** user supplied tag */ + /** user supplied tag */ void* tag; - /** done callback - called when this queue element is no longer - needed by the completion queue */ + /** done callback - called when this queue element is no longer + needed by the completion queue */ void (*done)(void* done_arg, struct grpc_cq_completion* c); void* done_arg; - /** next pointer; low bit is used to indicate success or not */ - uintptr_t next; -} grpc_cq_completion; - + /** next pointer; low bit is used to indicate success or not */ + uintptr_t next; +} grpc_cq_completion; + #ifndef NDEBUG void grpc_cq_internal_ref(grpc_completion_queue* cc, const char* reason, const char* file, int line); void grpc_cq_internal_unref(grpc_completion_queue* cc, const char* reason, const char* file, int line); -#define GRPC_CQ_INTERNAL_REF(cc, reason) \ - grpc_cq_internal_ref(cc, reason, __FILE__, __LINE__) -#define GRPC_CQ_INTERNAL_UNREF(cc, reason) \ - grpc_cq_internal_unref(cc, reason, __FILE__, __LINE__) -#else +#define GRPC_CQ_INTERNAL_REF(cc, reason) \ + grpc_cq_internal_ref(cc, reason, __FILE__, __LINE__) +#define GRPC_CQ_INTERNAL_UNREF(cc, reason) \ + grpc_cq_internal_unref(cc, reason, __FILE__, __LINE__) +#else void grpc_cq_internal_ref(grpc_completion_queue* cc); void grpc_cq_internal_unref(grpc_completion_queue* cc); -#define GRPC_CQ_INTERNAL_REF(cc, reason) grpc_cq_internal_ref(cc) -#define GRPC_CQ_INTERNAL_UNREF(cc, reason) grpc_cq_internal_unref(cc) -#endif - +#define GRPC_CQ_INTERNAL_REF(cc, reason) grpc_cq_internal_ref(cc) +#define GRPC_CQ_INTERNAL_UNREF(cc, reason) grpc_cq_internal_unref(cc) +#endif + /* Initializes global variables used by completion queues */ void grpc_cq_global_init(); -/* Flag that an operation is beginning: the completion channel will not finish - shutdown until a corrensponding grpc_cq_end_* call is made. +/* Flag that an operation is beginning: the completion channel will not finish + shutdown until a corrensponding grpc_cq_end_* call is made. \a tag is currently used only in debug builds. Return true on success, and false if completion_queue has been shutdown. */ bool grpc_cq_begin_op(grpc_completion_queue* cc, void* tag); - -/* Queue a GRPC_OP_COMPLETED operation; tag must correspond to the tag passed to - grpc_cq_begin_op */ + +/* Queue a GRPC_OP_COMPLETED operation; tag must correspond to the tag passed to + grpc_cq_begin_op */ void grpc_cq_end_op(grpc_completion_queue* cc, void* tag, grpc_error* error, void (*done)(void* done_arg, grpc_cq_completion* storage), void* done_arg, grpc_cq_completion* storage, bool internal = false); - + grpc_pollset* grpc_cq_pollset(grpc_completion_queue* cc); - + bool grpc_cq_can_listen(grpc_completion_queue* cc); - + grpc_cq_completion_type grpc_get_cq_completion_type(grpc_completion_queue* cc); - + int grpc_get_cq_poll_num(grpc_completion_queue* cc); grpc_completion_queue* grpc_completion_queue_create_internal( grpc_cq_completion_type completion_type, grpc_cq_polling_type polling_type, grpc_experimental_completion_queue_functor* shutdown_callback); -#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H */ +#endif /* GRPC_CORE_LIB_SURFACE_COMPLETION_QUEUE_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/event_string.h b/contrib/libs/grpc/src/core/lib/surface/event_string.h index f4ad847b3c..ea077ba105 100644 --- a/contrib/libs/grpc/src/core/lib/surface/event_string.h +++ b/contrib/libs/grpc/src/core/lib/surface/event_string.h @@ -1,31 +1,31 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_EVENT_STRING_H -#define GRPC_CORE_LIB_SURFACE_EVENT_STRING_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_EVENT_STRING_H +#define GRPC_CORE_LIB_SURFACE_EVENT_STRING_H + #include <grpc/support/port_platform.h> #include <util/generic/string.h> -#include <grpc/grpc.h> - -/* Returns a string describing an event. Must be later freed with gpr_free() */ +#include <grpc/grpc.h> + +/* Returns a string describing an event. Must be later freed with gpr_free() */ TString grpc_event_string(grpc_event* ev); - -#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ + +#endif /* GRPC_CORE_LIB_SURFACE_EVENT_STRING_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/init.h b/contrib/libs/grpc/src/core/lib/surface/init.h index 6eaa488d05..cb1082d6f8 100644 --- a/contrib/libs/grpc/src/core/lib/surface/init.h +++ b/contrib/libs/grpc/src/core/lib/surface/init.h @@ -1,27 +1,27 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_SURFACE_INIT_H -#define GRPC_CORE_LIB_SURFACE_INIT_H - -void grpc_register_security_filters(void); -void grpc_security_pre_init(void); -void grpc_security_init(void); + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_INIT_H +#define GRPC_CORE_LIB_SURFACE_INIT_H + +void grpc_register_security_filters(void); +void grpc_security_pre_init(void); +void grpc_security_init(void); void grpc_maybe_wait_for_async_shutdown(void); - -#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ + +#endif /* GRPC_CORE_LIB_SURFACE_INIT_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/lame_client.h b/contrib/libs/grpc/src/core/lib/surface/lame_client.h index aefa67c24a..0da23196b6 100644 --- a/contrib/libs/grpc/src/core/lib/surface/lame_client.h +++ b/contrib/libs/grpc/src/core/lib/surface/lame_client.h @@ -1,28 +1,28 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H -#define GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H - + * + */ + +#ifndef GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H +#define GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/channel/channel_stack.h" - -extern const grpc_channel_filter grpc_lame_filter; - -#endif /* GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H */ +#include "src/core/lib/channel/channel_stack.h" + +extern const grpc_channel_filter grpc_lame_filter; + +#endif /* GRPC_CORE_LIB_SURFACE_LAME_CLIENT_H */ diff --git a/contrib/libs/grpc/src/core/lib/surface/server.h b/contrib/libs/grpc/src/core/lib/surface/server.h index f4f4ff6449..5ba15e5cf0 100644 --- a/contrib/libs/grpc/src/core/lib/surface/server.h +++ b/contrib/libs/grpc/src/core/lib/surface/server.h @@ -13,10 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. // - -#ifndef GRPC_CORE_LIB_SURFACE_SERVER_H -#define GRPC_CORE_LIB_SURFACE_SERVER_H - + +#ifndef GRPC_CORE_LIB_SURFACE_SERVER_H +#define GRPC_CORE_LIB_SURFACE_SERVER_H + #include <grpc/support/port_platform.h> #include <list> @@ -24,28 +24,28 @@ #include "y_absl/types/optional.h" -#include <grpc/grpc.h> +#include <grpc/grpc.h> #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/channelz.h" #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/surface/completion_queue.h" -#include "src/core/lib/transport/transport.h" - +#include "src/core/lib/transport/transport.h" + namespace grpc_core { - + extern TraceFlag grpc_server_channel_trace; - + class Server : public InternallyRefCounted<Server> { public: // Filter vtable. static const grpc_channel_filter kServerTopFilter; - + // Opaque type used for registered methods. struct RegisteredMethod; - + // An object to represent the most relevant characteristics of a // newly-allocated call object when using an AllocatingRequestMatcherBatch. struct BatchCallAllocation { @@ -65,7 +65,7 @@ class Server : public InternallyRefCounted<Server> { gpr_timespec* deadline; grpc_byte_buffer** optional_payload; }; - + /// Interface for listeners. /// Implementations must override the Orphan() method, which should stop /// listening and initiate destruction of the listener. @@ -77,11 +77,11 @@ class Server : public InternallyRefCounted<Server> { /// this call, so it is a pointer rather than a reference. virtual void Start(Server* server, const std::vector<grpc_pollset*>* pollsets) = 0; - + /// Returns the channelz node for the listen socket, or null if not /// supported. virtual channelz::ListenSocketNode* channelz_listen_socket_node() const = 0; - + /// Sets a closure to be invoked by the listener when its destruction /// is complete. virtual void SetOnDestroyDone(grpc_closure* on_destroy_done) = 0; @@ -394,4 +394,4 @@ struct grpc_server { grpc_core::OrphanablePtr<grpc_core::Server> core_server; }; -#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ +#endif /* GRPC_CORE_LIB_SURFACE_SERVER_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/README.md b/contrib/libs/grpc/src/core/lib/transport/README.md index e7e135edeb..345e1bcd04 100644 --- a/contrib/libs/grpc/src/core/lib/transport/README.md +++ b/contrib/libs/grpc/src/core/lib/transport/README.md @@ -1,7 +1,7 @@ -# Transport - -Common implementation details for gRPC Transports. - -Transports multiplex messages across some single connection. In ext/ there are -implementations atop [a custom http2 implementation](/src/core/ext/transport/chttp2/README.md) -and atop [cronet](/src/core/ext/transport/cronet/README.md). +# Transport + +Common implementation details for gRPC Transports. + +Transports multiplex messages across some single connection. In ext/ there are +implementations atop [a custom http2 implementation](/src/core/ext/transport/chttp2/README.md) +and atop [cronet](/src/core/ext/transport/cronet/README.md). diff --git a/contrib/libs/grpc/src/core/lib/transport/byte_stream.h b/contrib/libs/grpc/src/core/lib/transport/byte_stream.h index ecb605ad9b..64e27cfbf7 100644 --- a/contrib/libs/grpc/src/core/lib/transport/byte_stream.h +++ b/contrib/libs/grpc/src/core/lib/transport/byte_stream.h @@ -1,43 +1,43 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H -#define GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H +#define GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H + #include <grpc/support/port_platform.h> -#include <grpc/slice_buffer.h> +#include <grpc/slice_buffer.h> #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/closure.h" - -/** Internal bit flag for grpc_begin_message's \a flags signaling the use of + +/** Internal bit flag for grpc_begin_message's \a flags signaling the use of * compression for the message. (Does not apply for stream compression.) */ -#define GRPC_WRITE_INTERNAL_COMPRESS (0x80000000u) +#define GRPC_WRITE_INTERNAL_COMPRESS (0x80000000u) /** Internal bit flag for determining whether the message was compressed and had * to be decompressed by the message_decompress filter. (Does not apply for * stream compression.) */ #define GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED (0x40000000u) -/** Mask of all valid internal flags. */ +/** Mask of all valid internal flags. */ #define GRPC_WRITE_INTERNAL_USED_MASK \ (GRPC_WRITE_INTERNAL_COMPRESS | GRPC_WRITE_INTERNAL_TEST_ONLY_WAS_COMPRESSED) - + namespace grpc_core { - + class ByteStream : public Orphanable { public: virtual ~ByteStream() {} @@ -79,23 +79,23 @@ class ByteStream : public Orphanable { private: const uint32_t length_; uint32_t flags_; -}; - +}; + // // SliceBufferByteStream // // A ByteStream that wraps a slice buffer. // - + class SliceBufferByteStream : public ByteStream { public: // Removes all slices in slice_buffer, leaving it empty. SliceBufferByteStream(grpc_slice_buffer* slice_buffer, uint32_t flags); - + ~SliceBufferByteStream(); - + void Orphan() override; - + bool Next(size_t max_size_hint, grpc_closure* on_complete) override; grpc_error* Pull(grpc_slice* slice) override; void Shutdown(grpc_error* error) override; @@ -162,4 +162,4 @@ class ByteStreamCache { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h index 9e34c646c7..ec1bf0f835 100644 --- a/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h +++ b/contrib/libs/grpc/src/core/lib/transport/connectivity_state.h @@ -1,29 +1,29 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H -#define GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H +#define GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H + #include <grpc/support/port_platform.h> #include "y_absl/status/status.h" -#include <grpc/grpc.h> +#include <grpc/grpc.h> #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/atomic.h" @@ -32,14 +32,14 @@ #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/work_serializer.h" - + namespace grpc_core { - + extern TraceFlag grpc_connectivity_state_trace; - + // Enum to string conversion. const char* ConnectivityStateName(grpc_connectivity_state state); - + // Interface for watching connectivity state. // Subclasses must implement the Notify() method. // @@ -49,14 +49,14 @@ class ConnectivityStateWatcherInterface : public InternallyRefCounted<ConnectivityStateWatcherInterface> { public: virtual ~ConnectivityStateWatcherInterface() = default; - + // Notifies the watcher that the state has changed to new_state. virtual void Notify(grpc_connectivity_state new_state, const y_absl::Status& status) = 0; - + void Orphan() override { Unref(); } }; - + // An alternative watcher interface that performs notifications via an // asynchronous callback scheduled on the ExecCtx. // Subclasses must implement the OnConnectivityStateChange() method. @@ -64,12 +64,12 @@ class AsyncConnectivityStateWatcherInterface : public ConnectivityStateWatcherInterface { public: virtual ~AsyncConnectivityStateWatcherInterface() = default; - + // Schedules a closure on the ExecCtx to invoke // OnConnectivityStateChange() asynchronously. void Notify(grpc_connectivity_state new_state, const y_absl::Status& status) override final; - + protected: class Notifier; @@ -78,7 +78,7 @@ class AsyncConnectivityStateWatcherInterface explicit AsyncConnectivityStateWatcherInterface( std::shared_ptr<WorkSerializer> work_serializer = nullptr) : work_serializer_(std::move(work_serializer)) {} - + // Invoked asynchronously when Notify() is called. virtual void OnConnectivityStateChange(grpc_connectivity_state new_state, const y_absl::Status& status) = 0; @@ -140,4 +140,4 @@ class ConnectivityStateTracker { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_CONNECTIVITY_STATE_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/metadata.h b/contrib/libs/grpc/src/core/lib/transport/metadata.h index 4bb8d64dd0..81ca52af0e 100644 --- a/contrib/libs/grpc/src/core/lib/transport/metadata.h +++ b/contrib/libs/grpc/src/core/lib/transport/metadata.h @@ -1,78 +1,78 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_METADATA_H -#define GRPC_CORE_LIB_TRANSPORT_METADATA_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_METADATA_H +#define GRPC_CORE_LIB_TRANSPORT_METADATA_H + #include <grpc/support/port_platform.h> #include <grpc/impl/codegen/log.h> #include <grpc/grpc.h> -#include <grpc/slice.h> - +#include <grpc/slice.h> + #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/atomic.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/slice/slice_utils.h" - + extern grpc_core::DebugOnlyTraceFlag grpc_trace_metadata; - -/* This file provides a mechanism for tracking metadata through the grpc stack. - It's not intended for consumption outside of the library. - + +/* This file provides a mechanism for tracking metadata through the grpc stack. + It's not intended for consumption outside of the library. + Metadata is tracked in the context of a sharded global grpc_mdctx. The context tracks unique strings (grpc_mdstr) and pairs of strings - (grpc_mdelem). Any of these objects can be checked for equality by comparing - their pointers. These objects are reference counted. - - grpc_mdelem can additionally store a (non-NULL) user data pointer. This - pointer is intended to be used to cache semantic meaning of a metadata - element. For example, an OAuth token may cache the credentials it represents - and the time at which it expires in the mdelem user data. - - Combining this metadata cache and the hpack compression table allows us to - simply lookup complete preparsed objects quickly, incurring a few atomic - ops per metadata element on the fast path. - - grpc_mdelem instances MAY live longer than their refcount implies, and are - garbage collected periodically, meaning cached data can easily outlive a - single request. - - STATIC METADATA: in static_metadata.h we declare a set of static metadata. - These mdelems and mdstrs are available via pre-declared code generated macros - and are available to code anywhere between grpc_init() and grpc_shutdown(). - They are not refcounted, but can be passed to _ref and _unref functions - declared here - in which case those functions are effectively no-ops. */ - -/* Forward declarations */ -typedef struct grpc_mdelem grpc_mdelem; - + (grpc_mdelem). Any of these objects can be checked for equality by comparing + their pointers. These objects are reference counted. + + grpc_mdelem can additionally store a (non-NULL) user data pointer. This + pointer is intended to be used to cache semantic meaning of a metadata + element. For example, an OAuth token may cache the credentials it represents + and the time at which it expires in the mdelem user data. + + Combining this metadata cache and the hpack compression table allows us to + simply lookup complete preparsed objects quickly, incurring a few atomic + ops per metadata element on the fast path. + + grpc_mdelem instances MAY live longer than their refcount implies, and are + garbage collected periodically, meaning cached data can easily outlive a + single request. + + STATIC METADATA: in static_metadata.h we declare a set of static metadata. + These mdelems and mdstrs are available via pre-declared code generated macros + and are available to code anywhere between grpc_init() and grpc_shutdown(). + They are not refcounted, but can be passed to _ref and _unref functions + declared here - in which case those functions are effectively no-ops. */ + +/* Forward declarations */ +typedef struct grpc_mdelem grpc_mdelem; + /* if changing this, make identical changes in: - grpc_core::{InternedMetadata, AllocatedMetadata} - grpc_metadata in grpc_types.h */ typedef struct grpc_mdelem_data { const grpc_slice key; const grpc_slice value; - /* there is a private part to this in metadata.c */ + /* there is a private part to this in metadata.c */ } grpc_mdelem_data; - + /* GRPC_MDELEM_STORAGE_* enum values that can be treated as interned always have this bit set in their integer value */ #define GRPC_MDELEM_STORAGE_INTERNED_BIT 1 @@ -95,12 +95,12 @@ typedef enum { GRPC_MDELEM_STORAGE_INTERNED = 2 | GRPC_MDELEM_STORAGE_INTERNED_BIT, } grpc_mdelem_data_storage; -struct grpc_mdelem { +struct grpc_mdelem { /* a grpc_mdelem_data* generally, with the two lower bits signalling memory ownership as per grpc_mdelem_data_storage */ uintptr_t payload; -}; - +}; + #define GRPC_MDELEM_DATA(md) ((grpc_mdelem_data*)((md).payload & ~(uintptr_t)3)) #define GRPC_MDELEM_STORAGE(md) \ ((grpc_mdelem_data_storage)((md).payload & (uintptr_t)3)) @@ -114,14 +114,14 @@ struct grpc_mdelem { #define GRPC_MDELEM_IS_INTERNED(md) \ ((grpc_mdelem_data_storage)((md).payload & \ (uintptr_t)GRPC_MDELEM_STORAGE_INTERNED_BIT)) - + /* Given arbitrary input slices, create a grpc_mdelem object. The caller refs * the input slices; we unref them. This method is always safe to call; however, * if we know data about the slices in question (e.g. if we knew our key was * static) we can call specializations that save on cycle count. */ grpc_mdelem grpc_mdelem_from_slices(const grpc_slice& key, const grpc_slice& value); - + /* Like grpc_mdelem_from_slices, but we know that key is a static slice. This saves us a few branches and a no-op call to md_unref() for the key. */ grpc_mdelem grpc_mdelem_from_slices(const grpc_core::StaticMetadataSlice& key, @@ -143,7 +143,7 @@ grpc_mdelem grpc_mdelem_from_slices(const grpc_core::ManagedMemorySlice& key, /* Cheaply convert a grpc_metadata to a grpc_mdelem; may use the grpc_metadata object as backing storage (so lifetimes should align) */ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata); - + /* Does not unref the slices; if a new non-interned mdelem is needed, allocates one if compatible_external_backing_store is NULL, or uses compatible_external_backing_store if it is non-NULL (in which case it's the @@ -151,7 +151,7 @@ grpc_mdelem grpc_mdelem_from_grpc_metadata(grpc_metadata* metadata); grpc_mdelem grpc_mdelem_create( const grpc_slice& key, const grpc_slice& value, grpc_mdelem_data* compatible_external_backing_store); - + /* Like grpc_mdelem_create, but we know that key is static. */ grpc_mdelem grpc_mdelem_create( const grpc_core::StaticMetadataSlice& key, const grpc_slice& value, @@ -170,7 +170,7 @@ inline bool grpc_mdelem_static_value_eq(grpc_mdelem a, grpc_mdelem b_static) { return grpc_slice_eq_static_interned(GRPC_MDVALUE(a), GRPC_MDVALUE(b_static)); } #define GRPC_MDISNULL(md) (GRPC_MDELEM_DATA(md) == NULL) - + inline bool grpc_mdelem_both_interned_eq(grpc_mdelem a_interned, grpc_mdelem b_interned) { GPR_DEBUG_ASSERT(GRPC_MDELEM_IS_INTERNED(a_interned) || @@ -180,12 +180,12 @@ inline bool grpc_mdelem_both_interned_eq(grpc_mdelem a_interned, return a_interned.payload == b_interned.payload; } -/* Mutator and accessor for grpc_mdelem user data. The destructor function - is used as a type tag and is checked during user_data fetch. */ +/* Mutator and accessor for grpc_mdelem user data. The destructor function + is used as a type tag and is checked during user_data fetch. */ void* grpc_mdelem_get_user_data(grpc_mdelem md, void (*if_destroy_func)(void*)); void* grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void*), void* data); - + // Defined in metadata.cc. struct mdtab_shard; @@ -328,7 +328,7 @@ class AllocatedMetadata : public RefcountedMdBase { } // namespace grpc_core #ifndef NDEBUG -#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__) +#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__) inline grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd, const char* file, int line) { #else // ifndef NDEBUG @@ -369,12 +369,12 @@ inline grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd) { void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, uint32_t hash, const char* file, int line); inline void grpc_mdelem_unref(grpc_mdelem gmd, const char* file, int line) { -#else +#else #define GRPC_MDELEM_UNREF(s) grpc_mdelem_unref((s)) void grpc_mdelem_on_final_unref(grpc_mdelem_data_storage storage, void* ptr, uint32_t hash); inline void grpc_mdelem_unref(grpc_mdelem gmd) { -#endif +#endif const grpc_mdelem_data_storage storage = GRPC_MDELEM_STORAGE(gmd); switch (storage) { case GRPC_MDELEM_STORAGE_EXTERNAL: @@ -399,19 +399,19 @@ inline void grpc_mdelem_unref(grpc_mdelem gmd) { return; } } - + #define GRPC_MDNULL GRPC_MAKE_MDELEM(NULL, GRPC_MDELEM_STORAGE_EXTERNAL) - -/* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ + +/* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ #define GRPC_MDELEM_LENGTH(e) \ (GRPC_SLICE_LENGTH(GRPC_MDKEY((e))) + GRPC_SLICE_LENGTH(GRPC_MDVALUE((e))) + \ 32) - -#define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash)) - -void grpc_mdctx_global_init(void); + +#define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash)) + +void grpc_mdctx_global_init(void); void grpc_mdctx_global_shutdown(); - + /* Like grpc_mdelem_from_slices, but we know that key is a static or interned slice and value is not static or interned. This gives us an inlinable fastpath - we know we must allocate metadata now, and that we do not need to @@ -443,4 +443,4 @@ inline grpc_mdelem grpc_mdelem_from_slices( GRPC_MDELEM_STORAGE_ALLOCATED); } -#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/metadata_batch.h b/contrib/libs/grpc/src/core/lib/transport/metadata_batch.h index 3101f485a2..cf37dbd82b 100644 --- a/contrib/libs/grpc/src/core/lib/transport/metadata_batch.h +++ b/contrib/libs/grpc/src/core/lib/transport/metadata_batch.h @@ -1,75 +1,75 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H -#define GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H +#define GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H + #include <grpc/support/port_platform.h> -#include <stdbool.h> - -#include <grpc/grpc.h> -#include <grpc/slice.h> -#include <grpc/support/time.h> +#include <stdbool.h> + +#include <grpc/grpc.h> +#include <grpc/slice.h> +#include <grpc/support/time.h> #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/static_metadata.h" - -typedef struct grpc_linked_mdelem { + +typedef struct grpc_linked_mdelem { grpc_linked_mdelem() {} grpc_mdelem md; struct grpc_linked_mdelem* next = nullptr; struct grpc_linked_mdelem* prev = nullptr; void* reserved; -} grpc_linked_mdelem; - -typedef struct grpc_mdelem_list { +} grpc_linked_mdelem; + +typedef struct grpc_mdelem_list { size_t count; size_t default_count; // Number of default keys. grpc_linked_mdelem* head; grpc_linked_mdelem* tail; -} grpc_mdelem_list; - -typedef struct grpc_metadata_batch { - /** Metadata elements in this batch */ - grpc_mdelem_list list; +} grpc_mdelem_list; + +typedef struct grpc_metadata_batch { + /** Metadata elements in this batch */ + grpc_mdelem_list list; grpc_metadata_batch_callouts idx; - /** Used to calculate grpc-timeout at the point of sending, + /** Used to calculate grpc-timeout at the point of sending, or GRPC_MILLIS_INF_FUTURE if this batch does not need to send a - grpc-timeout */ + grpc-timeout */ grpc_millis deadline; -} grpc_metadata_batch; - +} grpc_metadata_batch; + void grpc_metadata_batch_init(grpc_metadata_batch* batch); void grpc_metadata_batch_destroy(grpc_metadata_batch* batch); void grpc_metadata_batch_clear(grpc_metadata_batch* batch); bool grpc_metadata_batch_is_empty(grpc_metadata_batch* batch); - -/* Returns the transport size of the batch. */ + +/* Returns the transport size of the batch. */ size_t grpc_metadata_batch_size(grpc_metadata_batch* batch); - + /** Remove \a storage from the batch, unreffing the mdelem contained */ void grpc_metadata_batch_remove(grpc_metadata_batch* batch, grpc_linked_mdelem* storage); void grpc_metadata_batch_remove(grpc_metadata_batch* batch, grpc_metadata_batch_callouts_index idx); - + /** Substitute a new mdelem for an old value */ grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch, grpc_linked_mdelem* storage, @@ -78,11 +78,11 @@ grpc_error* grpc_metadata_batch_substitute(grpc_metadata_batch* batch, void grpc_metadata_batch_set_value(grpc_linked_mdelem* storage, const grpc_slice& value); -/** Add \a storage to the beginning of \a batch. storage->md is - assumed to be valid. - \a storage is owned by the caller and must survive for the - lifetime of batch. This usually means it should be around - for the lifetime of the call. */ +/** Add \a storage to the beginning of \a batch. storage->md is + assumed to be valid. + \a storage is owned by the caller and must survive for the + lifetime of batch. This usually means it should be around + for the lifetime of the call. */ grpc_error* grpc_metadata_batch_link_head(grpc_metadata_batch* batch, grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT; @@ -90,24 +90,24 @@ grpc_error* grpc_metadata_batch_link_head( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_metadata_batch_callouts_index idx) GRPC_MUST_USE_RESULT; -/** Add \a storage to the end of \a batch. storage->md is - assumed to be valid. - \a storage is owned by the caller and must survive for the - lifetime of batch. This usually means it should be around - for the lifetime of the call. */ +/** Add \a storage to the end of \a batch. storage->md is + assumed to be valid. + \a storage is owned by the caller and must survive for the + lifetime of batch. This usually means it should be around + for the lifetime of the call. */ grpc_error* grpc_metadata_batch_link_tail(grpc_metadata_batch* batch, grpc_linked_mdelem* storage) GRPC_MUST_USE_RESULT; grpc_error* grpc_metadata_batch_link_tail( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_metadata_batch_callouts_index idx) GRPC_MUST_USE_RESULT; - -/** Add \a elem_to_add as the first element in \a batch, using - \a storage as backing storage for the linked list element. - \a storage is owned by the caller and must survive for the - lifetime of batch. This usually means it should be around - for the lifetime of the call. - Takes ownership of \a elem_to_add */ + +/** Add \a elem_to_add as the first element in \a batch, using + \a storage as backing storage for the linked list element. + \a storage is owned by the caller and must survive for the + lifetime of batch. This usually means it should be around + for the lifetime of the call. + Takes ownership of \a elem_to_add */ grpc_error* grpc_metadata_batch_add_head( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; @@ -128,16 +128,16 @@ inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_head( return grpc_metadata_batch_add_head(batch, storage, idx); } -/** Add \a elem_to_add as the last element in \a batch, using - \a storage as backing storage for the linked list element. - \a storage is owned by the caller and must survive for the - lifetime of batch. This usually means it should be around - for the lifetime of the call. - Takes ownership of \a elem_to_add */ +/** Add \a elem_to_add as the last element in \a batch, using + \a storage as backing storage for the linked list element. + \a storage is owned by the caller and must survive for the + lifetime of batch. This usually means it should be around + for the lifetime of the call. + Takes ownership of \a elem_to_add */ grpc_error* grpc_metadata_batch_add_tail( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_mdelem elem_to_add) GRPC_MUST_USE_RESULT; - + inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_tail( grpc_metadata_batch* batch, grpc_linked_mdelem* storage, grpc_metadata_batch_callouts_index idx) { @@ -153,7 +153,7 @@ inline grpc_error* GRPC_MUST_USE_RESULT grpc_metadata_batch_add_tail( } grpc_error* grpc_attach_md_to_error(grpc_error* src, grpc_mdelem md); - + struct grpc_filtered_mdelem { grpc_error* error; grpc_mdelem md; @@ -171,21 +171,21 @@ grpc_error* grpc_metadata_batch_filter( grpc_metadata_batch* batch, grpc_metadata_batch_filter_func func, void* user_data, const char* composite_error_string) GRPC_MUST_USE_RESULT; -#ifndef NDEBUG +#ifndef NDEBUG void grpc_metadata_batch_assert_ok(grpc_metadata_batch* comd); -#else -#define grpc_metadata_batch_assert_ok(comd) \ - do { \ - } while (0) -#endif - +#else +#define grpc_metadata_batch_assert_ok(comd) \ + do { \ + } while (0) +#endif + /// Copies \a src to \a dst. \a storage must point to an array of /// \a grpc_linked_mdelem structs of at least the same size as \a src. void grpc_metadata_batch_copy(grpc_metadata_batch* src, grpc_metadata_batch* dst, grpc_linked_mdelem* storage); - + void grpc_metadata_batch_move(grpc_metadata_batch* src, grpc_metadata_batch* dst); -#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_METADATA_BATCH_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/pid_controller.h b/contrib/libs/grpc/src/core/lib/transport/pid_controller.h index e26205bf20..37baeac336 100644 --- a/contrib/libs/grpc/src/core/lib/transport/pid_controller.h +++ b/contrib/libs/grpc/src/core/lib/transport/pid_controller.h @@ -1,37 +1,37 @@ -/* - * +/* + * * Copyright 2016 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 GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H -#define GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H +#define GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H + #include <grpc/support/port_platform.h> #include <limits> -/* \file Simple PID controller. - Implements a proportional-integral-derivative controller. - Used when we want to iteratively control a variable to converge some other - observed value to a 'set-point'. - Gains can be set to adjust sensitivity to current error (p), the integral - of error (i), and the derivative of error (d). */ - +/* \file Simple PID controller. + Implements a proportional-integral-derivative controller. + Used when we want to iteratively control a variable to converge some other + observed value to a 'set-point'. + Gains can be set to adjust sensitivity to current error (p), the integral + of error (i), and the derivative of error (d). */ + namespace grpc_core { - + class PidController { public: class Args { @@ -43,7 +43,7 @@ class PidController { double min_control_value() const { return min_control_value_; } double max_control_value() const { return max_control_value_; } double integral_range() const { return integral_range_; } - + Args& set_gain_p(double gain_p) { gain_p_ = gain_p; return *this; @@ -72,7 +72,7 @@ class PidController { integral_range_ = integral_range; return *this; } - + private: double gain_p_ = 0.0; double gain_i_ = 0.0; @@ -82,7 +82,7 @@ class PidController { double max_control_value_ = std::numeric_limits<double>::max(); double integral_range_ = std::numeric_limits<double>::max(); }; - + explicit PidController(const Args& args); /// Reset the controller internal state: useful when the environment has @@ -113,4 +113,4 @@ class PidController { } // namespace grpc_core -#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_PID_CONTROLLER_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/static_metadata.h b/contrib/libs/grpc/src/core/lib/transport/static_metadata.h index 5d844af558..38eca2dba4 100644 --- a/contrib/libs/grpc/src/core/lib/transport/static_metadata.h +++ b/contrib/libs/grpc/src/core/lib/transport/static_metadata.h @@ -1,38 +1,38 @@ -/* +/* * 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. - */ - -/* - * WARNING: Auto-generated code. - * - * To make changes to this file, change - * tools/codegen/core/gen_static_metadata.py, and then re-run it. - * + */ + +/* + * WARNING: Auto-generated code. + * + * To make changes to this file, change + * tools/codegen/core/gen_static_metadata.py, and then re-run it. + * * See metadata.h for an explanation of the interface here, and metadata.cc for - * an explanation of what's going on. - */ - -#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H -#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H - + * an explanation of what's going on. + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H +#define GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H + #include <grpc/support/port_platform.h> #include <cstdint> -#include "src/core/lib/transport/metadata.h" - +#include "src/core/lib/transport/metadata.h" + static_assert( std::is_trivially_destructible<grpc_core::StaticMetadataSlice>::value, "grpc_core::StaticMetadataSlice must be trivially destructible."); @@ -106,9 +106,9 @@ inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { #define GRPC_MDSTR_X_ENDPOINT_LOAD_METRICS_BIN (grpc_static_slice_table()[23]) /* "grpc-timeout" */ #define GRPC_MDSTR_GRPC_TIMEOUT (grpc_static_slice_table()[24]) -/* "1" */ +/* "1" */ #define GRPC_MDSTR_1 (grpc_static_slice_table()[25]) -/* "2" */ +/* "2" */ #define GRPC_MDSTR_2 (grpc_static_slice_table()[26]) /* "3" */ #define GRPC_MDSTR_3 (grpc_static_slice_table()[27]) @@ -166,103 +166,103 @@ inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { #define GRPC_MDSTR_HTTPS (grpc_static_slice_table()[48]) /* "200" */ #define GRPC_MDSTR_200 (grpc_static_slice_table()[49]) -/* "204" */ +/* "204" */ #define GRPC_MDSTR_204 (grpc_static_slice_table()[50]) -/* "206" */ +/* "206" */ #define GRPC_MDSTR_206 (grpc_static_slice_table()[51]) -/* "304" */ +/* "304" */ #define GRPC_MDSTR_304 (grpc_static_slice_table()[52]) -/* "400" */ +/* "400" */ #define GRPC_MDSTR_400 (grpc_static_slice_table()[53]) /* "404" */ #define GRPC_MDSTR_404 (grpc_static_slice_table()[54]) -/* "500" */ +/* "500" */ #define GRPC_MDSTR_500 (grpc_static_slice_table()[55]) -/* "accept-charset" */ +/* "accept-charset" */ #define GRPC_MDSTR_ACCEPT_CHARSET (grpc_static_slice_table()[56]) /* "gzip, deflate" */ #define GRPC_MDSTR_GZIP_COMMA_DEFLATE (grpc_static_slice_table()[57]) -/* "accept-language" */ +/* "accept-language" */ #define GRPC_MDSTR_ACCEPT_LANGUAGE (grpc_static_slice_table()[58]) -/* "accept-ranges" */ +/* "accept-ranges" */ #define GRPC_MDSTR_ACCEPT_RANGES (grpc_static_slice_table()[59]) /* "accept" */ #define GRPC_MDSTR_ACCEPT (grpc_static_slice_table()[60]) -/* "access-control-allow-origin" */ +/* "access-control-allow-origin" */ #define GRPC_MDSTR_ACCESS_CONTROL_ALLOW_ORIGIN (grpc_static_slice_table()[61]) -/* "age" */ +/* "age" */ #define GRPC_MDSTR_AGE (grpc_static_slice_table()[62]) -/* "allow" */ +/* "allow" */ #define GRPC_MDSTR_ALLOW (grpc_static_slice_table()[63]) -/* "authorization" */ +/* "authorization" */ #define GRPC_MDSTR_AUTHORIZATION (grpc_static_slice_table()[64]) -/* "cache-control" */ +/* "cache-control" */ #define GRPC_MDSTR_CACHE_CONTROL (grpc_static_slice_table()[65]) -/* "content-disposition" */ +/* "content-disposition" */ #define GRPC_MDSTR_CONTENT_DISPOSITION (grpc_static_slice_table()[66]) -/* "content-language" */ +/* "content-language" */ #define GRPC_MDSTR_CONTENT_LANGUAGE (grpc_static_slice_table()[67]) -/* "content-length" */ +/* "content-length" */ #define GRPC_MDSTR_CONTENT_LENGTH (grpc_static_slice_table()[68]) -/* "content-location" */ +/* "content-location" */ #define GRPC_MDSTR_CONTENT_LOCATION (grpc_static_slice_table()[69]) -/* "content-range" */ +/* "content-range" */ #define GRPC_MDSTR_CONTENT_RANGE (grpc_static_slice_table()[70]) -/* "cookie" */ +/* "cookie" */ #define GRPC_MDSTR_COOKIE (grpc_static_slice_table()[71]) -/* "date" */ +/* "date" */ #define GRPC_MDSTR_DATE (grpc_static_slice_table()[72]) -/* "etag" */ +/* "etag" */ #define GRPC_MDSTR_ETAG (grpc_static_slice_table()[73]) -/* "expect" */ +/* "expect" */ #define GRPC_MDSTR_EXPECT (grpc_static_slice_table()[74]) -/* "expires" */ +/* "expires" */ #define GRPC_MDSTR_EXPIRES (grpc_static_slice_table()[75]) -/* "from" */ +/* "from" */ #define GRPC_MDSTR_FROM (grpc_static_slice_table()[76]) -/* "if-match" */ +/* "if-match" */ #define GRPC_MDSTR_IF_MATCH (grpc_static_slice_table()[77]) -/* "if-modified-since" */ +/* "if-modified-since" */ #define GRPC_MDSTR_IF_MODIFIED_SINCE (grpc_static_slice_table()[78]) -/* "if-none-match" */ +/* "if-none-match" */ #define GRPC_MDSTR_IF_NONE_MATCH (grpc_static_slice_table()[79]) -/* "if-range" */ +/* "if-range" */ #define GRPC_MDSTR_IF_RANGE (grpc_static_slice_table()[80]) -/* "if-unmodified-since" */ +/* "if-unmodified-since" */ #define GRPC_MDSTR_IF_UNMODIFIED_SINCE (grpc_static_slice_table()[81]) -/* "last-modified" */ +/* "last-modified" */ #define GRPC_MDSTR_LAST_MODIFIED (grpc_static_slice_table()[82]) -/* "link" */ +/* "link" */ #define GRPC_MDSTR_LINK (grpc_static_slice_table()[83]) -/* "location" */ +/* "location" */ #define GRPC_MDSTR_LOCATION (grpc_static_slice_table()[84]) -/* "max-forwards" */ +/* "max-forwards" */ #define GRPC_MDSTR_MAX_FORWARDS (grpc_static_slice_table()[85]) -/* "proxy-authenticate" */ +/* "proxy-authenticate" */ #define GRPC_MDSTR_PROXY_AUTHENTICATE (grpc_static_slice_table()[86]) -/* "proxy-authorization" */ +/* "proxy-authorization" */ #define GRPC_MDSTR_PROXY_AUTHORIZATION (grpc_static_slice_table()[87]) -/* "range" */ +/* "range" */ #define GRPC_MDSTR_RANGE (grpc_static_slice_table()[88]) -/* "referer" */ +/* "referer" */ #define GRPC_MDSTR_REFERER (grpc_static_slice_table()[89]) -/* "refresh" */ +/* "refresh" */ #define GRPC_MDSTR_REFRESH (grpc_static_slice_table()[90]) -/* "retry-after" */ +/* "retry-after" */ #define GRPC_MDSTR_RETRY_AFTER (grpc_static_slice_table()[91]) -/* "server" */ +/* "server" */ #define GRPC_MDSTR_SERVER (grpc_static_slice_table()[92]) -/* "set-cookie" */ +/* "set-cookie" */ #define GRPC_MDSTR_SET_COOKIE (grpc_static_slice_table()[93]) -/* "strict-transport-security" */ +/* "strict-transport-security" */ #define GRPC_MDSTR_STRICT_TRANSPORT_SECURITY (grpc_static_slice_table()[94]) -/* "transfer-encoding" */ +/* "transfer-encoding" */ #define GRPC_MDSTR_TRANSFER_ENCODING (grpc_static_slice_table()[95]) -/* "vary" */ +/* "vary" */ #define GRPC_MDSTR_VARY (grpc_static_slice_table()[96]) -/* "via" */ +/* "via" */ #define GRPC_MDSTR_VIA (grpc_static_slice_table()[97]) -/* "www-authenticate" */ +/* "www-authenticate" */ #define GRPC_MDSTR_WWW_AUTHENTICATE (grpc_static_slice_table()[98]) /* "0" */ #define GRPC_MDSTR_0 (grpc_static_slice_table()[99]) @@ -287,7 +287,7 @@ inline const grpc_core::StaticMetadataSlice* grpc_static_slice_table() { /* "identity,deflate,gzip" */ #define GRPC_MDSTR_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ (grpc_static_slice_table()[109]) - + namespace grpc_core { struct StaticSliceRefcount; extern StaticSliceRefcount* g_static_metadata_slice_refcounts; @@ -326,7 +326,7 @@ inline grpc_mdelem* grpc_static_mdelem_manifested() { return grpc_core::g_static_mdelem_manifested; } -extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; +extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* ":authority": "" */ #define GRPC_MDELEM_AUTHORITY_EMPTY (grpc_static_mdelem_manifested()[0]) /* ":method": "GET" */ @@ -356,108 +356,108 @@ extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; #define GRPC_MDELEM_STATUS_404 (grpc_static_mdelem_manifested()[12]) /* ":status": "500" */ #define GRPC_MDELEM_STATUS_500 (grpc_static_mdelem_manifested()[13]) -/* "accept-charset": "" */ +/* "accept-charset": "" */ #define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (grpc_static_mdelem_manifested()[14]) -/* "accept-encoding": "gzip, deflate" */ -#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ +/* "accept-encoding": "gzip, deflate" */ +#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ (grpc_static_mdelem_manifested()[15]) -/* "accept-language": "" */ +/* "accept-language": "" */ #define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[16]) -/* "accept-ranges": "" */ +/* "accept-ranges": "" */ #define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (grpc_static_mdelem_manifested()[17]) /* "accept": "" */ #define GRPC_MDELEM_ACCEPT_EMPTY (grpc_static_mdelem_manifested()[18]) -/* "access-control-allow-origin": "" */ -#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ +/* "access-control-allow-origin": "" */ +#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ (grpc_static_mdelem_manifested()[19]) -/* "age": "" */ +/* "age": "" */ #define GRPC_MDELEM_AGE_EMPTY (grpc_static_mdelem_manifested()[20]) -/* "allow": "" */ +/* "allow": "" */ #define GRPC_MDELEM_ALLOW_EMPTY (grpc_static_mdelem_manifested()[21]) -/* "authorization": "" */ +/* "authorization": "" */ #define GRPC_MDELEM_AUTHORIZATION_EMPTY (grpc_static_mdelem_manifested()[22]) -/* "cache-control": "" */ +/* "cache-control": "" */ #define GRPC_MDELEM_CACHE_CONTROL_EMPTY (grpc_static_mdelem_manifested()[23]) -/* "content-disposition": "" */ +/* "content-disposition": "" */ #define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \ (grpc_static_mdelem_manifested()[24]) -/* "content-encoding": "" */ +/* "content-encoding": "" */ #define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (grpc_static_mdelem_manifested()[25]) -/* "content-language": "" */ +/* "content-language": "" */ #define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (grpc_static_mdelem_manifested()[26]) -/* "content-length": "" */ +/* "content-length": "" */ #define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (grpc_static_mdelem_manifested()[27]) -/* "content-location": "" */ +/* "content-location": "" */ #define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (grpc_static_mdelem_manifested()[28]) -/* "content-range": "" */ +/* "content-range": "" */ #define GRPC_MDELEM_CONTENT_RANGE_EMPTY (grpc_static_mdelem_manifested()[29]) -/* "content-type": "" */ +/* "content-type": "" */ #define GRPC_MDELEM_CONTENT_TYPE_EMPTY (grpc_static_mdelem_manifested()[30]) -/* "cookie": "" */ +/* "cookie": "" */ #define GRPC_MDELEM_COOKIE_EMPTY (grpc_static_mdelem_manifested()[31]) -/* "date": "" */ +/* "date": "" */ #define GRPC_MDELEM_DATE_EMPTY (grpc_static_mdelem_manifested()[32]) -/* "etag": "" */ +/* "etag": "" */ #define GRPC_MDELEM_ETAG_EMPTY (grpc_static_mdelem_manifested()[33]) -/* "expect": "" */ +/* "expect": "" */ #define GRPC_MDELEM_EXPECT_EMPTY (grpc_static_mdelem_manifested()[34]) -/* "expires": "" */ +/* "expires": "" */ #define GRPC_MDELEM_EXPIRES_EMPTY (grpc_static_mdelem_manifested()[35]) -/* "from": "" */ +/* "from": "" */ #define GRPC_MDELEM_FROM_EMPTY (grpc_static_mdelem_manifested()[36]) -/* "host": "" */ +/* "host": "" */ #define GRPC_MDELEM_HOST_EMPTY (grpc_static_mdelem_manifested()[37]) -/* "if-match": "" */ +/* "if-match": "" */ #define GRPC_MDELEM_IF_MATCH_EMPTY (grpc_static_mdelem_manifested()[38]) -/* "if-modified-since": "" */ +/* "if-modified-since": "" */ #define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \ (grpc_static_mdelem_manifested()[39]) -/* "if-none-match": "" */ +/* "if-none-match": "" */ #define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (grpc_static_mdelem_manifested()[40]) -/* "if-range": "" */ +/* "if-range": "" */ #define GRPC_MDELEM_IF_RANGE_EMPTY (grpc_static_mdelem_manifested()[41]) -/* "if-unmodified-since": "" */ +/* "if-unmodified-since": "" */ #define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \ (grpc_static_mdelem_manifested()[42]) -/* "last-modified": "" */ +/* "last-modified": "" */ #define GRPC_MDELEM_LAST_MODIFIED_EMPTY (grpc_static_mdelem_manifested()[43]) -/* "link": "" */ +/* "link": "" */ #define GRPC_MDELEM_LINK_EMPTY (grpc_static_mdelem_manifested()[44]) -/* "location": "" */ +/* "location": "" */ #define GRPC_MDELEM_LOCATION_EMPTY (grpc_static_mdelem_manifested()[45]) -/* "max-forwards": "" */ +/* "max-forwards": "" */ #define GRPC_MDELEM_MAX_FORWARDS_EMPTY (grpc_static_mdelem_manifested()[46]) -/* "proxy-authenticate": "" */ +/* "proxy-authenticate": "" */ #define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \ (grpc_static_mdelem_manifested()[47]) -/* "proxy-authorization": "" */ +/* "proxy-authorization": "" */ #define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \ (grpc_static_mdelem_manifested()[48]) -/* "range": "" */ +/* "range": "" */ #define GRPC_MDELEM_RANGE_EMPTY (grpc_static_mdelem_manifested()[49]) -/* "referer": "" */ +/* "referer": "" */ #define GRPC_MDELEM_REFERER_EMPTY (grpc_static_mdelem_manifested()[50]) -/* "refresh": "" */ +/* "refresh": "" */ #define GRPC_MDELEM_REFRESH_EMPTY (grpc_static_mdelem_manifested()[51]) -/* "retry-after": "" */ +/* "retry-after": "" */ #define GRPC_MDELEM_RETRY_AFTER_EMPTY (grpc_static_mdelem_manifested()[52]) -/* "server": "" */ +/* "server": "" */ #define GRPC_MDELEM_SERVER_EMPTY (grpc_static_mdelem_manifested()[53]) -/* "set-cookie": "" */ +/* "set-cookie": "" */ #define GRPC_MDELEM_SET_COOKIE_EMPTY (grpc_static_mdelem_manifested()[54]) -/* "strict-transport-security": "" */ -#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ +/* "strict-transport-security": "" */ +#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ (grpc_static_mdelem_manifested()[55]) -/* "transfer-encoding": "" */ +/* "transfer-encoding": "" */ #define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \ (grpc_static_mdelem_manifested()[56]) -/* "user-agent": "" */ +/* "user-agent": "" */ #define GRPC_MDELEM_USER_AGENT_EMPTY (grpc_static_mdelem_manifested()[57]) -/* "vary": "" */ +/* "vary": "" */ #define GRPC_MDELEM_VARY_EMPTY (grpc_static_mdelem_manifested()[58]) -/* "via": "" */ +/* "via": "" */ #define GRPC_MDELEM_VIA_EMPTY (grpc_static_mdelem_manifested()[59]) -/* "www-authenticate": "" */ +/* "www-authenticate": "" */ #define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (grpc_static_mdelem_manifested()[60]) /* "grpc-status": "0" */ #define GRPC_MDELEM_GRPC_STATUS_0 (grpc_static_mdelem_manifested()[61]) @@ -518,7 +518,7 @@ extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; /* "accept-encoding": "identity,gzip" */ #define GRPC_MDELEM_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ (grpc_static_mdelem_manifested()[84]) - + grpc_mdelem grpc_static_mdelem_for_static_strings(intptr_t a, intptr_t b); typedef enum { GRPC_BATCH_PATH, @@ -588,7 +588,7 @@ typedef union { ->index) \ : GRPC_BATCH_CALLOUTS_COUNT) -extern const uint8_t grpc_static_accept_encoding_metadata[8]; +extern const uint8_t grpc_static_accept_encoding_metadata[8]; #define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ (GRPC_MAKE_MDELEM(&grpc_static_mdelem_table() \ [grpc_static_accept_encoding_metadata[(algs)]] \ @@ -601,4 +601,4 @@ extern const uint8_t grpc_static_accept_stream_encoding_metadata[4]; [grpc_static_accept_stream_encoding_metadata[(algs)]] \ .data(), \ GRPC_MDELEM_STORAGE_STATIC)) -#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/timeout_encoding.h b/contrib/libs/grpc/src/core/lib/transport/timeout_encoding.h index c87ff39d49..aacc8178c7 100644 --- a/contrib/libs/grpc/src/core/lib/transport/timeout_encoding.h +++ b/contrib/libs/grpc/src/core/lib/transport/timeout_encoding.h @@ -1,38 +1,38 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H -#define GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H +#define GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H + #include <grpc/support/port_platform.h> #include <grpc/slice.h> -#include <grpc/support/time.h> - +#include <grpc/support/time.h> + #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/exec_ctx.h" #define GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE 10 - -/* Encode/decode timeouts to the GRPC over HTTP/2 format; + +/* Encode/decode timeouts to the GRPC over HTTP/2 format; encoding may round up arbitrarily. If the timeout is larger than about 1157 days, it will be capped and "99999999S" will be sent on the wire. */ void grpc_http2_encode_timeout(grpc_millis timeout, char* buffer); int grpc_http2_decode_timeout(const grpc_slice& text, grpc_millis* timeout); - -#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ + +#endif /* GRPC_CORE_LIB_TRANSPORT_TIMEOUT_ENCODING_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/transport.h b/contrib/libs/grpc/src/core/lib/transport/transport.h index 2404455f9f..b661ad4c4b 100644 --- a/contrib/libs/grpc/src/core/lib/transport/transport.h +++ b/contrib/libs/grpc/src/core/lib/transport/transport.h @@ -1,83 +1,83 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H -#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H +#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H + #include <grpc/support/port_platform.h> -#include <stddef.h> - -#include "src/core/lib/channel/context.h" +#include <stddef.h> + +#include "src/core/lib/channel/context.h" #include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/call_combiner.h" -#include "src/core/lib/iomgr/endpoint.h" -#include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/iomgr/pollset_set.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/polling_entity.h" +#include "src/core/lib/iomgr/pollset.h" +#include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/transport/byte_stream.h" +#include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/connectivity_state.h" -#include "src/core/lib/transport/metadata_batch.h" - +#include "src/core/lib/transport/metadata_batch.h" + /* Minimum and maximum protocol accepted versions. */ #define GRPC_PROTOCOL_VERSION_MAX_MAJOR 2 #define GRPC_PROTOCOL_VERSION_MAX_MINOR 1 #define GRPC_PROTOCOL_VERSION_MIN_MAJOR 2 #define GRPC_PROTOCOL_VERSION_MIN_MINOR 1 - -/* forward declarations */ - -typedef struct grpc_transport grpc_transport; - -/* grpc_stream doesn't actually exist. It's used as a typesafe - opaque pointer for whatever data the transport wants to track - for a stream. */ -typedef struct grpc_stream grpc_stream; - + +/* forward declarations */ + +typedef struct grpc_transport grpc_transport; + +/* grpc_stream doesn't actually exist. It's used as a typesafe + opaque pointer for whatever data the transport wants to track + for a stream. */ +typedef struct grpc_stream grpc_stream; + extern grpc_core::DebugOnlyTraceFlag grpc_trace_stream_refcount; - -typedef struct grpc_stream_refcount { + +typedef struct grpc_stream_refcount { grpc_core::RefCount refs; - grpc_closure destroy; + grpc_closure destroy; #ifndef NDEBUG const char* object_type; -#endif +#endif grpc_slice_refcount slice_refcount; -} grpc_stream_refcount; - +} grpc_stream_refcount; + #ifndef NDEBUG void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs, grpc_iomgr_cb_func cb, void* cb_arg, const char* object_type); -#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \ - grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype) -#else +#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \ + grpc_stream_ref_init(rc, ir, cb, cb_arg, objtype) +#else void grpc_stream_ref_init(grpc_stream_refcount* refcount, int initial_refs, grpc_iomgr_cb_func cb, void* cb_arg); -#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \ +#define GRPC_STREAM_REF_INIT(rc, ir, cb, cb_arg, objtype) \ do { \ grpc_stream_ref_init(rc, ir, cb, cb_arg); \ (void)(objtype); \ } while (0) -#endif - +#endif + #ifndef NDEBUG inline void grpc_stream_ref(grpc_stream_refcount* refcount, const char* reason) { @@ -124,18 +124,18 @@ struct grpc_transport_one_way_stats { uint64_t data_bytes = 0; uint64_t header_bytes = 0; }; - + struct grpc_transport_stream_stats { - grpc_transport_one_way_stats incoming; - grpc_transport_one_way_stats outgoing; + grpc_transport_one_way_stats incoming; + grpc_transport_one_way_stats outgoing; }; - + void grpc_transport_move_one_way_stats(grpc_transport_one_way_stats* from, grpc_transport_one_way_stats* to); - + void grpc_transport_move_stats(grpc_transport_stream_stats* from, grpc_transport_stream_stats* to); - + // This struct (which is present in both grpc_transport_stream_op_batch // and grpc_transport_op_batch) is a convenience to allow filters or // transports to schedule a closure related to a particular batch without @@ -151,15 +151,15 @@ void grpc_transport_move_stats(grpc_transport_stream_stats* from, // this struct anymore, because the next handler may reuse it. struct grpc_handler_private_op_data { void* extra_arg = nullptr; - grpc_closure closure; + grpc_closure closure; grpc_handler_private_op_data() { memset(&closure, 0, sizeof(closure)); } }; - + typedef struct grpc_transport_stream_op_batch_payload grpc_transport_stream_op_batch_payload; -/* Transport stream op: a set of operations to perform on a transport - against a single stream */ +/* Transport stream op: a set of operations to perform on a transport + against a single stream */ struct grpc_transport_stream_op_batch { grpc_transport_stream_op_batch() : send_initial_metadata(false), @@ -170,7 +170,7 @@ struct grpc_transport_stream_op_batch { recv_trailing_metadata(false), cancel_stream(false), is_traced(false) {} - + /** Should be scheduled when all of the non-recv operations in the batch are complete. @@ -184,39 +184,39 @@ struct grpc_transport_stream_op_batch { /** Values for the stream op (fields set are determined by flags above) */ grpc_transport_stream_op_batch_payload* payload = nullptr; - + /** Send initial metadata to the peer, from the provided metadata batch. */ bool send_initial_metadata : 1; - - /** Send trailing metadata to the peer, from the provided metadata batch. */ + + /** Send trailing metadata to the peer, from the provided metadata batch. */ bool send_trailing_metadata : 1; - - /** Send message data to the peer, from the provided byte stream. */ + + /** Send message data to the peer, from the provided byte stream. */ bool send_message : 1; - - /** Receive initial metadata from the stream, into provided metadata batch. */ + + /** Receive initial metadata from the stream, into provided metadata batch. */ bool recv_initial_metadata : 1; - - /** Receive message data from the stream, into provided byte stream. */ + + /** Receive message data from the stream, into provided byte stream. */ bool recv_message : 1; - - /** Receive trailing metadata from the stream, into provided metadata batch. - */ + + /** Receive trailing metadata from the stream, into provided metadata batch. + */ bool recv_trailing_metadata : 1; - + /** Cancel this stream with the provided error */ bool cancel_stream : 1; - + /** Is this stream traced */ bool is_traced : 1; - /*************************************************************************** - * remaining fields are initialized and used at the discretion of the + /*************************************************************************** + * remaining fields are initialized and used at the discretion of the * current handler of the op */ - + grpc_handler_private_op_data handler_private; }; - + struct grpc_transport_stream_op_batch_payload { explicit grpc_transport_stream_op_batch_payload( grpc_call_context_element* context) @@ -326,11 +326,11 @@ struct grpc_transport_stream_op_batch_payload { grpc_call_context_element* context; }; -/** Transport op: a set of operations to perform on a transport as a whole */ -typedef struct grpc_transport_op { - /** Called when processing of this op is done. */ +/** Transport op: a set of operations to perform on a transport as a whole */ +typedef struct grpc_transport_op { + /** Called when processing of this op is done. */ grpc_closure* on_consumed = nullptr; - /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */ + /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */ grpc_core::OrphanablePtr<grpc_core::ConnectivityStateWatcherInterface> start_connectivity_watch; grpc_connectivity_state start_connectivity_watch_state = GRPC_CHANNEL_IDLE; @@ -344,17 +344,17 @@ typedef struct grpc_transport_op { * Error contract: the transport that gets this op must cause * goaway_error to be unref'ed after processing it */ grpc_error* goaway_error = nullptr; - /** set the callback for accepting new streams; - this is a permanent callback, unlike the other one-shot closures. - If true, the callback is set to set_accept_stream_fn, with its - user_data argument set to set_accept_stream_user_data */ + /** set the callback for accepting new streams; + this is a permanent callback, unlike the other one-shot closures. + If true, the callback is set to set_accept_stream_fn, with its + user_data argument set to set_accept_stream_user_data */ bool set_accept_stream = false; void (*set_accept_stream_fn)(void* user_data, grpc_transport* transport, const void* server_data) = nullptr; void* set_accept_stream_user_data = nullptr; - /** add this transport to a pollset */ + /** add this transport to a pollset */ grpc_pollset* bind_pollset = nullptr; - /** add this transport to a pollset_set */ + /** add this transport to a pollset_set */ grpc_pollset_set* bind_pollset_set = nullptr; /** send a ping, if either on_initiate or on_ack is not NULL */ struct { @@ -366,99 +366,99 @@ typedef struct grpc_transport_op { } send_ping; // If true, will reset the channel's connection backoff. bool reset_connect_backoff = false; - - /*************************************************************************** - * remaining fields are initialized and used at the discretion of the - * transport implementation */ - + + /*************************************************************************** + * remaining fields are initialized and used at the discretion of the + * transport implementation */ + grpc_handler_private_op_data handler_private; -} grpc_transport_op; - -/* Returns the amount of memory required to store a grpc_stream for this - transport */ +} grpc_transport_op; + +/* Returns the amount of memory required to store a grpc_stream for this + transport */ size_t grpc_transport_stream_size(grpc_transport* transport); - -/* Initialize transport data for a stream. - - Returns 0 on success, any other (transport-defined) value for failure. + +/* Initialize transport data for a stream. + + Returns 0 on success, any other (transport-defined) value for failure. May assume that stream contains all-zeros. - - Arguments: - transport - the transport on which to create this stream - stream - a pointer to uninitialized memory to initialize - server_data - either NULL for a client initiated stream, or a pointer - supplied from the accept_stream callback function */ + + Arguments: + transport - the transport on which to create this stream + stream - a pointer to uninitialized memory to initialize + server_data - either NULL for a client initiated stream, or a pointer + supplied from the accept_stream callback function */ int grpc_transport_init_stream(grpc_transport* transport, grpc_stream* stream, grpc_stream_refcount* refcount, const void* server_data, grpc_core::Arena* arena); - + void grpc_transport_set_pops(grpc_transport* transport, grpc_stream* stream, grpc_polling_entity* pollent); - -/* Destroy transport data for a stream. - - Requires: a recv_batch with final_state == GRPC_STREAM_CLOSED has been - received by the up-layer. Must not be called in the same call stack as - recv_frame. - - Arguments: - transport - the transport on which to create this stream - stream - the grpc_stream to destroy (memory is still owned by the - caller, but any child memory must be cleaned up) */ + +/* Destroy transport data for a stream. + + Requires: a recv_batch with final_state == GRPC_STREAM_CLOSED has been + received by the up-layer. Must not be called in the same call stack as + recv_frame. + + Arguments: + transport - the transport on which to create this stream + stream - the grpc_stream to destroy (memory is still owned by the + caller, but any child memory must be cleaned up) */ void grpc_transport_destroy_stream(grpc_transport* transport, grpc_stream* stream, grpc_closure* then_schedule_closure); - + void grpc_transport_stream_op_batch_finish_with_failure( grpc_transport_stream_op_batch* op, grpc_error* error, grpc_core::CallCombiner* call_combiner); - + TString grpc_transport_stream_op_batch_string( grpc_transport_stream_op_batch* op); TString grpc_transport_op_string(grpc_transport_op* op); - -/* Send a batch of operations on a transport - - Takes ownership of any objects contained in ops. - - Arguments: - transport - the transport on which to initiate the stream - stream - the stream on which to send the operations. This must be - non-NULL and previously initialized by the same transport. + +/* Send a batch of operations on a transport + + Takes ownership of any objects contained in ops. + + Arguments: + transport - the transport on which to initiate the stream + stream - the stream on which to send the operations. This must be + non-NULL and previously initialized by the same transport. op - a grpc_transport_stream_op_batch specifying the op to perform */ void grpc_transport_perform_stream_op(grpc_transport* transport, grpc_stream* stream, grpc_transport_stream_op_batch* op); - + void grpc_transport_perform_op(grpc_transport* transport, grpc_transport_op* op); - -/* Send a ping on a transport - - Calls cb with user data when a response is received. */ + +/* Send a ping on a transport + + Calls cb with user data when a response is received. */ void grpc_transport_ping(grpc_transport* transport, grpc_closure* cb); - -/* Advise peer of pending connection termination. */ + +/* Advise peer of pending connection termination. */ void grpc_transport_goaway(grpc_transport* transport, grpc_status_code status, - grpc_slice debug_data); - -/* Destroy the transport */ + grpc_slice debug_data); + +/* Destroy the transport */ void grpc_transport_destroy(grpc_transport* transport); - -/* Get the endpoint used by \a transport */ + +/* Get the endpoint used by \a transport */ grpc_endpoint* grpc_transport_get_endpoint(grpc_transport* transport); - -/* Allocate a grpc_transport_op, and preconfigure the on_consumed closure to - \a on_consumed and then delete the returned transport op */ + +/* Allocate a grpc_transport_op, and preconfigure the on_consumed closure to + \a on_consumed and then delete the returned transport op */ grpc_transport_op* grpc_make_transport_op(grpc_closure* on_consumed); /* Allocate a grpc_transport_stream_op_batch, and preconfigure the on_consumed closure - to \a on_consumed and then delete the returned transport op */ + to \a on_consumed and then delete the returned transport op */ grpc_transport_stream_op_batch* grpc_make_transport_stream_op( grpc_closure* on_consumed); - + namespace grpc_core { // This is the key to be used for loading/storing keepalive_throttling in the // y_absl::Status object. @@ -466,4 +466,4 @@ constexpr const char* kKeepaliveThrottlingKey = "grpc.internal.keepalive_throttling"; } // namespace grpc_core -#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_H */ diff --git a/contrib/libs/grpc/src/core/lib/transport/transport_impl.h b/contrib/libs/grpc/src/core/lib/transport/transport_impl.h index 526cc1b1ba..37e793c7f9 100644 --- a/contrib/libs/grpc/src/core/lib/transport/transport_impl.h +++ b/contrib/libs/grpc/src/core/lib/transport/transport_impl.h @@ -1,71 +1,71 @@ -/* - * +/* + * * 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 GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H -#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H - + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H +#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H + #include <grpc/support/port_platform.h> -#include "src/core/lib/transport/transport.h" - -typedef struct grpc_transport_vtable { - /* Memory required for a single stream element - this is allocated by upper - layers and initialized by the transport */ - size_t sizeof_stream; /* = sizeof(transport stream) */ - - /* name of this transport implementation */ +#include "src/core/lib/transport/transport.h" + +typedef struct grpc_transport_vtable { + /* Memory required for a single stream element - this is allocated by upper + layers and initialized by the transport */ + size_t sizeof_stream; /* = sizeof(transport stream) */ + + /* name of this transport implementation */ const char* name; - - /* implementation of grpc_transport_init_stream */ + + /* implementation of grpc_transport_init_stream */ int (*init_stream)(grpc_transport* self, grpc_stream* stream, grpc_stream_refcount* refcount, const void* server_data, grpc_core::Arena* arena); - - /* implementation of grpc_transport_set_pollset */ + + /* implementation of grpc_transport_set_pollset */ void (*set_pollset)(grpc_transport* self, grpc_stream* stream, grpc_pollset* pollset); - - /* implementation of grpc_transport_set_pollset */ + + /* implementation of grpc_transport_set_pollset */ void (*set_pollset_set)(grpc_transport* self, grpc_stream* stream, grpc_pollset_set* pollset_set); - - /* implementation of grpc_transport_perform_stream_op */ + + /* implementation of grpc_transport_perform_stream_op */ void (*perform_stream_op)(grpc_transport* self, grpc_stream* stream, grpc_transport_stream_op_batch* op); - - /* implementation of grpc_transport_perform_op */ + + /* implementation of grpc_transport_perform_op */ void (*perform_op)(grpc_transport* self, grpc_transport_op* op); - - /* implementation of grpc_transport_destroy_stream */ + + /* implementation of grpc_transport_destroy_stream */ void (*destroy_stream)(grpc_transport* self, grpc_stream* stream, grpc_closure* then_schedule_closure); - - /* implementation of grpc_transport_destroy */ + + /* implementation of grpc_transport_destroy */ void (*destroy)(grpc_transport* self); - - /* implementation of grpc_transport_get_endpoint */ + + /* implementation of grpc_transport_get_endpoint */ grpc_endpoint* (*get_endpoint)(grpc_transport* self); -} grpc_transport_vtable; - -/* an instance of a grpc transport */ -struct grpc_transport { - /* pointer to a vtable defining operations on this transport */ +} grpc_transport_vtable; + +/* an instance of a grpc transport */ +struct grpc_transport { + /* pointer to a vtable defining operations on this transport */ const grpc_transport_vtable* vtable; -}; - -#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ +}; + +#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ |