annotate src/lib/ioloop-iolist.c @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents cf77e448295c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 /*
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 * Copyright (c) 2004 Andrey Panin <pazke@donpac.ru>
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 *
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 * This software is released under the MIT license.
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5 */
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 #include "lib.h"
13529
cf77e448295c Renamed lib/*-internal.h files to lib/*-private.h for consistency.
Timo Sirainen <tss@iki.fi>
parents: 12314
diff changeset
8 #include "ioloop-private.h"
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 #include "ioloop-iolist.h"
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10
5248
12ac5f685814 Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents: 4573
diff changeset
11 bool ioloop_iolist_add(struct io_list *list, struct io_file *io)
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 int i, idx;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14
5248
12ac5f685814 Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents: 4573
diff changeset
15 if ((io->io.condition & IO_READ) != 0)
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 idx = IOLOOP_IOLIST_INPUT;
5248
12ac5f685814 Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents: 4573
diff changeset
17 else if ((io->io.condition & IO_WRITE) != 0)
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 idx = IOLOOP_IOLIST_OUTPUT;
5248
12ac5f685814 Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents: 4573
diff changeset
19 else if ((io->io.condition & IO_ERROR) != 0)
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 idx = IOLOOP_IOLIST_ERROR;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21 else {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 i_unreached();
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 }
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24
12314
f7f2edaf6dca ioloop: If io_add() is called twice for same fd, give a bit more informative panic message.
Timo Sirainen <tss@iki.fi>
parents: 5248
diff changeset
25 if (list->ios[idx] != NULL) {
f7f2edaf6dca ioloop: If io_add() is called twice for same fd, give a bit more informative panic message.
Timo Sirainen <tss@iki.fi>
parents: 5248
diff changeset
26 i_panic("io_add(0x%x) called twice fd=%d, callback=%p -> %p",
f7f2edaf6dca ioloop: If io_add() is called twice for same fd, give a bit more informative panic message.
Timo Sirainen <tss@iki.fi>
parents: 5248
diff changeset
27 io->io.condition, io->fd, list->ios[idx]->io.callback,
f7f2edaf6dca ioloop: If io_add() is called twice for same fd, give a bit more informative panic message.
Timo Sirainen <tss@iki.fi>
parents: 5248
diff changeset
28 io->io.callback);
f7f2edaf6dca ioloop: If io_add() is called twice for same fd, give a bit more informative panic message.
Timo Sirainen <tss@iki.fi>
parents: 5248
diff changeset
29 }
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
30 i_assert(list->ios[idx] == NULL);
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
31 list->ios[idx] = io;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
32
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
33 /* check if this was the first one */
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 if (i != idx && list->ios[i] != NULL)
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36 return FALSE;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 }
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 return TRUE;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 }
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41
5248
12ac5f685814 Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents: 4573
diff changeset
42 bool ioloop_iolist_del(struct io_list *list, struct io_file *io)
4573
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 bool last = TRUE;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 int i;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 for (i = 0; i < IOLOOP_IOLIST_IOS_PER_FD; i++) {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 if (list->ios[i] != NULL) {
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
49 if (list->ios[i] == io)
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
50 list->ios[i] = NULL;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
51 else
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
52 last = FALSE;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 }
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 }
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 return last;
8d977716f449 Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 }