litespeed-quic/bin/prog.h

119 lines
2.9 KiB
C
Raw Normal View History

2022-05-06 16:49:46 +00:00
/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc. See LICENSE. */
2017-09-22 21:00:03 +00:00
/*
* prog.h -- common setup and options for QUIC program
*/
#ifndef PROG_H
#define PROG_H 1
#include "test_config.h"
2017-09-22 21:00:03 +00:00
struct event;
struct event_base;
struct lsquic_hash;
struct sport_head;
struct ssl_ctx_st;
2017-09-22 21:00:03 +00:00
struct prog
{
struct packout_buf_allocator prog_pba;
struct lsquic_engine_settings prog_settings;
struct lsquic_engine_api prog_api;
unsigned prog_engine_flags;
struct service_port prog_dummy_sport; /* Use for options */
unsigned prog_packout_max;
unsigned short prog_max_packet_size;
int prog_version_cleared;
unsigned long prog_read_count;
#if HAVE_SENDMMSG
int prog_use_sendmmsg;
#endif
#if HAVE_RECVMMSG
int prog_use_recvmmsg;
#endif
int prog_use_stock_pmi;
2017-09-22 21:00:03 +00:00
struct event_base *prog_eb;
struct event *prog_timer,
*prog_send,
2017-09-22 21:00:03 +00:00
*prog_usr1;
struct event *prog_usr2;
struct ssl_ctx_st *prog_ssl_ctx;
struct lsquic_hash *prog_certs;
struct event *prog_event_sni;
char *prog_susp_sni;
2017-09-22 21:00:03 +00:00
struct sport_head *prog_sports;
struct lsquic_engine *prog_engine;
const char *prog_hostname;
int prog_ipver; /* 0, 4, or 6 */
enum {
PROG_FLAG_COOLDOWN = 1 << 0,
#if LSQUIC_PREFERRED_ADDR
PROG_SEARCH_ADDRS = 1 << 1,
#endif
} prog_flags;
2017-09-22 21:00:03 +00:00
};
2020-06-03 04:13:30 +00:00
int
2017-09-22 21:00:03 +00:00
prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
const struct lsquic_stream_if *, void *stream_if_ctx);
#if HAVE_SENDMMSG
# define SENDMMSG_FLAG "g"
#else
# define SENDMMSG_FLAG ""
#endif
#if HAVE_RECVMMSG
# define RECVMMSG_FLAG "j"
#else
# define RECVMMSG_FLAG ""
#endif
#if LSQUIC_DONTFRAG_SUPPORTED
# define IP_DONTFRAG_FLAG "D"
#else
# define IP_DONTFRAG_FLAG ""
#endif
#define PROG_OPTS "i:km:c:y:L:l:o:H:s:S:Y:z:G:W" RECVMMSG_FLAG SENDMMSG_FLAG \
IP_DONTFRAG_FLAG
2017-09-22 21:00:03 +00:00
/* Returns:
* 0 Applied
* 1 Not applicable
* -1 Error
*/
int
prog_set_opt (struct prog *, int opt, const char *arg);
struct event_base *
prog_eb (struct prog *);
int
prog_run (struct prog *);
void
prog_cleanup (struct prog *);
void
prog_stop (struct prog *);
int
prog_prep (struct prog *);
int
prog_connect (struct prog *, unsigned char *, size_t);
2017-09-22 21:00:03 +00:00
void
prog_print_common_options (const struct prog *, FILE *);
int
prog_is_stopped (void);
[API Change, OPTIMIZATION] Only process conns that need to be processed The API is simplified: do not expose the user code to several queues. A "connection queue" is now an internal concept. The user processes connections using the single function lsquic_engine_process_conns(). When this function is called, only those connections are processed that need to be processed. A connection needs to be processed when: 1. New incoming packets have been fed to the connection. 2. User wants to read from a stream that is readable. 3. User wants to write to a stream that is writeable. 4. There are buffered packets that can be sent out. (This means that the user wrote to a stream outside of the lsquic library callback.) 5. A control frame (such as BLOCKED) needs to be sent out. 6. A stream needs to be serviced or delayed stream needs to be created. 7. An alarm rings. 8. Pacer timer expires. To achieve this, the library places the connections into two priority queues (min heaps): 1. Tickable Queue; and 2. Advisory Tick Time queue (ATTQ). Each time lsquic_engine_process_conns() is called, the Tickable Queue is emptied. After the connections have been ticked, they are queried again: if a connection is not being closed, it is placed either in the Tickable Queue if it is ready to be ticked again or it is placed in the Advisory Tick Time Queue. It is assumed that a connection always has at least one timer set (the idle alarm). The connections in the Tickable Queue are arranged in the least recently ticked order. This lets connections that have been quiet longer to get their packets scheduled first. This change means that the library no longer needs to be ticked periodically. The user code can query the library when is the next tick event and schedule it exactly. When connections are processed, only the tickable connections are processed, not *all* the connections. When there are no tick events, it means that no timer event is necessary -- only the file descriptor READ event is active. The following are improvements and simplifications that have been triggered: - Queue of connections with incoming packets is gone. - "Pending Read/Write Events" Queue is gone (along with its history and progress checks). This queue has become the Tickable Queue. - The connection hash no longer needs to track the connection insertion order.
2018-04-09 13:39:38 +00:00
void
prog_process_conns (struct prog *);
void
prog_sport_cant_send (struct prog *, int fd);
2017-09-22 21:00:03 +00:00
#endif