Browse Source

TT#111357 refactor sysconf() call into shared code

Change-Id: Ifd8d1d774f55e7c58bf82c9a5f67787e02f53c3f
pull/1218/head
Richard Fuchs 5 years ago
parent
commit
b0f185f409
4 changed files with 16 additions and 16 deletions
  1. +4
    -15
      daemon/main.c
  2. +2
    -1
      daemon/rtpengine.pod
  3. +9
    -0
      lib/auxlib.c
  4. +1
    -0
      lib/auxlib.h

+ 4
- 15
daemon/main.c View File

@ -933,14 +933,8 @@ no_kernel:
rtpe_config.max_sessions = -1;
}
if (rtpe_config.redis_num_threads < 1) {
#ifdef _SC_NPROCESSORS_ONLN
rtpe_config.redis_num_threads = sysconf( _SC_NPROCESSORS_ONLN );
#endif
if (rtpe_config.redis_num_threads < 1) {
rtpe_config.redis_num_threads = REDIS_RESTORE_NUM_THREADS;
}
}
if (rtpe_config.redis_num_threads < 1)
rtpe_config.redis_num_threads = num_cpu_cores(REDIS_RESTORE_NUM_THREADS);
rtpe_tcp = NULL;
if (rtpe_config.tcp_listen_ep.port) {
@ -1007,13 +1001,8 @@ no_kernel:
rtpe_redis_write = rtpe_redis;
}
if (rtpe_config.num_threads < 1) {
#ifdef _SC_NPROCESSORS_ONLN
rtpe_config.num_threads = sysconf( _SC_NPROCESSORS_ONLN ) + 3;
#endif
if (rtpe_config.num_threads <= 1)
rtpe_config.num_threads = 4;
}
if (rtpe_config.num_threads < 1)
rtpe_config.num_threads = num_cpu_cores(4);
if (websocket_init())
die("Failed to init websocket listener");


+ 2
- 1
daemon/rtpengine.pod View File

@ -312,7 +312,8 @@ sensitive and/or private information. Defaults to an empty string.
How many worker threads to create, must be at least one.
The default is to create as many threads as there are CPU cores available.
If the number of CPU cores cannot be determined, the default is four.
If the number of CPU cores cannot be determined or if it is less than four,
then the default is four.
=item B<--num-media-threads=>I<INT>


+ 9
- 0
lib/auxlib.c View File

@ -410,3 +410,12 @@ void free_gbuf(char **p) {
void free_gvbuf(char ***p) {
g_strfreev(*p);
}
int num_cpu_cores(int minval) {
#ifdef _SC_NPROCESSORS_ONLN
int ret = sysconf(_SC_NPROCESSORS_ONLN);
if (ret >= 1 && ret >= minval)
return ret;
#endif
return minval;
}

+ 1
- 0
lib/auxlib.h View File

@ -57,6 +57,7 @@ unsigned int in6_addr_hash(const void *p);
int in6_addr_eq(const void *a, const void *b);
unsigned int uint32_hash(const void *p);
int uint32_eq(const void *a, const void *b);
int num_cpu_cores(int);
/*** HELPER MACROS ***/


Loading…
Cancel
Save