Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/ioloop-notify-fd.c @ 8590:b9faf4db2a9f HEAD
Updated copyright notices to include year 2009.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 06 Jan 2009 09:25:38 -0500 |
parents | 2c111b572eee |
children | 00cd9aacd03c |
rev | line source |
---|---|
8590
b9faf4db2a9f
Updated copyright notices to include year 2009.
Timo Sirainen <tss@iki.fi>
parents:
8366
diff
changeset
|
1 /* Copyright (c) 2007-2009 Dovecot authors, see the included COPYING file */ |
5248 | 2 |
3 #include "lib.h" | |
4 #include "ioloop-internal.h" | |
5 #include "ioloop-notify-fd.h" | |
6 | |
7 #if defined(IOLOOP_NOTIFY_DNOTIFY) || defined(IOLOOP_NOTIFY_INOTIFY) | |
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 |