• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eclipse-bluechi / bluechi / 15045056381

15 May 2025 12:33PM UTC coverage: 37.505% (-44.9%) from 82.405%
15045056381

Pull #1072

github

web-flow
Merge b13cd68af into 04834083b
Pull Request #1072: Prevent tmt from pruning coverage files

1888 of 5034 relevant lines covered (37.5%)

23.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/controller/monitor.h
1
/*
2
 * Copyright Contributors to the Eclipse BlueChi project
3
 *
4
 * SPDX-License-Identifier: LGPL-2.1-or-later
5
 */
6
#pragma once
7

8
#include "libbluechi/common/common.h"
9

10
#include "types.h"
11

12
typedef int(unit_property_changed_handler_func_t)(
13
                void *monitor, const char *node, const char *unit, const char *interface, sd_bus_message *m);
14
typedef int(unit_new_handler_func_t)(void *monitor, const char *node, const char *unit, const char *reason);
15
typedef int(unit_state_changed_handler_func_t)(
16
                void *monitor,
17
                const char *node,
18
                const char *unit,
19
                const char *active_state,
20
                const char *substate,
21
                const char *reason);
22
typedef int(unit_removed_handler_func_t)(void *monitor, const char *node, const char *unit, const char *reason);
23

24

25
struct SubscribedUnit {
26
        char *name;
27
        LIST_FIELDS(SubscribedUnit, units);
28
};
29

30
struct Subscription {
31
        int ref_count;
32
        uint32_t id;
33

34
        void *monitor;
35
        free_func_t free_monitor;
36

37
        char *node;
38
        LIST_HEAD(SubscribedUnit, subscribed_units);
39

40
        LIST_FIELDS(Subscription, subscriptions);     /* List in Monitor */
41
        LIST_FIELDS(Subscription, all_subscriptions); /* List in Controller */
42

43
        unit_new_handler_func_t *handle_unit_new;
44
        unit_removed_handler_func_t *handle_unit_removed;
45
        unit_state_changed_handler_func_t *handle_unit_state_changed;
46
        unit_property_changed_handler_func_t *handle_unit_property_changed;
47
};
48

49
Subscription *subscription_new(const char *node);
50
Subscription *create_monitor_subscription(Monitor *monitor, const char *node);
51

52
bool subscription_add_unit(Subscription *sub, const char *unit);
53
bool subscription_has_node_wildcard(Subscription *sub);
54

55
Subscription *subscription_ref(Subscription *subscription);
56
void subscription_unref(Subscription *subscription);
57

58
DEFINE_CLEANUP_FUNC(Subscription, subscription_unref)
×
59
#define _cleanup_subscription_ _cleanup_(subscription_unrefp)
60

61
struct MonitorPeer {
62
        uint32_t id;
63
        char *name;
64
        LIST_FIELDS(MonitorPeer, peers);
65
};
66

67
struct Monitor {
68
        int ref_count;
69
        uint32_t id;
70

71
        char *owner;
72
        LIST_HEAD(MonitorPeer, peers);
73

74
        Controller *controller; /* weak ref */
75

76
        sd_bus_slot *export_slot;
77
        char *object_path;
78

79
        LIST_HEAD(Subscription, subscriptions);
80

81
        LIST_FIELDS(Monitor, monitors);
82
};
83

84
Monitor *monitor_new(Controller *controller, const char *owner);
85
Monitor *monitor_ref(Monitor *monitor);
86
void monitor_unref(Monitor *monitor);
87

88
void monitor_close(Monitor *monitor);
89

90
bool monitor_export(Monitor *monitor);
91

92
int monitor_on_unit_property_changed(
93
                void *userdata, const char *node, const char *unit, const char *interface, sd_bus_message *m);
94
int monitor_on_unit_new(void *userdata, const char *node, const char *unit, const char *reason);
95
int monitor_on_unit_state_changed(
96
                void *userdata,
97
                const char *node,
98
                const char *unit,
99
                const char *active_state,
100
                const char *substate,
101
                const char *reason);
102
int monitor_on_unit_removed(void *userdata, const char *node, const char *unit, const char *reason);
103

104
DEFINE_CLEANUP_FUNC(Monitor, monitor_unref)
×
105
#define _cleanup_monitor_ _cleanup_(monitor_unrefp)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc