diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2017-09-07 17:51:35 +0300 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2017-12-31 12:20:59 +0100 |
commit | b40a54dc97e28e31e4a9be8a3aa634eaafb219d5 (patch) | |
tree | f1b7cd7163d815f2da9509e8775509dc62ca56ed | |
parent | 11943bf320ca5ed3e9efd099d27c3ed3b3631832 (diff) |
osmo-gapk: abort the processing queue on SIGINT
Instead of immediately shutting down the application, it is
better to try to break the processing queue first, and stop
the execution immediately if second SIGINT is received.
-rw-r--r-- | src/app_osmo_gapk.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/app_osmo_gapk.c b/src/app_osmo_gapk.c index 4c13570..d02ccbe 100644 --- a/src/app_osmo_gapk.c +++ b/src/app_osmo_gapk.c @@ -67,8 +67,8 @@ struct gapk_options struct gapk_state { struct gapk_options opts; - struct osmo_gapk_pq *pq; + int exit; struct { struct { @@ -622,7 +622,11 @@ run(struct gapk_state *gs) if (rv) return rv; - for (frames=0; !(rv = osmo_gapk_pq_execute(gs->pq)); frames++); + for (frames = 0; !gs->exit; frames++) { + rv = osmo_gapk_pq_execute(gs->pq); + if (rv) + break; + } LOGP(DAPP, LOGL_NOTICE, "Processed %d frames\n", frames); @@ -649,11 +653,14 @@ static void app_shutdown(void) static void signal_handler(int signal) { + fprintf(stderr, "signal %u received\n", signal); + switch (signal) { case SIGINT: - fprintf(stderr, "catching sigint, shutting down...\n"); - app_shutdown(); - exit(0); + if (gs->exit++) { + app_shutdown(); + exit(0); + } break; default: break; |