~ubuntu-branches/ubuntu/trusty/haproxy/trusty-updates

« back to all changes in this revision

Viewing changes to include/types/fd.h

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Cornet
  • Date: 2010-04-15 20:00:34 UTC
  • mfrom: (1.2.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20100415200034-mtlky4sy39tk0dfi
Tags: upstream-1.4.4
ImportĀ upstreamĀ versionĀ 1.4.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  include/types/fd.h
3
 
  File descriptors states.
4
 
 
5
 
  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
6
 
 
7
 
  This library is free software; you can redistribute it and/or
8
 
  modify it under the terms of the GNU Lesser General Public
9
 
  License as published by the Free Software Foundation, version 2.1
10
 
  exclusively.
11
 
 
12
 
  This library 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 GNU
15
 
  Lesser General Public License for more details.
16
 
 
17
 
  You should have received a copy of the GNU Lesser General Public
18
 
  License along with this library; if not, write to the Free Software
19
 
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
20
 
*/
 
2
 * include/types/fd.h
 
3
 * File descriptors states.
 
4
 *
 
5
 * Copyright (C) 2000-2009 Willy Tarreau - w@1wt.eu
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation, version 2.1
 
10
 * exclusively.
 
11
 *
 
12
 * This library 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 GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
20
 */
21
21
 
22
22
#ifndef _TYPES_FD_H
23
23
#define _TYPES_FD_H
29
29
 
30
30
#include <common/config.h>
31
31
#include <types/task.h>
32
 
#include <types/buffers.h>
33
32
#include <types/protocols.h>
34
33
 
35
34
/* different possible states for the fd */
59
58
#define FD_POLL_DATA    (FD_POLL_IN  | FD_POLL_OUT)
60
59
#define FD_POLL_STICKY  (FD_POLL_ERR | FD_POLL_HUP)
61
60
 
 
61
/* bit values for fdtab[fd]->flags. Most of them are used to hold a value
 
62
 * consecutive to a behaviour change.
 
63
 */
 
64
#define FD_FL_TCP               0x0001       /* socket is TCP */
 
65
#define FD_FL_TCP_NODELAY       0x0002
 
66
#define FD_FL_TCP_NOLING        0x0004       /* lingering disabled */
 
67
 
62
68
/* info about one given fd */
63
69
struct fdtab {
64
70
        struct {
66
72
                struct buffer *b;            /* read/write buffer */
67
73
        } cb[DIR_SIZE];
68
74
        void *owner;                         /* the session (or proxy) associated with this fd */
 
75
        struct {                             /* used by pollers which support speculative polling */
 
76
                unsigned char e;             /* read and write events status. 4 bits, may be merged into flags' lower bits */
 
77
                unsigned int s1;             /* Position in spec list+1. 0=not in list. */
 
78
        } spec;
 
79
        unsigned short flags;                /* various flags precising the exact status of this fd */
69
80
        unsigned char state;                 /* the state of this fd */
70
81
        unsigned char ev;                    /* event seen in return of poll() : FD_POLL_* */
71
 
        struct sockaddr *peeraddr;           /* pointer to peer's network address, or NULL if unset */
72
 
        socklen_t peerlen;                   /* peer's address length, or 0 if unset */
 
82
};
 
83
 
 
84
/* less often used information */
 
85
struct fdinfo {
 
86
        struct port_range *port_range;       /* optional port range to bind to */
73
87
        int local_port;                      /* optional local port */
74
 
        struct port_range *port_range;       /* optional port range to bind to */
 
88
        struct sockaddr *peeraddr;   /* pointer to peer's network address, or NULL if unset */
 
89
        socklen_t peerlen;           /* peer's address length, or 0 if unset */
75
90
};
76
91
 
77
92
/*
116
131
extern struct poller pollers[MAX_POLLERS];   /* all registered pollers */
117
132
 
118
133
extern struct fdtab *fdtab;             /* array of all the file descriptors */
 
134
extern struct fdinfo *fdinfo;           /* less-often used infos for file descriptors */
119
135
extern int maxfd;                       /* # of the highest fd + 1 */
120
136
extern int totalconn;                   /* total # of terminated sessions */
121
137
extern int actconn;                     /* # of active sessions */