diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-06 23:53:30 +0300 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-12-31 12:20:59 +0100 |
commit | 4ffd6f20a9b7604308506d9e04ef1bb2e41cd282 (patch) | |
tree | 0f4bcba1aecee4344478b45185e53b2945f5415f /src | |
parent | 5716ca636d8638060e525f428a497ddee18b4072 (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.
Diffstat (limited to 'src')
-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; } |