1
0
mirror of https://github.com/coturn/coturn.git synced 2025-10-29 14:01:01 +01:00

Backlog fifo (#1029)

Modify SSL backlog buffer from LIFO to queue/FIFO

If data ends up in the ssl_backlog_buffer because we are waiting for a
handshake to finish, then this change ensures that the data is sent out
in the proper order once the handshake completes. Previous code was
sending in LIFO order.
This commit is contained in:
Scott Godin 2022-10-24 19:44:31 -04:00 committed by GitHub
parent 27e5dd6e23
commit cfa5f66cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View File

@ -268,6 +268,9 @@ static stun_buffer_list_elem *get_elem_from_buffer_list(stun_buffer_list *bufs)
ret=bufs->head;
bufs->head=ret->next;
--bufs->tsz;
if(bufs->tsz == 0) {
bufs->tail = NULL;
}
ret->next=NULL;
ret->buf.len = 0;
@ -285,12 +288,13 @@ static void pop_elem_from_buffer_list(stun_buffer_list *bufs)
stun_buffer_list_elem *ret = bufs->head;
bufs->head=ret->next;
--bufs->tsz;
if(bufs->tsz == 0) {
bufs->tail = NULL;
}
free(ret);
}
}
static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
{
stun_buffer_list_elem *ret = get_elem_from_buffer_list(&(e->bufs));
@ -313,8 +317,14 @@ static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
static inline void add_elem_to_buffer_list(stun_buffer_list *bufs, stun_buffer_list_elem *buf_elem)
{
buf_elem->next = bufs->head;
bufs->head = buf_elem;
// We want a queue, so add to tail
if(bufs->tail) {
bufs->tail->next = buf_elem;
} else {
bufs->head = buf_elem;
}
buf_elem->next = NULL;
bufs->tail = buf_elem;
bufs->tsz += 1;
}

View File

@ -77,6 +77,7 @@ typedef struct _stun_buffer_list_elem {
typedef struct _stun_buffer_list {
stun_buffer_list_elem *head;
stun_buffer_list_elem *tail;
size_t tsz;
} stun_buffer_list;