Skip to content

Commit 5aa9358

Browse files
committed
avoid per-connection memory increase when PTLS_HAVE_LOG is off
1 parent f126480 commit 5aa9358

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

include/picotls.h

+7
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,15 @@ extern "C" {
6868
#define PTLS_THREADLOCAL __declspec(thread)
6969
#else
7070
#define PTLS_THREADLOCAL __thread
71+
#endif
72+
73+
#ifndef PTLS_HAVE_LOG
74+
#ifdef _WINDOWS
75+
#define PTLS_HAVE_LOG 0
76+
#else
7177
#define PTLS_HAVE_LOG 1
7278
#endif
79+
#endif
7380

7481
#ifndef PTLS_FUZZ_HANDSHAKE
7582
#define PTLS_FUZZ_HANDSHAKE 0

lib/picotls.c

+10
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,12 @@ struct st_ptls_t {
273273
unsigned send_change_cipher_spec : 1;
274274
unsigned needs_key_update : 1;
275275
unsigned key_update_send_request : 1;
276+
#if PTLS_HAVE_LOG
276277
/**
277278
* see ptls_log
278279
*/
279280
ptls_log_conn_state_t log_state;
281+
#endif
280282
struct {
281283
uint32_t active_conns;
282284
uint32_t generation;
@@ -5140,11 +5142,15 @@ static ptls_t *new_instance(ptls_context_t *ctx, int is_server)
51405142
*tls = (ptls_t){ctx};
51415143
tls->is_server = is_server;
51425144
tls->send_change_cipher_spec = ctx->send_change_cipher_spec;
5145+
5146+
#if PTLS_HAVE_LOG
51435147
if (ptls_log_conn_state_override != NULL) {
51445148
tls->log_state = *ptls_log_conn_state_override;
51455149
} else {
51465150
ptls_log_init_conn_state(&tls->log_state, ctx->random_bytes);
51475151
}
5152+
#endif
5153+
51485154
return tls;
51495155
}
51505156

@@ -5592,7 +5598,11 @@ void **ptls_get_data_ptr(ptls_t *tls)
55925598

55935599
ptls_log_conn_state_t *ptls_get_log_state(ptls_t *tls)
55945600
{
5601+
#if PTLS_HAVE_LOG
55955602
return &tls->log_state;
5603+
#else
5604+
return &ptls_log.dummy_conn_state;
5605+
#endif
55965606
}
55975607

55985608
static int handle_client_handshake_message(ptls_t *tls, ptls_message_emitter_t *emitter, ptls_iovec_t message, int is_end_of_record,

0 commit comments

Comments
 (0)