diff options
| author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-06 23:53:30 +0300 |
|---|---|---|
| committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-06 23:53:30 +0300 |
| commit | d8bdf47aaffb768c26b89511d1af7bce616543d2 (patch) | |
| tree | 867d2fe7e79367c29518b9bbb4d1797de7aef5bd | |
| parent | 6e0fe0e103612e01817dba857f5077adeb87ea84 (diff) | |
osmo-gapk: create a common shutdown function
Previously the code intended to shutdown the osmo-gapk application
was repeated two times. It's better to have a single function.
| -rw-r--r-- | src/main.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -587,13 +587,27 @@ run(struct gapk_state *gs) static struct gapk_state _gs, *gs = &_gs; +static void app_shutdown(void) +{ + /* Close source / destination files */ + files_close(gs); + + /* Release processing queue */ + osmo_gapk_pq_destroy(gs->pq); + + /* Print benchmarking results, if enabled */ + benchmark_dump(); + + /* Free memory taken by benchmark data */ + osmo_gapk_bench_free(); +} + static void signal_handler(int signal) { switch (signal) { case SIGINT: - fprintf(stderr, "catching sigint, closing files\n"); - files_close(gs); - osmo_gapk_pq_destroy(gs->pq); + fprintf(stderr, "catching sigint, shutting down...\n"); + app_shutdown(); exit(0); break; default: @@ -660,16 +674,6 @@ int main(int argc, char *argv[]) rv = run(gs); error: - /* Close source / destination files */ - files_close(gs); - - /* Release processing queue */ - osmo_gapk_pq_destroy(gs->pq); - - benchmark_dump(); - - /* Free memory taken by benchmark data */ - osmo_gapk_bench_free(); - + app_shutdown(); return rv; } |
