A function to return -1, the exit code for the caller. */
| 343 | |
| 344 | /** A function to return -1, the exit code for the caller. */ |
| 345 | static CLIStatus exit_function(int argc, char** argv, ostream& os) |
| 346 | { |
| 347 | unsigned wait =0; |
| 348 | if (argc>2) return BAD_NUM_ARGS; |
| 349 | if (argc==2) wait = atoi(argv[1]); |
| 350 | |
| 351 | if (wait!=0) |
| 352 | os << "waiting up to " << wait << " seconds for clearing of " |
| 353 | << gBTS.TCHActive() << " active calls" << endl; |
| 354 | |
| 355 | // Block creation of new channels. |
| 356 | gBTS.hold(true); |
| 357 | // Wait up to the timeout for active channels to release. |
| 358 | time_t finish = time(NULL) + wait; |
| 359 | while (time(NULL)<finish) { |
| 360 | unsigned load = gBTS.SDCCHActive() + gBTS.TCHActive(); |
| 361 | if (load==0) break; |
| 362 | sleep(1); |
| 363 | } |
| 364 | bool loads = false; |
| 365 | if (gBTS.SDCCHActive()>0) { |
| 366 | LOG(WARNING) << "dropping " << gBTS.SDCCHActive() << " control transactions on exit"; |
| 367 | loads = true; |
| 368 | } |
| 369 | if (gBTS.TCHActive()>0) { |
| 370 | LOG(WARNING) << "dropping " << gBTS.TCHActive() << " calls on exit"; |
| 371 | loads = true; |
| 372 | } |
| 373 | if (loads) { |
| 374 | os << endl << "exiting with loads:" << endl; |
| 375 | printStats(1,NULL,os); |
| 376 | } |
| 377 | LOG(ALERT) << "exiting OpenBTS as directed by command line..."; // This is sent to the log file. |
| 378 | os << endl << "exiting..." << endl; // This is sent to OpenBTSCLI |
| 379 | // We have to return CLI_EXIT rather than just exiting so we can send the result to OpenBTSCLI. |
| 380 | return CLI_EXIT; |
| 381 | } |
| 382 | |
| 383 | |
| 384 | /** Print or clear the TMSI table. */ |
nothing calls this directly
no test coverage detected