/src/haproxy/include/haproxy/stream-t.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * include/haproxy/stream-t.h |
3 | | * This file defines everything related to streams. |
4 | | * |
5 | | * Copyright (C) 2000-2020 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 | | |
22 | | #ifndef _HAPROXY_STREAM_T_H |
23 | | #define _HAPROXY_STREAM_T_H |
24 | | |
25 | | #include <sys/time.h> |
26 | | |
27 | | #include <haproxy/api-t.h> |
28 | | #include <haproxy/channel-t.h> |
29 | | #include <haproxy/stconn-t.h> |
30 | | #include <haproxy/dynbuf-t.h> |
31 | | #include <haproxy/filters-t.h> |
32 | | #include <haproxy/obj_type-t.h> |
33 | | #include <haproxy/log-t.h> |
34 | | #include <haproxy/show_flags-t.h> |
35 | | #include <haproxy/stick_table-t.h> |
36 | | #include <haproxy/vars-t.h> |
37 | | |
38 | | |
39 | | /* Various Stream Flags, bits values 0x01 to 0x100 (shift 0). |
40 | | * Please also update the txn_show_flags() function below in case of changes. |
41 | | */ |
42 | 0 | #define SF_DIRECT 0x00000001 /* connection made on the server matching the client cookie */ |
43 | 0 | #define SF_ASSIGNED 0x00000002 /* no need to assign a server to this stream */ |
44 | 0 | #define SF_MAYALLOC 0x00000004 /* we were notified that a work buffer might be available now */ |
45 | 0 | #define SF_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */ |
46 | | |
47 | 0 | #define SF_FORCE_PRST 0x00000010 /* force persistence here, even if server is down */ |
48 | 0 | #define SF_MONITOR 0x00000020 /* this stream comes from a monitoring system */ |
49 | 0 | #define SF_CURR_SESS 0x00000040 /* a connection is currently being counted on the server */ |
50 | 0 | #define SF_CONN_EXP 0x00000080 /* timeout has expired */ |
51 | 0 | #define SF_REDISP 0x00000100 /* set if this stream was redispatched from one server to another */ |
52 | 0 | #define SF_IGNORE 0x00000200 /* The stream lead to a mux upgrade, and should be ignored */ |
53 | 0 | #define SF_REDIRECTABLE 0x00000400 /* set if this stream is redirectable (GET or HEAD) */ |
54 | 0 | #define SF_HTX 0x00000800 /* set if this stream is an htx stream */ |
55 | | |
56 | | /* stream termination conditions, bits values 0x1000 to 0x7000 (0-9 shift 12) */ |
57 | 0 | #define SF_ERR_NONE 0x00000000 /* normal end of request */ |
58 | 0 | #define SF_ERR_LOCAL 0x00001000 /* the proxy locally processed this request => not an error */ |
59 | 0 | #define SF_ERR_CLITO 0x00002000 /* client time-out */ |
60 | 0 | #define SF_ERR_CLICL 0x00003000 /* client closed (read/write error) */ |
61 | 0 | #define SF_ERR_SRVTO 0x00004000 /* server time-out, connect time-out */ |
62 | 0 | #define SF_ERR_SRVCL 0x00005000 /* server closed (connect/read/write error) */ |
63 | 0 | #define SF_ERR_PRXCOND 0x00006000 /* the proxy decided to close (deny...) */ |
64 | 0 | #define SF_ERR_RESOURCE 0x00007000 /* the proxy encountered a lack of a local resources (fd, mem, ...) */ |
65 | 0 | #define SF_ERR_INTERNAL 0x00008000 /* the proxy encountered an internal error */ |
66 | 0 | #define SF_ERR_DOWN 0x00009000 /* the proxy killed a stream because the backend became unavailable */ |
67 | 0 | #define SF_ERR_KILLED 0x0000a000 /* the proxy killed a stream because it was asked to do so */ |
68 | 0 | #define SF_ERR_UP 0x0000b000 /* the proxy killed a stream because a preferred backend became available */ |
69 | | #define SF_ERR_CHK_PORT 0x0000c000 /* no port could be found for a health check. TODO: check SF_ERR_SHIFT */ |
70 | 0 | #define SF_ERR_MASK 0x0000f000 /* mask to get only stream error flags */ |
71 | 0 | #define SF_ERR_SHIFT 12 /* bit shift */ |
72 | | |
73 | | /* stream state at termination, bits values 0x10000 to 0x70000 (0-7 shift 16) */ |
74 | 0 | #define SF_FINST_R 0x00010000 /* stream ended during client request */ |
75 | 0 | #define SF_FINST_C 0x00020000 /* stream ended during server connect */ |
76 | 0 | #define SF_FINST_H 0x00030000 /* stream ended during server headers */ |
77 | 0 | #define SF_FINST_D 0x00040000 /* stream ended during data phase */ |
78 | 0 | #define SF_FINST_L 0x00050000 /* stream ended while pushing last data to client */ |
79 | 0 | #define SF_FINST_Q 0x00060000 /* stream ended while waiting in queue for a server slot */ |
80 | 0 | #define SF_FINST_T 0x00070000 /* stream ended tarpitted */ |
81 | 0 | #define SF_FINST_MASK 0x00070000 /* mask to get only final stream state flags */ |
82 | 0 | #define SF_FINST_SHIFT 16 /* bit shift */ |
83 | | |
84 | 0 | #define SF_IGNORE_PRST 0x00080000 /* ignore persistence */ |
85 | | |
86 | 0 | #define SF_SRV_REUSED 0x00100000 /* the server-side connection was reused */ |
87 | 0 | #define SF_SRV_REUSED_ANTICIPATED 0x00200000 /* the connection was reused but the mux is not ready yet */ |
88 | 0 | #define SF_WEBSOCKET 0x00400000 /* websocket stream */ // TODO: must be removed |
89 | 0 | #define SF_SRC_ADDR 0x00800000 /* get the source ip/port with getsockname */ |
90 | 0 | #define SF_BC_MARK 0x01000000 /* need to set specific mark on backend/srv conn upon connect */ |
91 | 0 | #define SF_BC_TOS 0x02000000 /* need to set specific tos on backend/srv conn upon connect */ |
92 | 0 | #define SF_RULE_FYIELD 0x04000000 /* s->current_rule set because of forced yield */ |
93 | | |
94 | | /* This function is used to report flags in debugging tools. Please reflect |
95 | | * below any single-bit flag addition above in the same order via the |
96 | | * __APPEND_FLAG and __APPEND_ENUM macros. The new end of the buffer is |
97 | | * returned. |
98 | | */ |
99 | | static forceinline char *strm_show_flags(char *buf, size_t len, const char *delim, uint flg) |
100 | 0 | { |
101 | 0 | #define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) |
102 | 0 | #define _e(m, e, ...) __APPEND_ENUM(buf, len, delim, flg, m, e, #e, __VA_ARGS__) |
103 | 0 | /* prologue */ |
104 | 0 | _(0); |
105 | 0 | /* flags & enums */ |
106 | 0 | _(SF_IGNORE_PRST, _(SF_SRV_REUSED, _(SF_SRV_REUSED_ANTICIPATED, |
107 | 0 | _(SF_WEBSOCKET, _(SF_SRC_ADDR, _(SF_BC_MARK, _(SF_BC_TOS, |
108 | 0 | _(SF_RULE_FYIELD)))))))); |
109 | 0 |
|
110 | 0 | _e(SF_FINST_MASK, SF_FINST_R, _e(SF_FINST_MASK, SF_FINST_C, |
111 | 0 | _e(SF_FINST_MASK, SF_FINST_H, _e(SF_FINST_MASK, SF_FINST_D, |
112 | 0 | _e(SF_FINST_MASK, SF_FINST_L, _e(SF_FINST_MASK, SF_FINST_Q, |
113 | 0 | _e(SF_FINST_MASK, SF_FINST_T))))))); |
114 | 0 |
|
115 | 0 | _e(SF_ERR_MASK, SF_ERR_LOCAL, _e(SF_ERR_MASK, SF_ERR_CLITO, |
116 | 0 | _e(SF_ERR_MASK, SF_ERR_CLICL, _e(SF_ERR_MASK, SF_ERR_SRVTO, |
117 | 0 | _e(SF_ERR_MASK, SF_ERR_SRVCL, _e(SF_ERR_MASK, SF_ERR_PRXCOND, |
118 | 0 | _e(SF_ERR_MASK, SF_ERR_RESOURCE, _e(SF_ERR_MASK, SF_ERR_INTERNAL, |
119 | 0 | _e(SF_ERR_MASK, SF_ERR_DOWN, _e(SF_ERR_MASK, SF_ERR_KILLED, |
120 | 0 | _e(SF_ERR_MASK, SF_ERR_UP, _e(SF_ERR_MASK, SF_ERR_CHK_PORT)))))))))))); |
121 | 0 |
|
122 | 0 | _(SF_DIRECT, _(SF_ASSIGNED, _(SF_MAYALLOC, _(SF_BE_ASSIGNED, _(SF_FORCE_PRST, |
123 | 0 | _(SF_MONITOR, _(SF_CURR_SESS, _(SF_CONN_EXP, _(SF_REDISP, |
124 | 0 | _(SF_IGNORE, _(SF_REDIRECTABLE, _(SF_HTX)))))))))))); |
125 | 0 |
|
126 | 0 | /* epilogue */ |
127 | 0 | _(~0U); |
128 | 0 | return buf; |
129 | 0 | #undef _e |
130 | 0 | #undef _ |
131 | 0 | } Unexecuted instantiation: cfgparse.c:strm_show_flags Unexecuted instantiation: cli.c:strm_show_flags Unexecuted instantiation: connection.c:strm_show_flags Unexecuted instantiation: debug.c:strm_show_flags Unexecuted instantiation: errors.c:strm_show_flags Unexecuted instantiation: fd.c:strm_show_flags Unexecuted instantiation: filters.c:strm_show_flags Unexecuted instantiation: flt_http_comp.c:strm_show_flags Unexecuted instantiation: frontend.c:strm_show_flags Unexecuted instantiation: haproxy.c:strm_show_flags Unexecuted instantiation: http_ana.c:strm_show_flags Unexecuted instantiation: http_ext.c:strm_show_flags Unexecuted instantiation: http_htx.c:strm_show_flags Unexecuted instantiation: http_rules.c:strm_show_flags Unexecuted instantiation: lb_chash.c:strm_show_flags Unexecuted instantiation: lb_fas.c:strm_show_flags Unexecuted instantiation: lb_fwlc.c:strm_show_flags Unexecuted instantiation: lb_fwrr.c:strm_show_flags Unexecuted instantiation: lb_map.c:strm_show_flags Unexecuted instantiation: lb_ss.c:strm_show_flags Unexecuted instantiation: limits.c:strm_show_flags Unexecuted instantiation: listener.c:strm_show_flags Unexecuted instantiation: log.c:strm_show_flags Unexecuted instantiation: mworker.c:strm_show_flags Unexecuted instantiation: peers.c:strm_show_flags Unexecuted instantiation: pool.c:strm_show_flags Unexecuted instantiation: proto_rhttp.c:strm_show_flags Unexecuted instantiation: proto_sockpair.c:strm_show_flags Unexecuted instantiation: proxy.c:strm_show_flags Unexecuted instantiation: queue.c:strm_show_flags Unexecuted instantiation: resolvers.c:strm_show_flags Unexecuted instantiation: ring.c:strm_show_flags Unexecuted instantiation: sample.c:strm_show_flags Unexecuted instantiation: server.c:strm_show_flags Unexecuted instantiation: session.c:strm_show_flags Unexecuted instantiation: sink.c:strm_show_flags Unexecuted instantiation: sock.c:strm_show_flags Unexecuted instantiation: stats-html.c:strm_show_flags Unexecuted instantiation: stats.c:strm_show_flags Unexecuted instantiation: stconn.c:strm_show_flags Unexecuted instantiation: stick_table.c:strm_show_flags Unexecuted instantiation: stream.c:strm_show_flags Unexecuted instantiation: tcp_rules.c:strm_show_flags Unexecuted instantiation: tcpcheck.c:strm_show_flags Unexecuted instantiation: thread.c:strm_show_flags Unexecuted instantiation: tools.c:strm_show_flags Unexecuted instantiation: trace.c:strm_show_flags Unexecuted instantiation: vars.c:strm_show_flags Unexecuted instantiation: action.c:strm_show_flags Unexecuted instantiation: activity.c:strm_show_flags Unexecuted instantiation: applet.c:strm_show_flags Unexecuted instantiation: backend.c:strm_show_flags Unexecuted instantiation: cache.c:strm_show_flags Unexecuted instantiation: cfgparse-global.c:strm_show_flags Unexecuted instantiation: cfgparse-listen.c:strm_show_flags Unexecuted instantiation: channel.c:strm_show_flags Unexecuted instantiation: check.c:strm_show_flags Unexecuted instantiation: compression.c:strm_show_flags Unexecuted instantiation: dns.c:strm_show_flags Unexecuted instantiation: dns_ring.c:strm_show_flags Unexecuted instantiation: extcheck.c:strm_show_flags Unexecuted instantiation: fcgi-app.c:strm_show_flags Unexecuted instantiation: guid.c:strm_show_flags Unexecuted instantiation: http_fetch.c:strm_show_flags Unexecuted instantiation: mux_spop.c:strm_show_flags Unexecuted instantiation: pattern.c:strm_show_flags Unexecuted instantiation: payload.c:strm_show_flags Unexecuted instantiation: proto_tcp.c:strm_show_flags Unexecuted instantiation: stats-file.c:strm_show_flags Unexecuted instantiation: stats-json.c:strm_show_flags Unexecuted instantiation: stats-proxy.c:strm_show_flags Unexecuted instantiation: flt_spoe.c:strm_show_flags |
132 | | |
133 | | |
134 | | /* flags for the proxy of the master CLI */ |
135 | | /* 0x0001.. to 0x4000 are reserved for ACCESS_* flags from cli-t.h */ |
136 | | |
137 | 0 | #define PCLI_F_BIDIR 0x08000 /* communicate with worker in bidirectional mode (forward till close) */ |
138 | 0 | #define PCLI_F_PROMPT 0x10000 |
139 | 0 | #define PCLI_F_PAYLOAD 0x20000 |
140 | 0 | #define PCLI_F_RELOAD 0x40000 /* this is the "reload" stream, quits after displaying reload status */ |
141 | 0 | #define PCLI_F_TIMED 0x80000 /* the prompt shows the process' uptime */ |
142 | | |
143 | | |
144 | | /* error types reported on the streams for more accurate reporting. |
145 | | * Please also update the strm_et_show_flags() function below in case of changes. |
146 | | */ |
147 | | enum { |
148 | | STRM_ET_NONE = 0x0000, /* no error yet, leave it to zero */ |
149 | | STRM_ET_QUEUE_TO = 0x0001, /* queue timeout */ |
150 | | STRM_ET_QUEUE_ERR = 0x0002, /* queue error (eg: full) */ |
151 | | STRM_ET_QUEUE_ABRT = 0x0004, /* aborted in queue by external cause */ |
152 | | STRM_ET_CONN_TO = 0x0008, /* connection timeout */ |
153 | | STRM_ET_CONN_ERR = 0x0010, /* connection error (eg: no server available) */ |
154 | | STRM_ET_CONN_ABRT = 0x0020, /* connection aborted by external cause (eg: abort) */ |
155 | | STRM_ET_CONN_RES = 0x0040, /* connection aborted due to lack of resources */ |
156 | | STRM_ET_CONN_OTHER = 0x0080, /* connection aborted for other reason (eg: 500) */ |
157 | | STRM_ET_DATA_TO = 0x0100, /* timeout during data phase */ |
158 | | STRM_ET_DATA_ERR = 0x0200, /* error during data phase */ |
159 | | STRM_ET_DATA_ABRT = 0x0400, /* data phase aborted by external cause */ |
160 | | }; |
161 | | |
162 | | |
163 | | /* Types of entities that may interrupt a processing, teomporarily or not |
164 | | * depending on the context; |
165 | | */ |
166 | | enum { |
167 | | STRM_ENTITY_NONE = 0x0000, |
168 | | STRM_ENTITY_RULE = 0x0001, |
169 | | STRM_ENTITY_FILTER = 0x0002, |
170 | | STRM_ENTITY_WREQ_BODY = 0x0003, |
171 | | }; |
172 | | |
173 | | /* All possible stream events handled by process_stream(). First ones are mapped |
174 | | * from TASK_WOKEN_*. |
175 | | */ |
176 | | enum { |
177 | | STRM_EVT_NONE = 0x00000000, /* No events */ |
178 | | STRM_EVT_TIMER = 0x00000001, /* A timer has expired */ |
179 | | STRM_EVT_MSG = 0x00000002, /* A message event was triggered */ |
180 | | STRM_EVT_SHUT_SRV_DOWN = 0x00000004, /* Must be shut because the selected server became available */ |
181 | | STRM_EVT_SHUT_SRV_UP = 0x00000008, /* Must be shut because a preferred server became available */ |
182 | | STRM_EVT_KILLED = 0x00000010, /* Must be shut for external reason */ |
183 | | }; |
184 | | |
185 | | /* This function is used to report flags in debugging tools. Please reflect |
186 | | * below any single-bit flag addition above in the same order via the |
187 | | * __APPEND_FLAG macro. The new end of the buffer is returned. |
188 | | */ |
189 | | static forceinline char *strm_et_show_flags(char *buf, size_t len, const char *delim, uint flg) |
190 | 0 | { |
191 | 0 | #define _(f, ...) __APPEND_FLAG(buf, len, delim, flg, f, #f, __VA_ARGS__) |
192 | 0 | /* prologue */ |
193 | 0 | _(0); |
194 | 0 | /* flags */ |
195 | 0 | _(STRM_ET_QUEUE_TO, _(STRM_ET_QUEUE_ERR, _(STRM_ET_QUEUE_ABRT, |
196 | 0 | _(STRM_ET_CONN_TO, _(STRM_ET_CONN_ERR, _(STRM_ET_CONN_ABRT, |
197 | 0 | _(STRM_ET_CONN_RES, _(STRM_ET_CONN_OTHER, _(STRM_ET_DATA_TO, |
198 | 0 | _(STRM_ET_DATA_ERR, _(STRM_ET_DATA_ABRT))))))))))); |
199 | 0 | /* epilogue */ |
200 | 0 | _(~0U); |
201 | 0 | return buf; |
202 | 0 | #undef _ |
203 | 0 | } Unexecuted instantiation: cfgparse.c:strm_et_show_flags Unexecuted instantiation: cli.c:strm_et_show_flags Unexecuted instantiation: connection.c:strm_et_show_flags Unexecuted instantiation: debug.c:strm_et_show_flags Unexecuted instantiation: errors.c:strm_et_show_flags Unexecuted instantiation: fd.c:strm_et_show_flags Unexecuted instantiation: filters.c:strm_et_show_flags Unexecuted instantiation: flt_http_comp.c:strm_et_show_flags Unexecuted instantiation: frontend.c:strm_et_show_flags Unexecuted instantiation: haproxy.c:strm_et_show_flags Unexecuted instantiation: http_ana.c:strm_et_show_flags Unexecuted instantiation: http_ext.c:strm_et_show_flags Unexecuted instantiation: http_htx.c:strm_et_show_flags Unexecuted instantiation: http_rules.c:strm_et_show_flags Unexecuted instantiation: lb_chash.c:strm_et_show_flags Unexecuted instantiation: lb_fas.c:strm_et_show_flags Unexecuted instantiation: lb_fwlc.c:strm_et_show_flags Unexecuted instantiation: lb_fwrr.c:strm_et_show_flags Unexecuted instantiation: lb_map.c:strm_et_show_flags Unexecuted instantiation: lb_ss.c:strm_et_show_flags Unexecuted instantiation: limits.c:strm_et_show_flags Unexecuted instantiation: listener.c:strm_et_show_flags Unexecuted instantiation: log.c:strm_et_show_flags Unexecuted instantiation: mworker.c:strm_et_show_flags Unexecuted instantiation: peers.c:strm_et_show_flags Unexecuted instantiation: pool.c:strm_et_show_flags Unexecuted instantiation: proto_rhttp.c:strm_et_show_flags Unexecuted instantiation: proto_sockpair.c:strm_et_show_flags Unexecuted instantiation: proxy.c:strm_et_show_flags Unexecuted instantiation: queue.c:strm_et_show_flags Unexecuted instantiation: resolvers.c:strm_et_show_flags Unexecuted instantiation: ring.c:strm_et_show_flags Unexecuted instantiation: sample.c:strm_et_show_flags Unexecuted instantiation: server.c:strm_et_show_flags Unexecuted instantiation: session.c:strm_et_show_flags Unexecuted instantiation: sink.c:strm_et_show_flags Unexecuted instantiation: sock.c:strm_et_show_flags Unexecuted instantiation: stats-html.c:strm_et_show_flags Unexecuted instantiation: stats.c:strm_et_show_flags Unexecuted instantiation: stconn.c:strm_et_show_flags Unexecuted instantiation: stick_table.c:strm_et_show_flags Unexecuted instantiation: stream.c:strm_et_show_flags Unexecuted instantiation: tcp_rules.c:strm_et_show_flags Unexecuted instantiation: tcpcheck.c:strm_et_show_flags Unexecuted instantiation: thread.c:strm_et_show_flags Unexecuted instantiation: tools.c:strm_et_show_flags Unexecuted instantiation: trace.c:strm_et_show_flags Unexecuted instantiation: vars.c:strm_et_show_flags Unexecuted instantiation: action.c:strm_et_show_flags Unexecuted instantiation: activity.c:strm_et_show_flags Unexecuted instantiation: applet.c:strm_et_show_flags Unexecuted instantiation: backend.c:strm_et_show_flags Unexecuted instantiation: cache.c:strm_et_show_flags Unexecuted instantiation: cfgparse-global.c:strm_et_show_flags Unexecuted instantiation: cfgparse-listen.c:strm_et_show_flags Unexecuted instantiation: channel.c:strm_et_show_flags Unexecuted instantiation: check.c:strm_et_show_flags Unexecuted instantiation: compression.c:strm_et_show_flags Unexecuted instantiation: dns.c:strm_et_show_flags Unexecuted instantiation: dns_ring.c:strm_et_show_flags Unexecuted instantiation: extcheck.c:strm_et_show_flags Unexecuted instantiation: fcgi-app.c:strm_et_show_flags Unexecuted instantiation: guid.c:strm_et_show_flags Unexecuted instantiation: http_fetch.c:strm_et_show_flags Unexecuted instantiation: mux_spop.c:strm_et_show_flags Unexecuted instantiation: pattern.c:strm_et_show_flags Unexecuted instantiation: payload.c:strm_et_show_flags Unexecuted instantiation: proto_tcp.c:strm_et_show_flags Unexecuted instantiation: stats-file.c:strm_et_show_flags Unexecuted instantiation: stats-json.c:strm_et_show_flags Unexecuted instantiation: stats-proxy.c:strm_et_show_flags Unexecuted instantiation: flt_spoe.c:strm_et_show_flags |
204 | | |
205 | | struct hlua; |
206 | | struct proxy; |
207 | | struct pendconn; |
208 | | struct session; |
209 | | struct server; |
210 | | struct task; |
211 | | struct sockaddr_storage; |
212 | | |
213 | | /* some external definitions */ |
214 | | struct strm_logs { |
215 | | int logwait; /* log fields waiting to be collected : LW_* */ |
216 | | int level; /* log level to force + 1 if > 0, -1 = no log */ |
217 | | struct timeval accept_date; /* date of the stream's accept() in user date */ |
218 | | ullong accept_ts; /* date of the session's accept() in internal date (monotonic) */ |
219 | | long t_handshake; /* handshake duration, -1 if never occurs */ |
220 | | long t_idle; /* idle duration, -1 if never occurs */ |
221 | | ullong request_ts; /* date when the request arrives in internal date */ |
222 | | long t_queue; /* delay before the stream gets out of the connect queue, -1 if never occurs */ |
223 | | long t_connect; /* delay before the connect() to the server succeeds, -1 if never occurs */ |
224 | | long t_data; /* delay before the first data byte from the server ... */ |
225 | | unsigned long t_close; /* total stream duration */ |
226 | | unsigned long srv_queue_pos; /* number of streams de-queued while waiting for a connection slot on this server */ |
227 | | unsigned long prx_queue_pos; /* number of streams de-qeuued while waiting for a connection slot on this instance */ |
228 | | long long bytes_in; /* number of bytes transferred from the client to the server */ |
229 | | long long bytes_out; /* number of bytes transferred from the server to the client */ |
230 | | }; |
231 | | |
232 | | struct stream { |
233 | | enum obj_type obj_type; /* object type == OBJ_TYPE_STREAM */ |
234 | | enum sc_state prev_conn_state; /* CS_ST*, copy of previous state of the server stream connector */ |
235 | | |
236 | | int16_t priority_class; /* priority class of the stream for the pending queue */ |
237 | | int32_t priority_offset; /* priority offset of the stream for the pending queue */ |
238 | | |
239 | | int flags; /* some flags describing the stream */ |
240 | | unsigned int uniq_id; /* unique ID used for the traces */ |
241 | | uint32_t bc_mark; /* set mark on back conn if SF_BC_MARK is set */ |
242 | | uint8_t bc_tos; /* set tos on back conn if SF_BC_TOS is set */ |
243 | | /* 3 unused bytes here */ |
244 | | enum obj_type *target; /* target to use for this stream */ |
245 | | |
246 | | struct session *sess; /* the session this stream is attached to */ |
247 | | |
248 | | struct channel req; /* request channel */ |
249 | | struct channel res; /* response channel */ |
250 | | |
251 | | struct proxy *be; /* the proxy this stream depends on for the server side */ |
252 | | |
253 | | struct server *srv_conn; /* stream already has a slot on a server and is not in queue */ |
254 | | struct pendconn *pend_pos; /* if not NULL, points to the pending position in the pending queue */ |
255 | | |
256 | | struct http_txn *txn; /* current HTTP transaction being processed. Should become a list. */ |
257 | | |
258 | | struct task *task; /* the task associated with this stream */ |
259 | | unsigned int pending_events; /* the pending events not yet processed by the stream but handled by process_stream() */ |
260 | | unsigned int new_events; /* the new events added since the previous wakeup (never seen by process_stream()). It is atomic field */ |
261 | | int conn_retries; /* number of connect retries performed */ |
262 | | unsigned int conn_exp; /* wake up time for connect, queue, turn-around, ... */ |
263 | | unsigned int conn_err_type; /* first error detected, one of STRM_ET_* */ |
264 | | |
265 | | uint32_t rules_bcount; /* number of rules evaluated since last yield */ |
266 | | |
267 | | struct stream *parent; /* Pointer to the parent stream, if any. NULL most of time */ |
268 | | |
269 | | struct list list; /* position in the thread's streams list */ |
270 | | struct mt_list by_srv; /* position in server stream list */ |
271 | | struct list back_refs; /* list of users tracking this stream */ |
272 | | struct buffer_wait buffer_wait; /* position in the list of objects waiting for a buffer */ |
273 | | |
274 | | uint64_t lat_time; /* total latency time experienced */ |
275 | | uint64_t cpu_time; /* total CPU time consumed */ |
276 | | struct freq_ctr call_rate; /* stream task call rate without making progress */ |
277 | | uint32_t passes_stconn; /* number of passes on the stconn evaluation code */ |
278 | | uint32_t passes_reqana; /* number of passes on the req analysers block */ |
279 | | uint32_t passes_resana; /* number of passes on the res analysers block */ |
280 | | uint32_t passes_propag; /* number of passes on the shut/err propag code */ |
281 | | |
282 | | unsigned short max_retries; /* Maximum number of connection retried (=0 is backend is not set) */ |
283 | | short store_count; |
284 | | |
285 | | struct { |
286 | | struct stksess *ts; |
287 | | struct stktable *table; |
288 | | } store[8]; /* tracked stickiness values to store */ |
289 | | |
290 | | struct stkctr *stkctr; /* content-aware stick counters */ |
291 | | |
292 | | struct strm_flt strm_flt; /* current state of filters active on this stream */ |
293 | | |
294 | | char **req_cap; /* array of captures from the request (may be NULL) */ |
295 | | char **res_cap; /* array of captures from the response (may be NULL) */ |
296 | | struct vars vars_txn; /* list of variables for the txn scope. */ |
297 | | struct vars vars_reqres; /* list of variables for the request and resp scope. */ |
298 | | |
299 | | struct stconn *scf; /* frontend stream connector */ |
300 | | struct stconn *scb; /* backend stream connector */ |
301 | | |
302 | | struct strm_logs logs; /* logs for this stream */ |
303 | | |
304 | | void (*do_log)(struct stream *s, /* the function to call in order to log (or NULL) */ |
305 | | struct log_orig origin); |
306 | | void (*srv_error)(struct stream *s, /* the function to call upon unrecoverable server errors (or NULL) */ |
307 | | struct stconn *sc); |
308 | | |
309 | | int pcli_next_pid; /* next target PID to use for the CLI proxy */ |
310 | | int pcli_flags; /* flags for CLI proxy */ |
311 | | char pcli_payload_pat[8]; /* payload pattern for the CLI proxy */ |
312 | | |
313 | | struct ist unique_id; /* custom unique ID */ |
314 | | |
315 | | /* These two pointers are used to resume the execution of the rule lists. */ |
316 | | struct list *current_rule_list; /* this is used to store the current executed rule list. */ |
317 | | void *current_rule; /* this is used to store the current rule to be resumed. */ |
318 | | int rules_exp; /* expiration date for current rules execution */ |
319 | | int tunnel_timeout; |
320 | | |
321 | | struct { |
322 | | void *ptr; /* Pointer on the entity (def: NULL) */ |
323 | | int type; /* entity type (STRM_ENTITY_*) */ |
324 | | } last_entity; /* last evaluated entity that interrupted processing */ |
325 | | |
326 | | struct { |
327 | | void *ptr; /* Pointer on the entity (def: NULL) */ |
328 | | int type; /* entity type (STRM_ENTITY_*) */ |
329 | | } waiting_entity; /* The entity waiting to continue its processing and interrupted by an error/timeout */ |
330 | | |
331 | | unsigned int stream_epoch; /* copy of stream_epoch when the stream was created */ |
332 | | uint32_t term_evts_log; /* termination events log */ |
333 | | struct hlua *hlua[2]; /* lua runtime context (0: global, 1: per-thread) */ |
334 | | |
335 | | /* Context */ |
336 | | struct { |
337 | | struct resolv_requester *requester; /* owner of the resolution */ |
338 | | struct act_rule *parent; /* rule which requested this resolution */ |
339 | | char *hostname_dn; /* hostname being resolve, in domain name format */ |
340 | | int hostname_dn_len; /* size of hostname_dn */ |
341 | | /* 4 unused bytes here, recoverable via packing if needed */ |
342 | | } resolv_ctx; /* context information for DNS resolution */ |
343 | | struct be_counters_shared_tg *be_tgcounters; /* pointer to current thread group shared backend counters */ |
344 | | struct be_counters_shared_tg *sv_tgcounters; /* pointer to current thread group shared server counters */ |
345 | | }; |
346 | | |
347 | | #endif /* _HAPROXY_STREAM_T_H */ |
348 | | |
349 | | /* |
350 | | * Local variables: |
351 | | * c-indent-level: 8 |
352 | | * c-basic-offset: 8 |
353 | | * End: |
354 | | */ |