Skip to content

Commit

Permalink
Fix the E_CORE_SHM_THRESHOLD event
Browse files Browse the repository at this point in the history
For some time now, this event has not been functional, due to
init_shm_mallocs() being called *before* parsing the opensips.cfg,
leading to un-initialized event holders and a quick-exit at runtime,
including times when the event actually needs to be raised.

Credits to Bogdan Iancu for reporting this issue!

(cherry picked from commit b38b06a)
  • Loading branch information
liviuchircu committed Apr 30, 2024
1 parent f019ddc commit 0eafd4f
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions mem/shm_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,22 +592,22 @@ int shm_mem_init_mallocs(void* mempool, unsigned long pool_size)
#endif

#ifdef STATISTICS
if (event_shm_threshold) {
event_shm_last=shm_malloc_unsafe(sizeof(long));
if (event_shm_last==0){
LM_CRIT("could not allocate shm last event indicator\n");
{
struct {
long last;
int pending;
} *ev_holders;

ev_holders = shm_malloc_unsafe(sizeof *ev_holders);
if (!ev_holders) {
LM_CRIT("could not allocate SHM event holders\n");
shm_mem_destroy();
return -1;
}
*event_shm_last=0;
event_shm_pending=shm_malloc_unsafe(sizeof(int));
if (event_shm_pending==0){
LM_CRIT("could not allocate shm pending flags\n");
shm_mem_destroy();
return -1;
}
*event_shm_pending=0;
memset(ev_holders, 0, sizeof *ev_holders);

event_shm_last = &ev_holders->last;
event_shm_pending = &ev_holders->pending;
}
#endif /* STATISTICS */

Expand Down

0 comments on commit 0eafd4f

Please sign in to comment.