aboutsummaryrefslogtreecommitdiff
path: root/seatd/poller.c
diff options
context:
space:
mode:
authorKenny Levinsen <kl@kl.wtf>2020-08-03 01:21:51 +0200
committerKenny Levinsen <kl@kl.wtf>2020-08-03 02:13:22 +0200
commitd68c5feaee9b294d071c0825f5600e316c728708 (patch)
tree2b87b3f722997112943d89d647291d0ffbe04a96 /seatd/poller.c
parent3f3bdd41dd774b65a6ee0ad63bf28a6e22e8908d (diff)
poller: Inline the poller into the server struct
Diffstat (limited to 'seatd/poller.c')
-rw-r--r--seatd/poller.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/seatd/poller.c b/seatd/poller.c
index 43a57b4..f786d47 100644
--- a/seatd/poller.c
+++ b/seatd/poller.c
@@ -10,28 +10,20 @@
#include "list.h"
#include "poller.h"
+/* Used for signal handling */
struct poller *global_poller = NULL;
-struct poller *poller_create(void) {
- if (global_poller != NULL) {
- errno = EEXIST;
- return NULL;
- }
+void poller_init(struct poller *poller) {
+ assert(global_poller == NULL);
- struct poller *poller = calloc(1, sizeof(struct poller));
- if (poller == NULL) {
- errno = ENOMEM;
- return NULL;
- }
list_init(&poller->fds);
list_init(&poller->new_fds);
list_init(&poller->signals);
list_init(&poller->new_signals);
global_poller = poller;
- return poller;
}
-int poller_destroy(struct poller *poller) {
+int poller_finish(struct poller *poller) {
for (size_t idx = 0; idx < poller->fds.length; idx++) {
struct event_source_fd *bpfd = poller->fds.items[idx];
free(bpfd);