summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2016-04-20 12:48:12 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2016-04-20 12:48:12 +0200
commit769c9f5a2434da149bcf22b3bbcc2e60a1d85c14 (patch)
treec22156879adc06519bc8ecb1fd097fe7a5e83dc4 /bin
parentd3611bac94257a8115e35311f6f3bdea633ff14e (diff)
ufod: simplify teardown
However, due to the tremendous threading construct it still locks ...
Diffstat (limited to 'bin')
-rw-r--r--bin/ufod.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/bin/ufod.c b/bin/ufod.c
index 5f87397..9cb9367 100644
--- a/bin/ufod.c
+++ b/bin/ufod.c
@@ -29,7 +29,9 @@
#include <string.h>
#include <ufo/ufo.h>
-static UfoDaemon *global_daemon;
+
+static UfoDaemon *global_daemon = NULL;
+static gboolean done = FALSE;
typedef struct {
gchar **paths;
@@ -89,24 +91,13 @@ opts_free (Options *opts)
static void
terminate (int signum)
{
- GError *error = NULL;
-
if (signum == SIGTERM)
g_print ("Received SIGTERM, exiting...\n");
if (signum == SIGINT)
g_print ("Received SIGINT, exiting...\n");
- if (global_daemon != NULL) {
- ufo_daemon_stop (global_daemon, &error);
-
- if (error != NULL)
- g_printerr ("Error: %s\n", error->message);
-
- g_object_unref (global_daemon);
- }
-
- exit (EXIT_SUCCESS);
+ done = TRUE;
}
int
@@ -137,9 +128,10 @@ main (int argc, char * argv[])
g_print ("ufod %s - waiting for requests on %s ...\n", UFO_VERSION, opts->addr);
- while (TRUE) {
- g_usleep (G_MAXULONG);
- }
+ while (!done)
+ g_usleep (G_USEC_PER_SEC);
+
+ ufo_daemon_stop (global_daemon, &error);
error:
if (error != NULL)