|
39 | 39 | #define MAP_QUERY_OPT 1
|
40 | 40 | #include "../../util/tmpl/fd_map_dynamic.c"
|
41 | 41 |
|
42 |
| -/* FD_QUIC_KEEP_ALIVE |
43 |
| - * |
44 |
| - * This compile time option specifies whether the server should use |
45 |
| - * QUIC PING frames to keep connections alive |
46 |
| - * |
47 |
| - * Set to 1 to keep connections alive |
48 |
| - * Set to 0 to allow connections to close on idle */ |
49 |
| -# define FD_QUIC_KEEP_ALIVE 0 |
50 | 42 |
|
51 | 43 | /* FD_QUIC_MAX_STREAMS_ALWAYS_UNLESS_ACKED */
|
52 | 44 | /* Defines whether a MAX_STREAMS frame is sent even if it was just */
|
@@ -2832,23 +2824,21 @@ fd_quic_svc_poll( fd_quic_t * quic,
|
2832 | 2824 | return 1;
|
2833 | 2825 | }
|
2834 | 2826 |
|
2835 |
| - //FD_DEBUG( FD_LOG_DEBUG(( "svc_poll conn=%p svc_type=%u", (void *)conn, conn->svc_type )); ) |
2836 |
| - |
2837 | 2827 | if( FD_UNLIKELY( now >= conn->last_activity + ( conn->idle_timeout / 2 ) ) ) {
|
2838 | 2828 | if( FD_UNLIKELY( now >= conn->last_activity + conn->idle_timeout ) ) {
|
2839 | 2829 | if( FD_LIKELY( conn->state != FD_QUIC_CONN_STATE_DEAD ) ) {
|
2840 | 2830 | /* rfc9000 10.1 Idle Timeout
|
2841 | 2831 | "... the connection is silently closed and its state is discarded
|
2842 | 2832 | when it remains idle for longer than the minimum of the
|
2843 | 2833 | max_idle_timeout value advertised by both endpoints." */
|
2844 |
| - FD_DEBUG( FD_LOG_WARNING(( "%s conn %p conn_idx: %u closing due to idle timeout (%g ms)", |
| 2834 | + FD_DEBUG( FD_LOG_WARNING(("%s conn %p conn_idx: %u closing due to idle timeout (%g ms)", |
2845 | 2835 | conn->server?"SERVER":"CLIENT",
|
2846 | 2836 | (void *)conn, conn->conn_idx, (double)conn->idle_timeout / 1e6 )); )
|
2847 | 2837 |
|
2848 | 2838 | fd_quic_set_conn_state( conn, FD_QUIC_CONN_STATE_DEAD );
|
2849 | 2839 | quic->metrics.conn_timeout_cnt++;
|
2850 | 2840 | }
|
2851 |
| - } else if( FD_QUIC_KEEP_ALIVE ) { |
| 2841 | + } else if( quic->config.keep_alive ) { |
2852 | 2842 | /* send PING */
|
2853 | 2843 | if( !( conn->flags & FD_QUIC_CONN_FLAGS_PING ) ) {
|
2854 | 2844 | conn->flags |= FD_QUIC_CONN_FLAGS_PING;
|
@@ -2876,7 +2866,8 @@ fd_quic_svc_poll( fd_quic_t * quic,
|
2876 | 2866 | fd_quic_conn_free( quic, conn );
|
2877 | 2867 | break;
|
2878 | 2868 | default:
|
2879 |
| - fd_quic_svc_prep_schedule( conn, state->now + quic->config.idle_timeout ); |
| 2869 | + /* prep idle timeout or keep alive at idle timeout/2 */ |
| 2870 | + fd_quic_svc_prep_schedule( conn, state->now + (conn->idle_timeout>>(quic->config.keep_alive)) ); |
2880 | 2871 | fd_quic_svc_schedule( state->svc_timers, conn );
|
2881 | 2872 | break;
|
2882 | 2873 | }
|
@@ -4292,8 +4283,9 @@ fd_quic_conn_create( fd_quic_t * quic,
|
4292 | 4283 |
|
4293 | 4284 | fd_quic_svc_timers_init_conn( conn );
|
4294 | 4285 |
|
4295 |
| - /* prep idle timeout */ |
4296 |
| - fd_quic_svc_prep_schedule( conn, state->now+quic->config.idle_timeout ); |
| 4286 | + /* prep idle timeout or keep alive at idle timeout/2 */ |
| 4287 | + ulong delay = quic->config.idle_timeout>>(quic->config.keep_alive); |
| 4288 | + fd_quic_svc_prep_schedule( conn, state->now+delay ); |
4297 | 4289 |
|
4298 | 4290 | /* return connection */
|
4299 | 4291 | return conn;
|
|
0 commit comments