aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-07 17:51:35 +0300
committerVadim Yanitskiy <axilirator@gmail.com>2017-09-08 00:13:42 +0300
commit3e8cfdea6a2e1da03b6601c96b87d2a5683c73c6 (patch)
treea121acfe182cd4ef2c19c095609fc2409ef1ed34
parent0d177795d1ffe70d926281034116d73199265202 (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.c17
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;