mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-01 01:32:04 +00:00
REORG: quic: Move quic_increment_curr_handshake() to quic_sock
Move quic_increment_curr_handshake() from quic_conn.c to quic_sock.h to be inlined. Also move all the inlined functions at the end of this header.
This commit is contained in:
parent
3e16784dfc
commit
ad61a5dde3
@ -48,6 +48,16 @@ int qc_snd_buf(struct quic_conn *qc, const struct buffer *buf, size_t count,
|
||||
int qc_rcv_buf(struct quic_conn *qc);
|
||||
void quic_conn_sock_fd_iocb(int fd);
|
||||
|
||||
void qc_alloc_fd(struct quic_conn *qc, const struct sockaddr_storage *src,
|
||||
const struct sockaddr_storage *dst);
|
||||
void qc_release_fd(struct quic_conn *qc, int reinit);
|
||||
void qc_want_recv(struct quic_conn *qc);
|
||||
|
||||
void quic_accept_push_qc(struct quic_conn *qc);
|
||||
|
||||
int quic_listener_max_handshake(const struct listener *l);
|
||||
int quic_listener_max_accept(const struct listener *l);
|
||||
|
||||
/* Set default value for <qc> socket as uninitialized. */
|
||||
static inline void qc_init_fd(struct quic_conn *qc)
|
||||
{
|
||||
@ -62,15 +72,29 @@ static inline char qc_test_fd(struct quic_conn *qc)
|
||||
return qc->fd >= 0;
|
||||
}
|
||||
|
||||
void qc_alloc_fd(struct quic_conn *qc, const struct sockaddr_storage *src,
|
||||
const struct sockaddr_storage *dst);
|
||||
void qc_release_fd(struct quic_conn *qc, int reinit);
|
||||
void qc_want_recv(struct quic_conn *qc);
|
||||
/* Try to increment <l> handshake current counter. If listener limit is
|
||||
* reached, incrementation is rejected and 0 is returned.
|
||||
*/
|
||||
static inline int quic_increment_curr_handshake(struct listener *l)
|
||||
{
|
||||
unsigned int count, next;
|
||||
const int max = quic_listener_max_handshake(l);
|
||||
|
||||
void quic_accept_push_qc(struct quic_conn *qc);
|
||||
do {
|
||||
count = l->rx.quic_curr_handshake;
|
||||
if (count >= max) {
|
||||
/* maxconn reached */
|
||||
next = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
int quic_listener_max_handshake(const struct listener *l);
|
||||
int quic_listener_max_accept(const struct listener *l);
|
||||
/* try to increment quic_curr_handshake */
|
||||
next = count + 1;
|
||||
} while (!_HA_ATOMIC_CAS(&l->rx.quic_curr_handshake, &count, next) && __ha_cpu_relax());
|
||||
|
||||
end:
|
||||
return next;
|
||||
}
|
||||
|
||||
#endif /* USE_QUIC */
|
||||
#endif /* _HAPROXY_QUIC_SOCK_H */
|
||||
|
@ -945,30 +945,6 @@ struct task *qc_process_timer(struct task *task, void *ctx, unsigned int state)
|
||||
return task;
|
||||
}
|
||||
|
||||
/* Try to increment <l> handshake current counter. If listener limit is
|
||||
* reached, incrementation is rejected and 0 is returned.
|
||||
*/
|
||||
static int quic_increment_curr_handshake(struct listener *l)
|
||||
{
|
||||
unsigned int count, next;
|
||||
const int max = quic_listener_max_handshake(l);
|
||||
|
||||
do {
|
||||
count = l->rx.quic_curr_handshake;
|
||||
if (count >= max) {
|
||||
/* maxconn reached */
|
||||
next = 0;
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* try to increment quic_curr_handshake */
|
||||
next = count + 1;
|
||||
} while (!_HA_ATOMIC_CAS(&l->rx.quic_curr_handshake, &count, next) && __ha_cpu_relax());
|
||||
|
||||
end:
|
||||
return next;
|
||||
}
|
||||
|
||||
/* Allocate a new QUIC connection with <version> as QUIC version. <ipv4>
|
||||
* boolean is set to 1 for IPv4 connection, 0 for IPv6. <server> is set to 1
|
||||
* for QUIC servers (or haproxy listeners).
|
||||
|
Loading…
Reference in New Issue
Block a user