ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/fdlist.h
Revision: 33
Committed: Sun Oct 2 20:50:00 2005 UTC (19 years, 10 months ago) by knight
Content type: text/x-chdr
Original Path: ircd-hybrid/include/fdlist.h
File size: 3286 byte(s)
Log Message:
- svn:keywords

File Contents

# User Rev Content
1 adx 30 /*
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 knight 31 * $Id$
23 adx 30 */
24    
25     #ifndef INCLUDED_fdlist_h
26     #define INCLUDED_fdlist_h
27     #define FILEIO_V2
28    
29     #include "ircd_defs.h"
30     #define FD_DESC_SZ 128 /* hostlen + comment */
31    
32     enum {
33     COMM_OK,
34     COMM_ERR_BIND,
35     COMM_ERR_DNS,
36     COMM_ERR_TIMEOUT,
37     COMM_ERR_CONNECT,
38     COMM_ERROR,
39     COMM_ERR_MAX
40     };
41    
42     struct _fde;
43     struct Client;
44     struct DNSQuery;
45    
46     /* Callback for completed IO events */
47     typedef void PF(struct _fde *, void *);
48    
49     /* Callback for completed connections */
50     /* int fd, int status, void * */
51     typedef void CNCB(struct _fde *, int, void *);
52    
53     typedef struct _fde {
54     /* New-school stuff, again pretty much ripped from squid */
55     /*
56     * Yes, this gives us only one pending read and one pending write per
57     * filedescriptor. Think though: when do you think we'll need more?
58     */
59     int fd; /* So we can use the fde_t as a callback ptr */
60     int comm_index; /* where in the poll list we live */
61     int evcache; /* current fd events as set up by the underlying I/O */
62     char desc[FD_DESC_SZ];
63     PF *read_handler;
64     void *read_data;
65     PF *write_handler;
66     void *write_data;
67     PF *timeout_handler;
68     void *timeout_data;
69     time_t timeout;
70     PF *flush_handler;
71     void *flush_data;
72     time_t flush_timeout;
73     struct DNSQuery *dns_query;
74     struct {
75     unsigned int open:1;
76     unsigned int is_socket:1;
77     #ifdef HAVE_LIBCRYPTO
78     unsigned int pending_read:1;
79     #endif
80     } flags;
81    
82     struct {
83     /* We don't need the host here ? */
84     struct irc_ssaddr S;
85     struct irc_ssaddr hostaddr;
86     CNCB *callback;
87     void *data;
88     /* We'd also add the retry count here when we get to that -- adrian */
89     } connect;
90     #ifdef HAVE_LIBCRYPTO
91     SSL *ssl;
92     #endif
93     struct _fde *hnext;
94     } fde_t;
95    
96     #define FD_HASH_SIZE CLIENT_HEAP_SIZE
97    
98     extern int number_fd;
99     extern int hard_fdlimit;
100     extern fde_t *fd_hash[];
101     extern fde_t *fd_next_in_loop;
102     extern struct Callback *fdlimit_cb;
103    
104     extern void fdlist_init(void);
105     extern fde_t *lookup_fd(int);
106     extern void fd_open(fde_t *, int, int, const char *);
107     extern void fd_close(fde_t *);
108     extern void fd_dump(struct Client *);
109     #ifndef __GNUC__
110     extern void fd_note(fde_t *, const char *format, ...);
111     #else
112     extern void fd_note(fde_t *, const char *format, ...)
113     __attribute__((format (printf, 2, 3)));
114     #endif
115     extern void close_standard_fds(void);
116     extern void close_fds(fde_t *);
117     extern void recalc_fdlimit(void *);
118    
119     #endif /* INCLUDED_fdlist_h */

Properties

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