summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-06 23:53:30 +0300
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-31 12:20:59 +0100
commit4ffd6f20a9b7604308506d9e04ef1bb2e41cd282 (patch)
tree0f4bcba1aecee4344478b45185e53b2945f5415f /src/main.c
parent5716ca636d8638060e525f428a497ddee18b4072 (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/main.c')
-rw-r--r--src/main.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/main.c b/src/main.c
index 661f246..90779af 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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;
}