summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-06 13:03:55 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-06 13:03:55 +0200
commite2c3fd4f88b095aca492c0df1a278c774b00492d (patch)
tree4a77b341a87b8ef26ed2dca8d62de2f333a25c2c
parent459c4ae387ce3bf02a4ab27c2fc382974f3e1fae (diff)
Reparent most tasks to uring
-rw-r--r--announce.c2
-rw-r--r--cfgdir.c2
-rw-r--r--main.c4
-rw-r--r--server.c2
-rw-r--r--uring.c12
-rw-r--r--uring.h2
6 files changed, 19 insertions, 5 deletions
diff --git a/announce.c b/announce.c
index 9af2236..22dd080 100644
--- a/announce.c
+++ b/announce.c
@@ -176,7 +176,7 @@ announce_init(struct cfg *cfg)
if (sfd < 0)
perrordie("socket");
- uring_task_init(&aev->task, "aev", &cfg->task, announce_free);
+ uring_task_init(&aev->task, "aev", uring_parent(cfg), announce_free);
uring_task_set_fd(&aev->task, afd);
uring_task_init(&aev->mcast_task, "aev_mcast", &aev->task, mcast_free);
diff --git a/cfgdir.c b/cfgdir.c
index 443ec5e..c2870ab 100644
--- a/cfgdir.c
+++ b/cfgdir.c
@@ -347,7 +347,7 @@ cfgdir_init(struct cfg *cfg)
if (iwd < 0)
perrordie("inotify_add_watch");
- uring_task_init(&iev->task, "iev", &cfg->task, inotify_free);
+ uring_task_init(&iev->task, "iev", uring_parent(cfg), inotify_free);
uring_task_set_fd(&iev->task, ifd);
cfg->iev = iev;
uring_read(cfg, &iev->task, iev->buf, sizeof(iev->buf), 0, inotify_cb);
diff --git a/main.c b/main.c
index 69d47ae..1fc0e5d 100644
--- a/main.c
+++ b/main.c
@@ -155,9 +155,9 @@ dump_tree(struct cfg *cfg)
fprintf(stderr, "Dumping Tree\n");
fprintf(stderr, "============\n");
uring_task_refdump(&cfg->task);
+ uring_refdump(cfg->uev);
uring_task_refdump(&cfg->sev->task);
announce_refdump(cfg->aev);
- uring_refdump(cfg->uev);
if (cfg->iev)
cfgdir_refdump(cfg->iev);
list_for_each_entry(server, &cfg->servers, list)
@@ -261,7 +261,7 @@ signalfd_init(struct cfg *cfg)
perrordie("eventfd");
fprintf(stderr, "signalfd init: %i\n", sfd);
- uring_task_init(&sev->task, "sev", &cfg->task, signalfd_free);
+ uring_task_init(&sev->task, "sev", uring_parent(cfg), signalfd_free);
uring_task_set_fd(&sev->task, sfd);
cfg->sev = sev;
hack_efd = sfd;
diff --git a/server.c b/server.c
index 25cfad7..739fecf 100644
--- a/server.c
+++ b/server.c
@@ -373,7 +373,7 @@ server_new(struct cfg *cfg, const char *name)
scfg->type = SERVER_TYPE_UNDEFINED;
scfg->name = strdup(name);
scfg->running = false;
- uring_task_init(&scfg->task, "scfg", &cfg->task, server_free);
+ uring_task_init(&scfg->task, "scfg", uring_parent(cfg), server_free);
list_init(&scfg->remotes);
list_init(&scfg->locals);
list_init(&scfg->proxys);
diff --git a/uring.c b/uring.c
index 65277ce..3f089c8 100644
--- a/uring.c
+++ b/uring.c
@@ -102,6 +102,18 @@ uring_task_close_fd(struct cfg *cfg, struct uring_task *task)
task->fd = -1;
}
+struct uring_task *
+uring_parent(struct cfg *cfg)
+{
+ if (!cfg)
+ die("%s: called with null cfg\n");
+
+ if (!cfg->uev)
+ die("%s: called with uninitialized uring\n");
+
+ return &cfg->uev->task;
+}
+
void
uring_task_init(struct uring_task *task, const char *name, struct uring_task *parent, void (*free)(struct uring_task *))
{
diff --git a/uring.h b/uring.h
index fdabf68..cd13cd4 100644
--- a/uring.h
+++ b/uring.h
@@ -11,6 +11,8 @@ void uring_task_set_fd(struct uring_task *task, int fd);
void uring_task_close_fd(struct cfg *cfg, struct uring_task *task);
+struct uring_task *uring_parent(struct cfg *cfg);
+
void uring_task_init(struct uring_task *task, const char *name,
struct uring_task *parent,
void (*free)(struct uring_task *));