Avoid using bzero for the entire stun_buffer_list_elem and only init metadata

On high traffic servers bzero -> memset takes a significant amount of time because each stun_buffer_list_elem can be ~64kb
This commit is contained in:
Haseeb Abdul Qadir 2021-05-21 07:51:45 -04:00
parent d8026372af
commit 93c5387180

View File

@ -297,15 +297,15 @@ static stun_buffer_list_elem *new_blist_elem(ioa_engine_handle e)
if(!ret) {
ret = (stun_buffer_list_elem *)malloc(sizeof(stun_buffer_list_elem));
if (ret) {
ret->next = NULL;
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot allocate memory for STUN buffer!\n", __FUNCTION__);
}
}
if(ret) {
bzero(&ret->buf, sizeof(stun_buffer));
ret->buf.len = 0;
ret->buf.offset = 0;
ret->buf.coffset = 0;
ret->next = NULL;
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "%s: Cannot allocate memory for STUN buffer!\n", __FUNCTION__);
}
return ret;