26#ifndef ROUTER_SRC_OPENSSL_INCLUDE_TLS_TRACE_STREAM_H_
27#define ROUTER_SRC_OPENSSL_INCLUDE_TLS_TRACE_STREAM_H_
38#ifndef USE_CUSTOM_HOLDER
47template <
typename NameType,
typename LowerLevelStream>
66 template <
typename... Args>
77 template <
class MutableBufferSequence>
79 const MutableBufferSequence &buffers) {
83 template <
class ConstBufferSequence>
85 const ConstBufferSequence &buffers) {
89 template <
typename Buffer,
typename Handler>
97 template <
typename Buffer,
typename Handler>
118 print(
"handle_read error:", ec,
", size:",
size);
124 print(
"handle_write error:", ec,
", size:",
size);
129 template <
typename SettableSocketOption>
131 const SettableSocketOption &option) {
135 template <
typename... Args>
137 std::unique_lock<std::mutex> l{
mutex_};
139 <<
", " << NameType::get_name() <<
": ";
165 template <
typename Vector>
166 void dump(Vector &data,
size_t s) {
167 std::unique_lock<std::mutex> l{
mutex_};
168 auto it = data.begin();
171 while (it != data.end() && s) {
172 auto data_on_page = std::min(s, it->size());
173 const char *data_ptr = (
const char *)it->data();
174 auto to_print = data_on_page;
177 auto line = std::min(to_print, 16UL);
178 *
out_ <<
"this:" <<
parent_ <<
" " << std::hex << std::setfill(
'0')
179 << std::setw(8) << offset <<
" | ";
180 for (
size_t i = 0; i < line; ++i) {
181 *
out_ <<
" 0x" << std::setw(2) << (int)((
const uint8_t *)data_ptr)[i];
184 *
out_ << std::string((16 - line) * 5,
' ');
187 for (
size_t i = 0; i < line; ++i) {
188 *
out_ << (iscntrl(data_ptr[i]) ?
'?' : data_ptr[i]);
203 template <
typename Vector,
typename SrcBuffers>
204 void copy(Vector &dst,
const SrcBuffers &src) {
209 dst.emplace_back(it->data(), it->size());
216 template <
typename Arg,
typename... Args>
222 template <
typename WriteToken,
typename StandardToken>
225 using Write_token_result = std::decay_t<WriteToken>;
226 using Write_token_handler =
227 std::conditional_t<std::is_same<WriteToken, Write_token_result>::value,
228 Write_token_result &, Write_token_result>;
230 using Standard_token_result = std::decay_t<StandardToken>;
231 using Standard_token_handler = std::conditional_t<
232 std::is_same<StandardToken, Standard_token_result>::value,
233 Standard_token_result &, Standard_token_result>;
236 std::forward<Write_token_handler>(write_token),
237 std::forward<Standard_token_handler>(std_token));
240 template <
typename ReadToken,
typename StandardToken>
243 using Read_token_result = std::decay_t<ReadToken>;
244 using Read_token_handler =
245 std::conditional_t<std::is_same<ReadToken, Read_token_result>::value,
246 Read_token_result &, Read_token_result>;
248 using Standard_token_result = std::decay_t<StandardToken>;
249 using Standard_token_handler = std::conditional_t<
250 std::is_same<StandardToken, Standard_token_result>::value,
251 Standard_token_result &, Standard_token_result>;
254 std::forward<Standard_token_handler>(std_token));
264template <
typename NameType,
typename LowerLevelStream>
Definition: trace_stream.h:265
const LowerLayerType & lower_layer() const
Definition: trace_stream.h:272
typename LowerLevelStream::LowerLayerType LowerLayerType
Definition: trace_stream.h:269
LowerLayerType & lower_layer()
Definition: trace_stream.h:271
Definition: trace_stream.h:146
void handle_write(std::error_code ec, size_t size)
Definition: trace_stream.h:157
WrappedTraceStream(TraceStream *parent=nullptr)
Definition: trace_stream.h:148
WrappedTraceStream(const WrappedTraceStream &other)
Definition: trace_stream.h:149
WrappedTraceStream(WrappedTraceStream &&other)
Definition: trace_stream.h:151
void handle_read(std::error_code ec, size_t size)
Definition: trace_stream.h:153
TraceStream * parent_
Definition: trace_stream.h:162
Definition: trace_stream.h:48
auto cancel()
Definition: trace_stream.h:107
VectorOfConstBuffers send_buffer_
Definition: trace_stream.h:258
TraceStream(Args &&... args)
Definition: trace_stream.h:67
const LowerLevelStream & lower_layer() const
Definition: trace_stream.h:75
void handle_read(std::error_code ec, size_t size)
Definition: trace_stream.h:117
net::tls::LowerLayerWriteCompletionToken< WriteToken, StandardToken > get_write_handler(WriteToken &write_token, StandardToken &std_token)
Definition: trace_stream.h:224
void async_receive(const Buffer &buffer, Handler &&handler)
Definition: trace_stream.h:98
void handle_write(std::error_code ec, size_t size)
Definition: trace_stream.h:123
void copy(Vector &dst, const SrcBuffers &src)
Definition: trace_stream.h:204
std::vector< net::const_buffer > VectorOfConstBuffers
Definition: trace_stream.h:56
std::nullptr_t protocol_type
Definition: trace_stream.h:54
net::tls::LowerLayerReadCompletionToken< ReadToken, StandardToken > get_read_handler(ReadToken &read_token, StandardToken &std_token)
Definition: trace_stream.h:242
void print_single()
Definition: trace_stream.h:214
stdx::expected< void, std::error_code > set_option(const SettableSocketOption &option)
Definition: trace_stream.h:130
TraceStream(TraceStream &&other)
Definition: trace_stream.h:58
std::ostream * out_
Definition: trace_stream.h:260
stdx::expected< size_t, std::error_code > write_some(const ConstBufferSequence &buffers)
Definition: trace_stream.h:84
std::vector< net::mutable_buffer > VectorOfBuffers
Definition: trace_stream.h:55
void set_parent(const char *parent)
Definition: trace_stream.h:105
VectorOfBuffers recv_buffer_
Definition: trace_stream.h:257
auto get_executor()
Definition: trace_stream.h:72
std::nullptr_t native_handle_type
Definition: trace_stream.h:53
LowerLevelStream & lower_layer()
Definition: trace_stream.h:74
void async_send(const Buffer &buffer, Handler &&handler)
Definition: trace_stream.h:90
std::string parent_
Definition: trace_stream.h:261
LowerLevelStream lower_layer_
Definition: trace_stream.h:259
stdx::expected< size_t, std::error_code > read_some(const MutableBufferSequence &buffers)
Definition: trace_stream.h:78
void print(const Args &... args)
Definition: trace_stream.h:136
void dump(Vector &data, size_t s)
Definition: trace_stream.h:166
void print_single(const Arg &arg, const Args... args)
Definition: trace_stream.h:217
auto close()
Definition: trace_stream.h:112
The handler class is the interface for dynamically loadable storage engines.
Definition: handler.h:4573
Definition: lower_layer_completion.h:40
Definition: lower_layer_completion.h:77
static const std::string dec("DECRYPTION")
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
size_t size(const char *const c)
Definition: base64.h:46
const const_buffer * buffer_sequence_end(const const_buffer &b) noexcept
Definition: buffer.h:185
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
const const_buffer * buffer_sequence_begin(const const_buffer &b) noexcept
Definition: buffer.h:180
size_t buffer_size(const ConstBufferSequence &buffers) noexcept
Definition: buffer.h:313
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:192
Definition: gcs_xcom_synode.h:64
pid_type get_id()
Definition: process.h:48
uint read_token(const sql_digest_storage *digest_storage, uint index, uint *tok)
Read a single token from token array.
Definition: sql_digest.cc:56
Definition: mutex_static_holder.h:32
static std::mutex mutex_
Definition: mutex_static_holder.h:33
Definition: trace_stream.h:45