Fix native deb pkg install dependency
[src/app-framework-binder.git] / src / jobs.c
index 26fc015..9768f26 100644 (file)
 #include "jobs.h"
 #include "sig-monitor.h"
 #include "verbose.h"
+
+#if defined(REMOVE_SYSTEMD_EVENT)
 #include "fdev-epoll.h"
-#if 0
-#define _alert_ "do you really want to remove signal monitoring?"
-#define sig_monitor_init_timeouts()  ((void)0)
-#define sig_monitor_clean_timeouts() ((void)0)
-#define sig_monitor(to,cb,arg)       (cb(0,arg))
 #endif
 
 #define EVENT_TIMEOUT_TOP      ((uint64_t)-1)
@@ -131,11 +128,11 @@ static struct job *free_jobs;
 
 /* event loop */
 static struct evloop evloop[1];
+
+#if defined(REMOVE_SYSTEMD_EVENT)
 static struct fdev_epoll *fdevepoll;
-#if !defined(REMOVE_SYSTEMD_EVENT)
-__attribute__((unused))
-#endif
 static int waitevt;
+#endif
 
 /**
  * Create a new job with the given parameters
@@ -163,7 +160,7 @@ static struct job *job_create(
                job = malloc(sizeof *job);
                pthread_mutex_lock(&mutex);
                if (!job) {
-                       errno = -ENOMEM;
+                       errno = ENOMEM;
                        goto end;
                }
        }
@@ -269,6 +266,7 @@ static void job_cancel(int signum, void *arg)
        job->callback(SIGABRT, job->arg);
 }
 
+#if defined(REMOVE_SYSTEMD_EVENT)
 /**
  * Gets a fdev_epoll item.
  * @return a fdev_epoll or NULL in case of error
@@ -283,6 +281,7 @@ static struct fdev_epoll *get_fdevepoll()
 
        return result;
 }
+#endif
 
 /**
  * Monitored normal callback for events.
@@ -307,7 +306,8 @@ static void evloop_run(int signum, void *arg)
                rc = sd_event_prepare(se);
                if (rc < 0) {
                        errno = -rc;
-                       ERROR("sd_event_prepare returned an error (state: %d): %m", sd_event_get_state(se));
+                       CRITICAL("sd_event_prepare returned an error (state: %d): %m", sd_event_get_state(se));
+                       abort();
                } else {
                        if (rc == 0) {
                                rc = sd_event_wait(se, (uint64_t)(int64_t)-1);
@@ -331,6 +331,7 @@ static void evloop_run(int signum, void *arg)
 }
 
 
+#if defined(REMOVE_SYSTEMD_EVENT)
 /**
  * Monitored normal loop for waiting events.
  * @param signum 0 on normal flow or the number
@@ -338,9 +339,6 @@ static void evloop_run(int signum, void *arg)
  *               flow
  * @param arg     the events to run
  */
-#if !defined(REMOVE_SYSTEMD_EVENT)
-__attribute__((unused))
-#endif
 static void monitored_wait_and_dispatch(int signum, void *arg)
 {
        struct fdev_epoll *fdev_epoll = arg;
@@ -348,6 +346,7 @@ static void monitored_wait_and_dispatch(int signum, void *arg)
                fdev_epoll_wait_and_dispatch(fdev_epoll, -1);
        }
 }
+#endif
 
 /**
  * Main processing loop of threads processing jobs.
@@ -823,6 +822,7 @@ struct sd_event *jobs_get_sd_event()
        return result;
 }
 
+#if defined(REMOVE_SYSTEMD_EVENT)
 /**
  * Gets the fdev_epoll item.
  * @return a fdev_epoll or NULL in case of error
@@ -837,6 +837,7 @@ struct fdev_epoll *jobs_get_fdev_epoll()
 
        return result;
 }
+#endif
 
 /**
  * Enter the jobs processing loop.
@@ -867,12 +868,6 @@ int jobs_start(int allowed_count, int start_count, int waiter_count, void (*star
                goto error;
        }
 
-       /* start */
-       if (sig_monitor_init() < 0) {
-               ERROR("failed to initialise signal handlers");
-               goto error;
-       }
-
        /* records the allowed count */
        allowed = allowed_count;
        started = 0;