| 481 | /* Send loop & traffic generation*/ |
| 482 | |
| 483 | static void traffic_thread(int &rtp_errors, int &echo_errors) |
| 484 | { |
| 485 | /* create the file */ |
| 486 | char L_file_name[MAX_PATH]; |
| 487 | sprintf(L_file_name, "%s_%ld_screen.log", scenario_file, (long) getpid()); |
| 488 | |
| 489 | update_clock_tick(); |
| 490 | |
| 491 | /* Arm the global timer if needed */ |
| 492 | if (global_timeout > 0) { |
| 493 | signal(SIGALRM, timeout_alarm); |
| 494 | alarm(global_timeout / 1000); |
| 495 | } |
| 496 | |
| 497 | // Dump (to create file on disk) and showing screen at the beginning even if |
| 498 | // the report period is not reached |
| 499 | stattask::report(); |
| 500 | screentask::report(false); |
| 501 | |
| 502 | while (1) { |
| 503 | scheduling_loops++; |
| 504 | update_clock_tick(); |
| 505 | |
| 506 | if (signalDump) { |
| 507 | /* Screen dumping in a file */ |
| 508 | if (useScreenf == 1) { |
| 509 | print_screens(); |
| 510 | } else { |
| 511 | /* If the -trace_screen option has not been set, */ |
| 512 | /* create the file at this occasion */ |
| 513 | rotate_screenf(); |
| 514 | print_screens(); |
| 515 | } |
| 516 | |
| 517 | if (dumpInRtt) { |
| 518 | main_scenario->stats->dumpDataRtt(); |
| 519 | } |
| 520 | |
| 521 | signalDump = false; |
| 522 | } |
| 523 | |
| 524 | while (sockets_pending_reset.begin() != sockets_pending_reset.end()) { |
| 525 | (*(sockets_pending_reset.begin()))->reset_connection(); |
| 526 | sockets_pending_reset.erase(sockets_pending_reset.begin()); |
| 527 | } |
| 528 | |
| 529 | if (!quitting && (main_scenario->stats->GetStat(CStat::CPT_C_IncomingCallCreated) + main_scenario->stats->GetStat(CStat::CPT_C_OutgoingCallCreated)) >= stop_after) { |
| 530 | quitting = 1; |
| 531 | } |
| 532 | if (quitting) { |
| 533 | /* Quitting and no more opened calls, close all */ |
| 534 | if ((quitting >= 11) || !main_scenario->stats->GetStat(CStat::CPT_C_CurrentCall)) { |
| 535 | /* We can have calls that do not count towards our open-call count (e.g., dead calls). */ |
| 536 | abort_all_tasks(); |
| 537 | rtp_errors = rtpstream_shutdown(main_scenario->fetchRtpTaskThreadIDs()); |
| 538 | echo_errors = main_scenario->stats->getRtpEchoErrors(); |
| 539 | |
| 540 | /* Reverse order shutdown, because deleting reorders the |
no test coverage detected