/*
- * Copyright (C) 2016, 2017, 2018 "IoT.bzh"
+ * Copyright (C) 2016-2019 "IoT.bzh"
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
#include "afb-api-so-v2.h"
#include "afb-api-v3.h"
#include "afb-common.h"
-#include "afb-systemd.h"
#include "afb-cred.h"
#include "afb-evt.h"
#include "afb-export.h"
#include "afb-session.h"
#include "afb-xreq.h"
#include "afb-calls.h"
+
+#include "systemd.h"
#include "jobs.h"
#include "verbose.h"
#include "globset.h"
return afb_evt_broadcast(event, object);
}
+static struct sd_event *get_event_loop(struct afb_api_x3 *closure)
+{
+ jobs_acquire_event_manager();
+ return systemd_get_event_loop();
+}
+
+static struct sd_bus *get_user_bus(struct afb_api_x3 *closure)
+{
+ jobs_acquire_event_manager();
+ return systemd_get_user_bus();
+}
+
+static struct sd_bus *get_system_bus(struct afb_api_x3 *closure)
+{
+ jobs_acquire_event_manager();
+ return systemd_get_system_bus();
+}
+
static int rootdir_open_locale_cb(struct afb_api_x3 *closure, const char *filename, int flags, const char *locale)
{
return afb_common_rootdir_open_locale(filename, flags, locale);
static struct sd_event *hooked_get_event_loop(struct afb_api_x3 *closure)
{
struct afb_export *export = from_api_x3(closure);
- struct sd_event *r = afb_systemd_get_event_loop();
+ struct sd_event *r;
+
+ jobs_acquire_event_manager();
+ r = get_event_loop(closure);
return afb_hook_api_get_event_loop(export, r);
}
static struct sd_bus *hooked_get_user_bus(struct afb_api_x3 *closure)
{
struct afb_export *export = from_api_x3(closure);
- struct sd_bus *r = afb_systemd_get_user_bus();
+ struct sd_bus *r;
+
+ jobs_acquire_event_manager();
+ r = get_user_bus(closure);
return afb_hook_api_get_user_bus(export, r);
}
static struct sd_bus *hooked_get_system_bus(struct afb_api_x3 *closure)
{
struct afb_export *export = from_api_x3(closure);
- struct sd_bus *r = afb_systemd_get_system_bus();
+ struct sd_bus *r;
+
+ jobs_acquire_event_manager();
+ r = get_system_bus(closure);
return afb_hook_api_get_system_bus(export, r);
}
.vverbose_v2 = vverbose_cb,
.event_make = legacy_event_x1_make_cb,
.event_broadcast = event_broadcast_cb,
- .get_event_loop = afb_systemd_get_event_loop,
- .get_user_bus = afb_systemd_get_user_bus,
- .get_system_bus = afb_systemd_get_system_bus,
+ .get_event_loop = get_event_loop,
+ .get_user_bus = get_user_bus,
+ .get_system_bus = get_system_bus,
.rootdir_get_fd = afb_common_rootdir_get_fd,
.rootdir_open_locale = rootdir_open_locale_cb,
.queue_job = queue_job_cb,
.vverbose = (void*)vverbose_cb,
- .get_event_loop = afb_systemd_get_event_loop,
- .get_user_bus = afb_systemd_get_user_bus,
- .get_system_bus = afb_systemd_get_system_bus,
+ .get_event_loop = get_event_loop,
+ .get_user_bus = get_user_bus,
+ .get_system_bus = get_system_bus,
.rootdir_get_fd = afb_common_rootdir_get_fd,
.rootdir_open_locale = rootdir_open_locale_cb,
.queue_job = queue_job_cb,