chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unit: reduce heap usage for unit objects
[elogind.git]
/
src
/
unit.h
diff --git
a/src/unit.h
b/src/unit.h
index b32c1a702e241dca527ebed1590d22a207c0ed00..626bdc43af6b1a793a99d9f0c6011c93940cffa3 100644
(file)
--- a/
src/unit.h
+++ b/
src/unit.h
@@
-32,6
+32,7
@@
typedef enum UnitType UnitType;
typedef enum UnitLoadState UnitLoadState;
typedef enum UnitActiveState UnitActiveState;
typedef enum UnitDependency UnitDependency;
typedef enum UnitLoadState UnitLoadState;
typedef enum UnitActiveState UnitActiveState;
typedef enum UnitDependency UnitDependency;
+typedef struct UnitRef UnitRef;
#include "set.h"
#include "util.h"
#include "set.h"
#include "util.h"
@@
-119,6
+120,14
@@
enum UnitDependency {
/* On Failure */
UNIT_ON_FAILURE,
/* On Failure */
UNIT_ON_FAILURE,
+ /* Triggers (i.e. a socket triggers a service) */
+ UNIT_TRIGGERS,
+ UNIT_TRIGGERED_BY,
+
+ /* Propagate reloads */
+ UNIT_PROPAGATE_RELOAD_TO,
+ UNIT_PROPAGATE_RELOAD_FROM,
+
/* Reference information for GC logic */
UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
UNIT_REFERENCED_BY,
/* Reference information for GC logic */
UNIT_REFERENCES, /* Inverse of 'references' is 'referenced_by' */
UNIT_REFERENCED_BY,
@@
-156,6
+165,9
@@
struct Meta {
usec_t job_timeout;
usec_t job_timeout;
+ /* References to this */
+ LIST_HEAD(UnitRef, refs);
+
/* Conditions to check */
LIST_HEAD(Condition, conditions);
/* Conditions to check */
LIST_HEAD(Condition, conditions);
@@
-237,6
+249,15
@@
struct Meta {
bool in_audit:1;
};
bool in_audit:1;
};
+struct UnitRef {
+ /* Keeps tracks of references to a unit. This is useful so
+ * that we can merge two units if necessary and correct all
+ * references to them */
+
+ Unit* unit;
+ LIST_FIELDS(UnitRef, refs);
+};
+
#include "service.h"
#include "timer.h"
#include "socket.h"
#include "service.h"
#include "timer.h"
#include "socket.h"
@@
-265,6
+286,9
@@
union Unit {
struct UnitVTable {
const char *suffix;
struct UnitVTable {
const char *suffix;
+ /* How much memory does an object of this unit type need */
+ size_t object_size;
+
/* Config file sections this unit type understands, separated
* by NUL chars */
const char *sections;
/* Config file sections this unit type understands, separated
* by NUL chars */
const char *sections;
@@
-414,7
+438,7
@@
DEFINE_CAST(SNAPSHOT, Snapshot);
DEFINE_CAST(SWAP, Swap);
DEFINE_CAST(PATH, Path);
DEFINE_CAST(SWAP, Swap);
DEFINE_CAST(PATH, Path);
-Unit *unit_new(Manager *m);
+Unit *unit_new(Manager *m
, size_t size
);
void unit_free(Unit *u);
int unit_add_name(Unit *u, const char *name);
void unit_free(Unit *u);
int unit_add_name(Unit *u, const char *name);
@@
-536,6
+560,11
@@
bool unit_condition_test(Unit *u);
UnitFileState unit_get_unit_file_state(Unit *u);
UnitFileState unit_get_unit_file_state(Unit *u);
+Unit* unit_ref_set(UnitRef *ref, Unit *u);
+void unit_ref_unset(UnitRef *ref);
+
+#define UNIT_DEREF(ref) ((ref).unit)
+
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);
const char *unit_load_state_to_string(UnitLoadState i);
UnitLoadState unit_load_state_from_string(const char *s);