Mercurial > dovecot > original-hg > dovecot-1.2
annotate src/lib/ioloop-internal.h @ 5330:1dcd1631f06e HEAD
If poll()/etc. timeouts, we didn't handle time timeouts immediately but
called poll()/etc again with zero timeout and then handled the timeouts.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 15 Mar 2007 16:38:25 +0200 |
parents | 12ac5f685814 |
children | e4eb71ae8e96 |
rev | line source |
---|---|
0 | 1 #ifndef __IOLOOP_INTERNAL_H |
2 #define __IOLOOP_INTERNAL_H | |
3 | |
4 #include "ioloop.h" | |
5 | |
4573
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
6 #ifndef IOLOOP_INITIAL_FD_COUNT |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
7 # define IOLOOP_INITIAL_FD_COUNT 128 |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
8 #endif |
8d977716f449
Rewrote much of the kqueue code. It didn't work correctly if there were both
Timo Sirainen <tss@iki.fi>
parents:
3959
diff
changeset
|
9 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
10 struct ioloop { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
11 struct ioloop *prev; |
0 | 12 |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
13 struct io_file *io_files; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
14 struct io_file *next_io_file; |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
15 struct timeout *timeouts; /* sorted by next_run */ |
0 | 16 |
3483
84a4f150bd00
data -> context/ctx naming convention replaces
Timo Sirainen <tss@iki.fi>
parents:
3482
diff
changeset
|
17 struct ioloop_handler_context *handler_context; |
3482
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
18 struct ioloop_notify_handler_context *notify_handler_context; |
0 | 19 |
20 unsigned int running:1; | |
21 }; | |
22 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
23 struct io { |
1752 | 24 enum io_condition condition; |
0 | 25 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
26 io_callback_t *callback; |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
27 void *context; |
0 | 28 }; |
29 | |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
30 struct io_file { |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
31 struct io io; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
32 |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
33 /* use a doubly linked list so that io_remove() is quick */ |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
34 struct io_file *prev, *next; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
35 |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
36 int refcount; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
37 int fd; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
38 }; |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
39 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
40 struct timeout { |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
41 struct timeout *next; |
0 | 42 |
43 struct timeval next_run; | |
1499
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1431
diff
changeset
|
44 unsigned int msecs; |
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1431
diff
changeset
|
45 |
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1431
diff
changeset
|
46 unsigned int run_now:1; |
e850252cdc7e
Removed I/O priorities. They were pretty much useless and were just getting
Timo Sirainen <tss@iki.fi>
parents:
1431
diff
changeset
|
47 unsigned int destroyed:1; |
0 | 48 |
1036
f782b3319553
Removed useless parameters from io_callback_t and timeout_callback_t.
Timo Sirainen <tss@iki.fi>
parents:
953
diff
changeset
|
49 timeout_callback_t *callback; |
10
82b7de533f98
s/user_data/context/ and some s/Data/Context/
Timo Sirainen <tss@iki.fi>
parents:
0
diff
changeset
|
50 void *context; |
0 | 51 }; |
52 | |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
53 int io_loop_get_wait_time(struct timeout *timeout, struct timeval *tv, |
0 | 54 struct timeval *tv_now); |
5330
1dcd1631f06e
If poll()/etc. timeouts, we didn't handle time timeouts immediately but
Timo Sirainen <tss@iki.fi>
parents:
5248
diff
changeset
|
55 void io_loop_handle_timeouts(struct ioloop *ioloop, bool update_run_now); |
0 | 56 |
57 /* I/O handler calls */ | |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
58 void io_loop_handle_add(struct ioloop *ioloop, struct io_file *io); |
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
59 void io_loop_handle_remove(struct ioloop *ioloop, struct io_file *io); |
0 | 60 |
903
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
61 void io_loop_handler_init(struct ioloop *ioloop); |
fd8888f6f037
Naming style changes, finally got tired of most of the typedefs. Also the
Timo Sirainen <tss@iki.fi>
parents:
10
diff
changeset
|
62 void io_loop_handler_deinit(struct ioloop *ioloop); |
0 | 63 |
5248
12ac5f685814
Various cleanups to ioloop code.
Timo Sirainen <tss@iki.fi>
parents:
4579
diff
changeset
|
64 void io_loop_notify_remove(struct ioloop *ioloop, struct io *io); |
3482
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
65 void io_loop_notify_handler_deinit(struct ioloop *ioloop); |
465c465c66be
Added inotify patch by Johannes Berg and did some restructuring to
Timo Sirainen <tss@iki.fi>
parents:
2496
diff
changeset
|
66 |
0 | 67 #endif |