ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/libio/comm/fdlist.h
Revision: 724
Committed: Sun Jul 16 21:48:50 2006 UTC (17 years, 9 months ago) by adx
Content type: text/x-chdr
File size: 3550 byte(s)
Log Message:
+ began implementing hashtable confs (ACB)

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 * fdlist.h: The file descriptor list header.
4 *
5 * Copyright (C) 2002 by the past and present ircd coders, and others.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 *
22 * $Id$
23 */
24
25 #define FILEIO_V2
26
27 #define FD_DESC_SZ 128 /* hostlen + comment */
28 #define LOWEST_SAFE_FD 4 /* skip stdin, stdout, stderr, and profiler */
29
30 enum {
31 COMM_OK,
32 COMM_ERR_BIND,
33 COMM_ERR_DNS,
34 COMM_ERR_TIMEOUT,
35 COMM_ERR_CONNECT,
36 COMM_ERROR,
37 COMM_ERR_MAX
38 };
39
40 struct _fde;
41 struct DNSQuery;
42
43 /* Callback for completed IO events */
44 typedef void PF(struct _fde *, void *);
45
46 /* Callback for completed connections */
47 typedef void CNCB(struct _fde *, int, void *);
48
49 /* This is to get around the fact that some implementations have ss_len and
50 * others do not
51 */
52 struct irc_ssaddr
53 {
54 union {
55 struct sockaddr_in ss;
56 #ifdef IPV6
57 struct sockaddr_in6 ss6;
58 #endif
59 };
60 unsigned char ss_len;
61 in_port_t ss_port;
62 };
63
64 typedef struct _fde {
65 /* New-school stuff, again pretty much ripped from squid */
66 /*
67 * Yes, this gives us only one pending read and one pending write per
68 * filedescriptor. Think though: when do you think we'll need more?
69 */
70 int fd; /* So we can use the fde_t as a callback ptr */
71 int comm_index; /* where in the poll list we live */
72 int evcache; /* current fd events as set up by the underlying I/O */
73 char desc[FD_DESC_SZ];
74 PF *read_handler;
75 void *read_data;
76 PF *write_handler;
77 void *write_data;
78 PF *timeout_handler;
79 void *timeout_data;
80 time_t timeout;
81 PF *flush_handler;
82 void *flush_data;
83 time_t flush_timeout;
84 struct DNSQuery *dns_query;
85 struct {
86 unsigned int open:1;
87 unsigned int is_socket:1;
88 #ifdef HAVE_LIBCRYPTO
89 unsigned int pending_read:1;
90 #endif
91 } flags;
92
93 struct {
94 /* We don't need the host here ? */
95 struct irc_ssaddr S;
96 struct irc_ssaddr hostaddr;
97 CNCB *callback;
98 void *data;
99 /* We'd also add the retry count here when we get to that -- adrian */
100 } connect;
101 #ifdef HAVE_LIBCRYPTO
102 SSL *ssl;
103 #endif
104 struct _fde *hnext;
105 } fde_t;
106
107 #define FD_HASH_SIZE CLIENT_HEAP_SIZE
108
109 LIBIO_EXTERN int number_fd;
110 LIBIO_EXTERN int hard_fdlimit;
111 LIBIO_EXTERN fde_t *fd_hash[];
112 LIBIO_EXTERN fde_t *fd_next_in_loop;
113 LIBIO_EXTERN struct Callback *fdlimit_cb;
114
115 #ifdef IN_MISC_C
116 extern void fdlist_init(void);
117 #endif
118 LIBIO_EXTERN fde_t *lookup_fd(int);
119 LIBIO_EXTERN void fd_open(fde_t *, int, int, const char *);
120 LIBIO_EXTERN void fd_close(fde_t *);
121 #ifndef __GNUC__
122 LIBIO_EXTERN void fd_note(fde_t *, const char *format, ...);
123 #else
124 LIBIO_EXTERN void fd_note(fde_t *, const char *format, ...)
125 __attribute__((format (printf, 2, 3)));
126 #endif
127 #ifdef IN_MISC_C
128 extern void close_standard_fds(void);
129 #endif
130 LIBIO_EXTERN void close_fds(fde_t *);
131 LIBIO_EXTERN void recalc_fdlimit(void *);

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision