ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/include/fdlist.h
Revision: 2881
Committed: Mon Jan 20 17:15:39 2014 UTC (11 years, 7 months ago) by michael
Content type: text/x-chdr
File size: 2974 byte(s)
Log Message:
- Use the i/o subsystem to execute scheduled writes. Patch provided by Adam.

File Contents

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

Properties

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