diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:36:47 +0000 |
commit | 0441d265f2bb9da249c7abf333f0f771fadb4ab5 (patch) | |
tree | 3f3789daa2f6db22da6e55e92bee0062a7d613fe /src/lib/ioloop-notify-fd.c | |
parent | Initial commit. (diff) | |
download | dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.tar.xz dovecot-0441d265f2bb9da249c7abf333f0f771fadb4ab5.zip |
Adding upstream version 1:2.3.21+dfsg1.upstream/1%2.3.21+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/ioloop-notify-fd.c')
-rw-r--r-- | src/lib/ioloop-notify-fd.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/lib/ioloop-notify-fd.c b/src/lib/ioloop-notify-fd.c new file mode 100644 index 0000000..d3ec29b --- /dev/null +++ b/src/lib/ioloop-notify-fd.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "ioloop-private.h" +#include "ioloop-notify-fd.h" + +#if defined(IOLOOP_NOTIFY_INOTIFY) + +struct io *io_notify_fd_add(struct ioloop_notify_fd_context *ctx, int fd, + io_callback_t *callback, void *context) +{ + struct io_notify *io; + + io = i_new(struct io_notify, 1); + io->io.condition = IO_NOTIFY; + io->io.callback = callback; + io->io.context = context; + io->io.ioloop = current_ioloop; + io->fd = fd; + + if (ctx->notifies != NULL) { + ctx->notifies->prev = io; + io->next = ctx->notifies; + } + ctx->notifies = io; + return &io->io; +} + +void io_notify_fd_free(struct ioloop_notify_fd_context *ctx, + struct io_notify *io) +{ + if (io->prev != NULL) + io->prev->next = io->next; + else + ctx->notifies = io->next; + + if (io->next != NULL) + io->next->prev = io->prev; + i_free(io); +} + +struct io_notify * +io_notify_fd_find(struct ioloop_notify_fd_context *ctx, int fd) +{ + struct io_notify *io; + + for (io = ctx->notifies; io != NULL; io = io->next) { + if (io->fd == fd) + return io; + } + + return NULL; +} + +#endif |