Skip to content

Commit 3bce368

Browse files
committed
mem: add rpm cli param for selecting allocator
1 parent 5ad04ac commit 3bce368

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
#include "globals.h"
109109
#include "mem/mem.h"
110110
#include "mem/shm_mem.h"
111+
#include "mem/rpm_mem.h"
111112
#include "sr_module.h"
112113
#include "timer.h"
113114
#include "ipc.h"
@@ -962,6 +963,13 @@ int main(int argc, char** argv)
962963
goto error00;
963964
}
964965
break;
966+
case 'e':
967+
if (set_rpm_mm(optarg) < 0) {
968+
LM_ERR("current build does not support "
969+
"this allocator (-e %s)\n", optarg);
970+
goto error00;
971+
}
972+
break;
965973
}
966974
}
967975

@@ -1011,6 +1019,7 @@ int main(int argc, char** argv)
10111019
case 'a':
10121020
case 'k':
10131021
case 's':
1022+
case 'e':
10141023
/* ignoring, parsed previously */
10151024
break;
10161025
case 'b':

mem/rpm_mem.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,20 @@ enum osips_mm mem_allocator_rpm = MM_NONE;
3939
unsigned long rpm_mem_size = 0;
4040
char *rpm_mem_file = RESTART_PERSISTENCY_MEM_FILE;
4141

42+
int set_rpm_mm(const char *mm_name)
43+
{
44+
#ifdef INLINE_ALLOC
45+
LM_NOTICE("this is an inlined allocator build (see opensips -V), "
46+
"cannot set a custom rpm allocator (%s)\n", mm_name);
47+
return 0;
48+
#endif
49+
50+
if (parse_mm(mm_name, &mem_allocator_rpm) < 0)
51+
return -1;
52+
53+
return 0;
54+
}
55+
4256
#ifndef INLINE_ALLOC
4357
#ifdef DBG_MALLOC
4458
void *(*gen_rpm_malloc)(void *blk, unsigned long size,

0 commit comments

Comments
 (0)