mirror of
https://github.com/coturn/coturn.git
synced 2025-10-29 22:11:11 +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:
parent
27e5dd6e23
commit
cfa5f66cd7
@ -268,6 +268,9 @@ static stun_buffer_list_elem *get_elem_from_buffer_list(stun_buffer_list *bufs)
|
|||||||
ret=bufs->head;
|
ret=bufs->head;
|
||||||
bufs->head=ret->next;
|
bufs->head=ret->next;
|
||||||
--bufs->tsz;
|
--bufs->tsz;
|
||||||
|
if(bufs->tsz == 0) {
|
||||||
|
bufs->tail = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
ret->next=NULL;
|
ret->next=NULL;
|
||||||
ret->buf.len = 0;
|
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;
|
stun_buffer_list_elem *ret = bufs->head;
|
||||||
bufs->head=ret->next;
|
bufs->head=ret->next;
|
||||||
--bufs->tsz;
|
--bufs->tsz;
|
||||||
|
if(bufs->tsz == 0) {
|
||||||
|
bufs->tail = NULL;
|
||||||
|
}
|
||||||
free(ret);
|
free(ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
|
static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
|
||||||
{
|
{
|
||||||
stun_buffer_list_elem *ret = get_elem_from_buffer_list(&(e->bufs));
|
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)
|
static inline void add_elem_to_buffer_list(stun_buffer_list *bufs, stun_buffer_list_elem *buf_elem)
|
||||||
{
|
{
|
||||||
buf_elem->next = bufs->head;
|
// We want a queue, so add to tail
|
||||||
bufs->head = buf_elem;
|
if(bufs->tail) {
|
||||||
|
bufs->tail->next = buf_elem;
|
||||||
|
} else {
|
||||||
|
bufs->head = buf_elem;
|
||||||
|
}
|
||||||
|
buf_elem->next = NULL;
|
||||||
|
bufs->tail = buf_elem;
|
||||||
bufs->tsz += 1;
|
bufs->tsz += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,7 @@ typedef struct _stun_buffer_list_elem {
|
|||||||
|
|
||||||
typedef struct _stun_buffer_list {
|
typedef struct _stun_buffer_list {
|
||||||
stun_buffer_list_elem *head;
|
stun_buffer_list_elem *head;
|
||||||
|
stun_buffer_list_elem *tail;
|
||||||
size_t tsz;
|
size_t tsz;
|
||||||
} stun_buffer_list;
|
} stun_buffer_list;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user