]> jfr.im git - irc/rqf/shadowircd.git/blame - doc/technical/fd-management.txt
[svn] Apply ratbox flood fix.
[irc/rqf/shadowircd.git] / doc / technical / fd-management.txt
CommitLineData
212380e3 1Overview of the filedescriptor subsystem
2Adrian Chadd <adrian@creative.net.au>
3
4$Id: fd-management.txt 6 2005-09-10 01:02:21Z nenolod $
5
6
7Filedescriptor lists
8--------------------
9
10The filedescriptor list is managed through the routines in fdlist.c .
11These include:
12
13fd_open() - tag an FD as "open" and active
14fd_close() - tag an FD as "closed" and close() the filedescriptor
15fd_note() - update the filedescriptor tag
16
17You can get the current list of open filedescriptors through /stats F as
18an oper.
19
20
21
22FD lists
23--------
24
25The FD list support is very alpha. There are a few lists defined:
26
27typedef enum fdlist_t {
28 FDLIST_NONE,
29 FDLIST_SERVICE,
30 FDLIST_SERVER,
31 FDLIST_IDLECLIENT,
32 FDLIST_BUSYCLIENT,
33 FDLIST_MAX
34} fdlist_t;
35
36FDLIST_NONE Not on any list (ie close()d)
37FDLIST_SERVICE A service - listen() sockets, resolver, etc
38FDLIST_SERVER Server connections
39FDLIST_IDLECLIENT An idle client
40FDLIST_BUSYCLIENT A busy client
41FDLIST_MAX Used for bounds checking
42
43The idea is that the SERVICE sockets need polling frequently, the SERVER
44sockets also need polling frequently, BUSYCLIENT is for busy clients
45which need frequent polling (eg we're trying to write to them), and
46IDLECLIENT is for clients which we don't need to poll frequently.
47THIS hasn't been decided upon yet.
48
49
50
51File operations
52---------------
53
54The file operations are also wrapped through file_open() and file_close()
55which handle calling fd_open() / fd_close() and tracking the filedescriptors
56correctly. fbopen() / fbclose() use file_open() / file_close() too.
57
58fileio.c defines the functions:
59
60int
61file_open(const char *filename, int mode, int fmode)
62
63A wrapper around open(filename, flags, mode). Read the open manpage for
64information. file_open() enforces filedescriptor limits and tags the FD
65through fd_open().
66
67void
68file_close(int fd)
69
70A wrapper around close() for files. close() handles fd_close()ing the fd.
71
72
73FBFILE *
74fbopen(const char *filename, const char *mode)
75
76void
77fbclose(FBFILE *fb)
78
79These are the 'buffered disk IO' routines. You can read the code yourself.
80Note that these routines use file_open() and file_close().
81