Changeset 1396:188c82b6690b in freeDiameter for libfdcore
- Timestamp:
- Nov 15, 2019, 7:38:30 PM (4 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libfdcore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdcore/config.c
r1326 r1396 60 60 fd_g_config->cnf_sctp_str = 30; 61 61 fd_g_config->cnf_thr_srv = 5; 62 fd_g_config->cnf_processing_peers_minimum = 0; 62 63 fd_g_config->cnf_dispthr = 4; 63 64 fd_list_init(&fd_g_config->cnf_endpoints, NULL); … … 102 103 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Number of clients thr .. : %d\n", fd_g_config->cnf_thr_srv), return NULL); 103 104 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Number of app threads .. : %hu\n", fd_g_config->cnf_dispthr), return NULL); 105 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Minimal processing peers : %hu\n", fd_g_config->cnf_processing_peers_minimum), return NULL); 104 106 if (FD_IS_LIST_EMPTY(&fd_g_config->cnf_endpoints)) { 105 107 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, " Local endpoints ........ : Default (use all available)\n"), return NULL); -
libfdcore/fdd.l
r1394 r1396 257 257 (?i:"ListenOn") { return LISTENON; } 258 258 (?i:"ThreadsPerServer") { return THRPERSRV; } 259 (?i:"ProcessingPeersPattern") { return PROCESSINGPEERSPATTERN; } 260 (?i:"ProcessingPeersMinimum") { return PROCESSINGPEERSMINIMUM; } 259 261 (?i:"TcTimer") { return TCTIMER; } 260 262 (?i:"TwTimer") { return TWTIMER; } -
libfdcore/fdd.y
r1326 r1396 110 110 %token LISTENON 111 111 %token THRPERSRV 112 %token PROCESSINGPEERSPATTERN 113 %token PROCESSINGPEERSMINIMUM 112 114 %token TCTIMER 113 115 %token TWTIMER … … 142 144 | conffile listenon 143 145 | conffile thrpersrv 146 | conffile processingpeerspattern 147 | conffile processingpeersminimum 144 148 | conffile norelay 145 149 | conffile appservthreads … … 250 254 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 251 255 conf->cnf_thr_srv = $3; 256 } 257 ; 258 259 processingpeerspattern: PROCESSINGPEERSPATTERN '=' QSTRING ';' 260 { 261 char *pattern = $3; 262 int err; 263 CHECK_FCT_DO( err=regcomp(&conf->cnf_processing_peers_pattern_regex, pattern, REG_EXTENDED | REG_NOSUB), 264 { 265 char * buf; 266 size_t bl; 267 268 /* Error while compiling the regex */ 269 TRACE_DEBUG(INFO, "error while compiling the regular expression '%s':", pattern); 270 271 /* Get the error message size */ 272 bl = regerror(err, &conf->cnf_processing_peers_pattern_regex, NULL, 0); 273 274 /* Alloc the buffer for error message */ 275 CHECK_MALLOC( buf = malloc(bl) ); 276 277 /* Get the error message content */ 278 regerror(err, &conf->cnf_processing_peers_pattern_regex, buf, bl); 279 TRACE_DEBUG(INFO, "\t%s", buf); 280 281 /* Free the buffer, return the error */ 282 free(buf); 283 284 yyerror (&yylloc, conf, "Invalid regular expression in ProcessingPeersPattern"); 285 YYERROR; 286 } ); 287 } 288 ; 289 290 processingpeersminimum: PROCESSINGPEERSMINIMUM '=' INTEGER ';' 291 { 292 CHECK_PARAMS_DO( ($3 >= 0), 293 { yyerror (&yylloc, conf, "Invalid value"); YYERROR; } ); 294 conf->cnf_processing_peers_minimum = $3; 252 295 } 253 296 ; -
libfdcore/p_ce.c
r1281 r1396 834 834 } 835 835 836 /* Check if enough processing peers are connected to allow connections by other peers */ 837 static int sufficient_processing_peers(void) { 838 int processing_peers_count = 0; 839 struct fd_list * li; 840 841 CHECK_FCT( pthread_rwlock_rdlock(&fd_g_activ_peers_rw) ); 842 for (li = fd_g_activ_peers.next; li != &fd_g_activ_peers; li = li->next) { 843 struct fd_peer * p = (struct fd_peer *)li->o; 844 845 TRACE_DEBUG(FULL, "comparing '%s' against processing peers pattern", p->p_hdr.info.pi_diamid); 846 if (regexec(&fd_g_config->cnf_processing_peers_pattern_regex, p->p_hdr.info.pi_diamid, 0, NULL, 0) == 0) { 847 processing_peers_count++; 848 } 849 } 850 CHECK_FCT( pthread_rwlock_unlock(&fd_g_activ_peers_rw) ); 851 852 TRACE_DEBUG(FULL, "%d processing peers found", processing_peers_count); 853 return (processing_peers_count >= fd_g_config->cnf_processing_peers_minimum); 854 } 855 836 856 /* Handle the receiver side to go to OPEN or OPEN_NEW state (any election is resolved) */ 837 857 int fd_p_ce_process_receiver(struct fd_peer * peer) … … 884 904 } 885 905 906 /* Check peer type and if enough processing peers are already connected */ 907 if (fd_g_config->cnf_processing_peers_minimum > 0) { 908 if (regexec(&fd_g_config->cnf_processing_peers_pattern_regex, peer->p_hdr.info.pi_diamid, 0, NULL, 0) != 0) { 909 /* peer is not a processing peer */ 910 if (!sufficient_processing_peers()) { 911 pei.pei_errcode = "DIAMETER_TOO_BUSY"; 912 goto error_abort; 913 } 914 } 915 } 916 917 if (peer->p_flags.pf_responder) { 918 int res = fd_peer_validate( peer ); 919 if (res < 0) { 920 TRACE_DEBUG(INFO, "Rejected CER from peer '%s', validation failed (returning DIAMETER_UNKNOWN_PEER).", peer->p_hdr.info.pi_diamid); 921 pei.pei_errcode = "DIAMETER_UNKNOWN_PEER"; 922 goto error_abort; 923 } 924 CHECK_FCT( res ); 925 } 886 926 /* Check if we have common applications */ 887 927 if ( fd_g_config->cnf_flags.no_fwd && (! peer->p_hdr.info.runtime.pir_relay) ) {
Note: See TracChangeset
for help on using the changeset viewer.