summaryrefslogtreecommitdiff
path: root/sysdep/unix/domain.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-04-24 16:10:59 +0200
committerMaria Matejka <mq@ucw.cz>2023-04-25 09:52:28 +0200
commitce7495b49a5192b1cba17fd88cdb2495a40824e2 (patch)
tree005901ea2c816483fd1e195a066b0685f8c4d7b9 /sysdep/unix/domain.c
parent19e79eb8adddb6194248974443b9a906f66984ce (diff)
Refactoring of domains connected to pools
Diffstat (limited to 'sysdep/unix/domain.c')
-rw-r--r--sysdep/unix/domain.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/sysdep/unix/domain.c b/sysdep/unix/domain.c
index f4ee595d..c04e91ea 100644
--- a/sysdep/unix/domain.c
+++ b/sysdep/unix/domain.c
@@ -46,20 +46,21 @@ struct domain_generic {
struct domain_generic **prev;
struct lock_order *locked_by;
const char *name;
+ pool *pool;
};
-#define DOMAIN_INIT(_name, _order) { .mutex = PTHREAD_MUTEX_INITIALIZER, .name = _name, .order = _order }
+#define DOMAIN_INIT(_order) { .mutex = PTHREAD_MUTEX_INITIALIZER, .order = _order }
-static struct domain_generic the_bird_domain_gen = DOMAIN_INIT("The BIRD", OFFSETOF(struct lock_order, the_bird));
+static struct domain_generic the_bird_domain_gen = DOMAIN_INIT(OFFSETOF(struct lock_order, the_bird));
DOMAIN(the_bird) the_bird_domain = { .the_bird = &the_bird_domain_gen };
struct domain_generic *
-domain_new(const char *name, uint order)
+domain_new(uint order)
{
ASSERT_DIE(order < sizeof(struct lock_order));
struct domain_generic *dg = xmalloc(sizeof(struct domain_generic));
- *dg = (struct domain_generic) DOMAIN_INIT(name, order);
+ *dg = (struct domain_generic) DOMAIN_INIT(order);
return dg;
}
@@ -81,6 +82,14 @@ uint dg_order(struct domain_generic *dg)
return dg->order;
}
+void
+domain_setup(struct domain_generic *dg, const char *name, pool *p)
+{
+ ASSERT_DIE(dg->pool == NULL);
+ dg->pool = p;
+ dg->name = name;
+}
+
void do_lock(struct domain_generic *dg, struct domain_generic **lsp)
{
struct lock_order stack_copy;