Changeset 4366
- Timestamp:
- 01/07/11 23:20:54 (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r4352 r4366 260 260 #define DEFAULT_NBEST 1 261 261 #define DEFAULT_NFB 1 262 #define DEFAULT_RETRYLIMIT 2200 262 263 263 264 enum {E1_GLOBAL=0, E1_USER, E1_READER, E1_SERVER, E1_LSERVER}; … … 1155 1156 int lb_max_ecmcount; // maximum ecm count before reseting lbvalues 1156 1157 int lb_reopen_seconds; //time between retrying failed readers/caids/prov/srv 1157 1158 int lb_retrylimit; //reopen only happens if reader response time > retrylimit 1158 1159 int resolve_gethostbyname; 1159 1160 -
trunk/module-stat.c
r4360 r4366 24 24 if (cfg->lb_reopen_seconds < 10) 25 25 cfg->lb_reopen_seconds = DEFAULT_REOPEN_SECONDS; 26 if (cfg->lb_retrylimit <= 0) 27 cfg->lb_retrylimit = DEFAULT_RETRYLIMIT; 26 28 } 27 29 … … 100 102 LL_ITER *it = ll_iter_create(rdr->lb_stat); 101 103 READER_STAT *stat = NULL; 104 int i = 0; 102 105 while ((stat = ll_iter_next(it))) { 103 106 if (stat->caid==caid && stat->prid==prid && stat->srvid==srvid) { 107 if (i > 5) { //Move to first if not under top 5: 108 ll_iter_remove(it); 109 ll_insert_at(rdr->lb_stat, stat, 0); //move to first! 110 } 104 111 break; 105 112 } 113 i++; 106 114 } 107 115 ll_iter_release(it); … … 233 241 stat->rc = 0; 234 242 stat->ecm_count++; 235 stat->time_idx++;236 243 stat->last_received = time(NULL); 237 244 stat->request_count = 0; 238 245 239 246 //FASTEST READER: 247 stat->time_idx++; 240 248 if (stat->time_idx >= LB_MAX_STAT_TIME) 241 249 stat->time_idx = 0; … … 272 280 stat->request_count++; 273 281 stat->last_received = time(NULL); 282 283 //add timeout to stat: 284 if (ecm_time<=0) 285 ecm_time = cfg->ctimeout; 286 stat->time_idx++; 287 if (stat->time_idx >= LB_MAX_STAT_TIME) 288 stat->time_idx = 0; 289 stat->time_stat[stat->time_idx] = ecm_time; 290 calc_stat(stat); 274 291 } 275 292 else … … 353 370 memset(result, 0, sizeof(result)); 354 371 int re[rdr_count]; 355 372 int ti[rdr_count]; 373 356 374 //resulting values: 357 375 memset(re, 0, sizeof(re)); 358 376 memset(ti, 0, sizeof(ti)); 377 359 378 struct timeb new_nulltime; 360 379 memset(&new_nulltime, 0, sizeof(new_nulltime)); … … 369 388 370 389 #ifdef WITH_DEBUG 371 //else372 // cs_debug_mask(D_TRACE, "loadbalancer: no best reader found, trying all readers");373 374 390 char rdrs[rdr_count+1]; 375 391 for (i=0;i<rdr_count;i++) … … 394 410 continue; 395 411 } 412 413 ti[i] = stat->time_avg; 396 414 397 415 if (stat->ecm_count < 0||(stat->ecm_count > cfg->lb_max_ecmcount && stat->time_avg > (int)cfg->ftimeout)) { … … 457 475 re[i] = current; 458 476 } 459 else460 {461 int seconds = cfg->lb_reopen_seconds;462 if (!rdr->audisabled && (er->client->autoau || er->client->aureader == rdr))463 seconds = seconds/10;464 465 if (stat->last_received+seconds < current_time) { //Retrying reader every (900/conf) seconds466 stat->last_received = current_time;467 result[i] = 1;468 cs_log("loadbalancer: retrying reader %s", rdr->label);469 }470 }471 477 } 472 478 } … … 567 573 #endif 568 574 575 //reopen other reader only if responsetime>retrylimit: 576 int reopen = (best_ridx>=0 && ti[best_ridx] && (ti[best_ridx] > cfg->lb_retrylimit)); 577 if (reopen) 578 cs_debug_mask(D_TRACE, "loadbalancer: reader %s reached retrylimit (%dms), reopening other readers", best_rdr->label, ti[best_ridx]); 579 569 580 for (i=0,rdr=first_reader; rdr ; rdr=rdr->next, i++) { 570 581 if (i>=rdr_count) 571 582 break; 583 584 if (!er->matching_rdr[i]) 585 continue; 586 572 587 if (result[i] == 1) { //primary readers 573 588 stat = get_stat(rdr, er->caid, er->prid, er->srvid); … … 578 593 cs_debug_mask(D_TRACE, "loadbalancer: reader %s increment request count to %d", rdr->label, stat->request_count); 579 594 } 580 } 595 } else if (reopen) { //retrylimit reached: 596 stat = get_stat(rdr, er->caid, er->prid, er->srvid); 597 if (stat && stat->rc != 0) { 598 int seconds = cfg->lb_reopen_seconds; 599 if (!rdr->audisabled && (er->client->autoau || er->client->aureader == rdr)) 600 seconds = seconds/10; //reopen faster if reader is a au reader 601 602 if (stat->last_received+seconds < current_time) { //Retrying reader every (900/conf) seconds 603 stat->last_received = current_time; 604 result[i] = 1; 605 cs_log("loadbalancer: retrying reader %s", rdr->label); 606 } 607 } 608 } 581 609 } 582 610 -
trunk/oscam-config.c
r4356 r4366 504 504 if (!strcmp(token, "lb_reopen_seconds")) { 505 505 cfg->lb_reopen_seconds = strToIntVal(value, 0); 506 return; 507 } 508 509 if (!strcmp(token, "lb_retrylimit")) { 510 cfg->lb_retrylimit = strToIntVal(value, 0); 506 511 return; 507 512 } … … 1753 1758 if (cfg->lb_reopen_seconds != DEFAULT_REOPEN_SECONDS ||(cfg->lb_reopen_seconds == DEFAULT_REOPEN_SECONDS && cfg->http_full_cfg)) 1754 1759 fprintf_conf(f, CONFVARWIDTH, "lb_reopen_seconds", "%d\n", cfg->lb_reopen_seconds); 1760 if (cfg->lb_retrylimit != DEFAULT_RETRYLIMIT || cfg->http_full_cfg) 1761 fprintf_conf(f, CONFVARWIDTH, "lb_retrylimit", "%d\n", cfg->lb_retrylimit); 1755 1762 1756 1763 if (cfg->resolve_gethostbyname ||(!cfg->resolve_gethostbyname && cfg->http_full_cfg))
Note:
See TracChangeset
for help on using the changeset viewer.