Mercurial > dovecot > core-2.2
annotate src/lib/ioloop-notify-fd.c @ 23007:36e01285b5b8
lib: buffer - Improve header comment for buffer_insert() and buffer_delete().
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Mon, 18 Mar 2019 00:52:37 +0100 |
parents | cb108f786fb4 |
children |
rev | line source |
---|---|
22713
cb108f786fb4
Updated copyright notices to include the year 2018.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
1 /* Copyright (c) 2007-2018 Dovecot authors, see the included COPYING file */ |
5248 | 2 |
3 #include "lib.h" | |
13529
cf77e448295c
Renamed lib/*-internal.h files to lib/*-private.h for consistency.
Timo Sirainen <tss@iki.fi>
parents:
12782
diff
changeset
|
4 #include "ioloop-private.h" |
5248 | 5 #include "ioloop-notify-fd.h" |
6 | |
18980 | 7 #if defined(IOLOOP_NOTIFY_INOTIFY) |
5248 | 8 |
9 struct io *io_notify_fd_add(struct ioloop_notify_fd_context *ctx, int fd, | |
10 io_callback_t *callback, void *context) | |
11 { | |
12 struct io_notify *io; | |
13 | |
14 io = i_new(struct io_notify, 1); | |
15 io->io.condition = IO_NOTIFY; | |
16 io->io.callback = callback; | |
17 io->io.context = context; | |
8366
2c111b572eee
Don't break if io_remove() or timeout_remove() are called for non-active ioloops.
Timo Sirainen <tss@iki.fi>
parents:
7086
diff
changeset
|
18 io->io.ioloop = current_ioloop; |
5248 | 19 io->fd = fd; |
20 | |
21 if (ctx->notifies != NULL) { | |
22 ctx->notifies->prev = io; | |
23 io->next = ctx->notifies; | |
24 } | |
25 ctx->notifies = io; | |
26 return &io->io; | |
27 } | |
28 | |
29 void io_notify_fd_free(struct ioloop_notify_fd_context *ctx, | |
30 struct io_notify *io) | |
31 { | |
32 if (io->prev != NULL) | |
33 io->prev->next = io->next; | |
34 else | |
35 ctx->notifies = io->next; | |
36 | |
37 if (io->next != NULL) | |
38 io->next->prev = io->prev; | |
39 i_free(io); | |
40 } | |
41 | |
42 struct io_notify * | |
43 io_notify_fd_find(struct ioloop_notify_fd_context *ctx, int fd) | |
44 { | |
45 struct io_notify *io; | |
46 | |
47 for (io = ctx->notifies; io != NULL; io = io->next) { | |
48 if (io->fd == fd) | |
49 return io; | |
50 } | |
51 | |
52 return NULL; | |
53 } | |
54 | |
55 #endif |