Changeset 1397:239ba25870d8 in freeDiameter
- Timestamp:
- Nov 15, 2019, 7:40:37 PM (4 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/freediameter.conf.sample
r1396 r1397 188 188 # Default: 4 189 189 #AppServThreads = 4; 190 191 # Number of server threads that can handle incoming message routing at the same time. 192 # Default: 1 193 #RoutingInThreads = 1; 194 195 # Number of server threads that can handle outgoing message routing at the same time. 196 # Default: 1 197 #RoutingOutThreads= 1; 190 198 191 199 # Other applications are configured by loaded extensions. -
include/freeDiameter/libfdcore.h
r1396 r1397 138 138 struct fd_list cnf_apps; /* Applications locally supported (except relay, see flags). Use fd_disp_app_support to add one. list of struct fd_app. */ 139 139 uint16_t cnf_dispthr; /* Number of dispatch threads to create */ 140 uint16_t cnf_rtinthr; /* Number of routing in threads to create */ 141 uint16_t cnf_rtoutthr; /* Number of routing out threads to create */ 140 142 uint16_t cnf_rr_in_answers; /* include Route-Record AVP in answers */ 143 int cnf_qin_limit; /* limit for incoming queue*/ 144 int cnf_qout_limit; /* limit for outgoing queue */ 145 int cnf_qlocal_limit; /* limit for local queue */ 141 146 struct { 142 147 unsigned no_fwd : 1; /* the peer does not relay messages (0xffffff app id) */ -
libfdcore/config.c
r1396 r1397 62 62 fd_g_config->cnf_processing_peers_minimum = 0; 63 63 fd_g_config->cnf_dispthr = 4; 64 fd_g_config->cnf_rtinthr = 1; 65 fd_g_config->cnf_rtoutthr = 1; 66 fd_g_config->cnf_qin_limit = 20; 67 fd_g_config->cnf_qout_limit = 30; 68 fd_g_config->cnf_qlocal_limit = 25; 64 69 fd_list_init(&fd_g_config->cnf_endpoints, NULL); 65 70 fd_list_init(&fd_g_config->cnf_apps, NULL); … … 104 109 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Number of app threads .. : %hu\n", fd_g_config->cnf_dispthr), return NULL); 105 110 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Minimal processing peers : %hu\n", fd_g_config->cnf_processing_peers_minimum), return NULL); 111 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Number of rtin threads . : %hu\n", fd_g_config->cnf_rtinthr), return NULL); 112 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Number of rtout threads : %hu\n", fd_g_config->cnf_rtoutthr), return NULL); 113 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Incoming queue limit : %hu\n", fd_g_config->cnf_qin_limit), return NULL); 114 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Outgoing queue limit : %hu\n", fd_g_config->cnf_qout_limit), return NULL); 115 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local queue limit : %hu\n", fd_g_config->cnf_qlocal_limit), return NULL); 106 116 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { 107 117 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local endpoints ........ : Default (use all available)\n"), return NULL); -
libfdcore/core.c
r1325 r1397 316 316 { 317 317 int ret; 318 CHECK_FCT( fd_queues_init_after_conf() ); 319 318 320 CHECK_POSIX( pthread_mutex_lock(&core_lock) ); 319 321 ret = fd_core_start_int(); -
libfdcore/fdcore-internal.h
r1240 r1397 110 110 /* Message queues */ 111 111 int fd_queues_init(void); 112 int fd_queues_init_after_conf(void); 112 113 int fd_queues_fini(struct fifo ** queue); 113 114 -
libfdcore/fdd.l
r1396 r1397 255 255 (?i:"SCTP_streams") { return SCTPSTREAMS; } 256 256 (?i:"AppServThreads") { return APPSERVTHREADS; } 257 (?i:"RoutingInThreads") { return ROUTINGINTHREADS; } 258 (?i:"RoutingOutThreads") { return ROUTINGOUTTHREADS; } 259 (?i:"IncomingQueueLimit") { return QINLIMIT; } 260 (?i:"OutgoingQueueLimit") { return QOUTLIMIT; } 261 (?i:"LocalQueueLimit") { return QLOCALLIMIT; } 257 262 (?i:"ListenOn") { return LISTENON; } 258 263 (?i:"ThreadsPerServer") { return THRPERSRV; } … … 272 277 (?i:"TLS_DH_bits") { return TLS_DH_BITS; } 273 278 (?i:"TLS_DH_file") { return TLS_DH_FILE; } 279 (?i:"RouteRecordInAnswers") { return RR_IN_ANSWERS; } 280 (?i:"Never") { return NEVER; } 281 (?i:"Always") { return ALWAYS; } 274 282 275 283 -
libfdcore/fdd.y
r1396 r1397 108 108 %token SCTPSTREAMS 109 109 %token APPSERVTHREADS 110 %token ROUTINGINTHREADS 111 %token ROUTINGOUTTHREADS 112 %token QINLIMIT 113 %token QOUTLIMIT 114 %token QLOCALLIMIT 110 115 %token LISTENON 111 116 %token THRPERSRV … … 148 153 | conffile norelay 149 154 | conffile appservthreads 155 | conffile routinginthreads 156 | conffile routingoutthreads 157 | conffile qinlimit 158 | conffile qoutlimit 159 | conffile qlocallimit 150 160 | conffile noip 151 161 | conffile noip6 … … 307 317 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 308 318 conf->cnf_dispthr = (uint16_t)$3; 319 } 320 ; 321 322 routinginthreads: ROUTINGINTHREADS '=' INTEGER ';' 323 { 324 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 256), 325 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 326 conf->cnf_rtinthr = (uint16_t)$3; 327 } 328 ; 329 330 routingoutthreads: ROUTINGOUTTHREADS '=' INTEGER ';' 331 { 332 CHECK_PARAMS_DO( ($3 > 0) && ($3 < 256), 333 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 334 conf->cnf_rtoutthr = (uint16_t)$3; 335 } 336 ; 337 338 qinlimit: QINLIMIT '=' INTEGER ';' 339 { 340 CHECK_PARAMS_DO( ($3 >= 0), 341 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 342 conf->cnf_qin_limit = $3; 343 } 344 ; 345 346 qoutlimit: QOUTLIMIT '=' INTEGER ';' 347 { 348 CHECK_PARAMS_DO( ($3 >= 0), 349 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 350 conf->cnf_qout_limit = $3; 351 } 352 ; 353 354 qlocallimit: QLOCALLIMIT '=' INTEGER ';' 355 { 356 CHECK_PARAMS_DO( ($3 >= 0), 357 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 358 conf->cnf_qlocal_limit = $3; 309 359 } 310 360 ; -
libfdcore/queues.c
r1127 r1397 45 45 { 46 46 TRACE_ENTRY(); 47 CHECK_FCT( fd_fifo_new ( &fd_g_incoming, 20 ) ); 48 CHECK_FCT( fd_fifo_new ( &fd_g_outgoing, 30 ) ); 49 CHECK_FCT( fd_fifo_new ( &fd_g_local, 25 ) ); 47 CHECK_FCT( fd_fifo_new ( &fd_g_incoming, fd_g_config->cnf_qin_limit ) ); 48 CHECK_FCT( fd_fifo_new ( &fd_g_outgoing, fd_g_config->cnf_qout_limit ) ); 49 CHECK_FCT( fd_fifo_new ( &fd_g_local, fd_g_config->cnf_qlocal_limit ) ); 50 return 0; 51 } 52 53 /* Resize according to values given in configuration file */ 54 int fd_queues_init_after_conf(void) 55 { 56 TRACE_ENTRY(); 57 CHECK_FCT( fd_fifo_set_max ( fd_g_incoming, fd_g_config->cnf_qin_limit ) ); 58 CHECK_FCT( fd_fifo_set_max ( fd_g_outgoing, fd_g_config->cnf_qout_limit ) ); 59 CHECK_FCT( fd_fifo_set_max ( fd_g_local, fd_g_config->cnf_qlocal_limit ) ); 50 60 return 0; 51 61 } -
libfdcore/routing_dispatch.c
r1328 r1397 35 35 36 36 #include "fdcore-internal.h" 37 38 #ifdef linux 39 /* This needs -D_USE_GNU, and since I have no idea what else that does, let's simply copy the declaration. */ 40 41 /* Set thread name visible in the kernel and its interfaces. */ 42 extern int pthread_setname_np (pthread_t __target_thread, const char *__name); 43 #endif 37 44 38 45 /********************************************************************************/ … … 1153 1160 static enum thread_state * disp_state = NULL; 1154 1161 1155 /* Later: make this more dynamic */ 1156 static pthread_t rt_out = (pthread_t)NULL; 1157 static enum thread_state out_state = NOTRUNNING; 1158 1159 static pthread_t rt_in = (pthread_t)NULL; 1160 static enum thread_state in_state = NOTRUNNING; 1162 static pthread_t * rt_out = NULL; 1163 static enum thread_state * out_state = NULL; 1164 1165 static pthread_t * rt_in = NULL; 1166 static enum thread_state * in_state = NULL; 1161 1167 1162 1168 /* Initialize the routing and dispatch threads */ … … 1165 1171 int i; 1166 1172 1167 /* Prepare the array for dispatch*/1173 /* Prepare the array for threads */ 1168 1174 CHECK_MALLOC( disp_state = calloc(fd_g_config->cnf_dispthr, sizeof(enum thread_state)) ); 1169 1175 CHECK_MALLOC( dispatch = calloc(fd_g_config->cnf_dispthr, sizeof(pthread_t)) ); 1176 CHECK_MALLOC( out_state = calloc(fd_g_config->cnf_rtoutthr, sizeof(enum thread_state)) ); 1177 CHECK_MALLOC( rt_out = calloc(fd_g_config->cnf_rtoutthr, sizeof(pthread_t)) ); 1178 CHECK_MALLOC( in_state = calloc(fd_g_config->cnf_rtinthr, sizeof(enum thread_state)) ); 1179 CHECK_MALLOC( rt_in = calloc(fd_g_config->cnf_rtinthr, sizeof(pthread_t)) ); 1170 1180 1171 1181 /* Create the threads */ 1172 1182 for (i=0; i < fd_g_config->cnf_dispthr; i++) { 1173 1183 CHECK_POSIX( pthread_create( &dispatch[i], NULL, dispatch_thr, &disp_state[i] ) ); 1174 } 1175 CHECK_POSIX( pthread_create( &rt_out, NULL, routing_out_thr, &out_state) ); 1176 CHECK_POSIX( pthread_create( &rt_in, NULL, routing_in_thr, &in_state) ); 1184 #ifdef linux 1185 pthread_setname_np(dispatch[i], "fd-dispatch"); 1186 #endif 1187 } 1188 for (i=0; i < fd_g_config->cnf_rtoutthr; i++) { 1189 CHECK_POSIX( pthread_create( &rt_out[i], NULL, routing_out_thr, &out_state[i] ) ); 1190 #ifdef linux 1191 pthread_setname_np(rt_out[i], "fd-routing-out"); 1192 #endif 1193 } 1194 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1195 CHECK_POSIX( pthread_create( &rt_in[i], NULL, routing_in_thr, &in_state[i] ) ); 1196 #ifdef linux 1197 pthread_setname_np(rt_in[i], "fd-routing-in"); 1198 #endif 1199 } 1177 1200 1178 1201 /* Later: TODO("Set the thresholds for the queues to create more threads as needed"); */ … … 1245 1268 1246 1269 /* Stop the routing IN thread */ 1247 stop_thread_delayed(&in_state, &rt_in, "IN routing"); 1270 if (rt_in != NULL) { 1271 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1272 stop_thread_delayed(&in_state[i], &rt_in[i], "IN routing"); 1273 } 1274 free(rt_in); 1275 rt_in = NULL; 1276 } 1277 if (in_state != NULL) { 1278 free(in_state); 1279 in_state = NULL; 1280 } 1248 1281 1249 1282 /* Destroy the outgoing queue */ … … 1251 1284 1252 1285 /* Stop the routing OUT thread */ 1253 stop_thread_delayed(&out_state, &rt_out, "OUT routing"); 1286 if (rt_out != NULL) { 1287 for (i=0; i < fd_g_config->cnf_rtinthr; i++) { 1288 stop_thread_delayed(&out_state[i], &rt_out[i], "OUT routing"); 1289 } 1290 free(rt_out); 1291 rt_out = NULL; 1292 } 1293 if (out_state != NULL) { 1294 free(out_state); 1295 out_state = NULL; 1296 } 1254 1297 1255 1298 /* Destroy the local queue */
Note: See TracChangeset
for help on using the changeset viewer.