Willy TARREAU | 3dc0644 | 2006-06-15 21:48:13 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 2 | * include/proto/session.h |
| 3 | * This file defines everything related to sessions. |
| 4 | * |
| 5 | * Copyright (C) 2000-2010 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 | */ |
Willy TARREAU | 3dc0644 | 2006-06-15 21:48:13 +0200 | [diff] [blame] | 21 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 22 | #ifndef _PROTO_SESSION_H |
| 23 | #define _PROTO_SESSION_H |
| 24 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 25 | #include <common/config.h> |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 26 | #include <common/memory.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 27 | #include <types/session.h> |
Willy Tarreau | 91c43d7 | 2010-06-20 11:19:22 +0200 | [diff] [blame] | 28 | #include <proto/freq_ctr.h> |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 29 | #include <proto/stick_table.h> |
Willy TARREAU | 3dc0644 | 2006-06-15 21:48:13 +0200 | [diff] [blame] | 30 | |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 31 | extern struct pool_head *pool2_session; |
Willy Tarreau | f54f8bd | 2008-11-23 19:53:55 +0100 | [diff] [blame] | 32 | extern struct list sessions; |
Willy Tarreau | bf883e0 | 2014-11-25 21:10:35 +0100 | [diff] [blame] | 33 | extern struct list buffer_wq; |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 34 | |
Willy Tarreau | bc174aa | 2012-11-19 16:10:32 +0100 | [diff] [blame] | 35 | extern struct data_cb sess_conn_cb; |
| 36 | |
Willy Tarreau | 81f9aa3 | 2010-06-01 17:45:26 +0200 | [diff] [blame] | 37 | int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 38 | |
Willy Tarreau | c6ca1a0 | 2007-05-13 19:43:47 +0200 | [diff] [blame] | 39 | /* perform minimal intializations, report 0 in case of error, 1 if OK. */ |
| 40 | int init_session(); |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 41 | |
Willy Tarreau | a2a64e9 | 2011-09-07 23:01:56 +0200 | [diff] [blame] | 42 | /* kill a session and set the termination flags to <why> (one of SN_ERR_*) */ |
| 43 | void session_shutdown(struct session *session, int why); |
Simon Horman | dec5be4 | 2011-06-08 09:19:07 +0900 | [diff] [blame] | 44 | |
Krzysztof Piotr Oledzki | 583bc96 | 2007-11-24 22:12:47 +0100 | [diff] [blame] | 45 | void session_process_counters(struct session *s); |
Willy Tarreau | 7c669d7 | 2008-06-20 15:04:11 +0200 | [diff] [blame] | 46 | void sess_change_server(struct session *sess, struct server *newsrv); |
Willy Tarreau | 26c2506 | 2009-03-08 09:38:41 +0100 | [diff] [blame] | 47 | struct task *process_session(struct task *t); |
Willy Tarreau | 8445533 | 2009-03-15 22:34:05 +0100 | [diff] [blame] | 48 | void default_srv_error(struct session *s, struct stream_interface *si); |
Willy Tarreau | e12704b | 2014-07-15 19:06:18 +0200 | [diff] [blame] | 49 | struct stkctr *smp_fetch_sc_stkctr(struct session *l4, const struct arg *args, const char *kw); |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 50 | int parse_track_counters(char **args, int *arg, |
| 51 | int section_type, struct proxy *curpx, |
| 52 | struct track_ctr_prm *prm, |
Willy Tarreau | 0a3dd74 | 2012-05-08 19:47:01 +0200 | [diff] [blame] | 53 | struct proxy *defpx, char **err); |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 54 | |
Willy Tarreau | 4bfc580 | 2014-06-17 12:19:18 +0200 | [diff] [blame] | 55 | /* Update the session's backend and server time stats */ |
| 56 | void session_update_time_stats(struct session *s); |
Willy Tarreau | bf883e0 | 2014-11-25 21:10:35 +0100 | [diff] [blame] | 57 | void session_offer_buffers(int count); |
Willy Tarreau | 656859d | 2014-11-25 19:46:36 +0100 | [diff] [blame] | 58 | int session_alloc_buffers(struct session *s); |
| 59 | void session_release_buffers(struct session *s); |
| 60 | int session_alloc_recv_buffer(struct session *s, struct buffer **buf); |
Willy Tarreau | 4bfc580 | 2014-06-17 12:19:18 +0200 | [diff] [blame] | 61 | |
Willy Tarreau | 787add2 | 2013-11-23 23:37:04 +0100 | [diff] [blame] | 62 | /* returns the session from a void *owner */ |
| 63 | static inline struct session *session_from_task(struct task *t) |
| 64 | { |
| 65 | return (struct session *)t->context; |
| 66 | } |
| 67 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 68 | /* sets the stick counter's entry pointer */ |
| 69 | static inline void stkctr_set_entry(struct stkctr *stkctr, struct stksess *entry) |
| 70 | { |
| 71 | stkctr->entry = caddr_from_ptr(entry, 0); |
| 72 | } |
| 73 | |
| 74 | /* returns the entry pointer from a stick counter */ |
| 75 | static inline struct stksess *stkctr_entry(struct stkctr *stkctr) |
| 76 | { |
| 77 | return caddr_to_ptr(stkctr->entry); |
| 78 | } |
| 79 | |
| 80 | /* returns the two flags from a stick counter */ |
| 81 | static inline unsigned int stkctr_flags(struct stkctr *stkctr) |
| 82 | { |
| 83 | return caddr_to_data(stkctr->entry); |
| 84 | } |
| 85 | |
| 86 | /* sets up to two flags at a time on a composite address */ |
| 87 | static inline void stkctr_set_flags(struct stkctr *stkctr, unsigned int flags) |
| 88 | { |
| 89 | stkctr->entry = caddr_set_flags(stkctr->entry, flags); |
| 90 | } |
| 91 | |
| 92 | /* returns the two flags from a stick counter */ |
| 93 | static inline void stkctr_clr_flags(struct stkctr *stkctr, unsigned int flags) |
| 94 | { |
| 95 | stkctr->entry = caddr_clr_flags(stkctr->entry, flags); |
| 96 | } |
| 97 | |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 98 | /* Remove the refcount from the session to the tracked counters, and clear the |
| 99 | * pointer to ensure this is only performed once. The caller is responsible for |
| 100 | * ensuring that the pointer is valid first. |
| 101 | */ |
| 102 | static inline void session_store_counters(struct session *s) |
| 103 | { |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 104 | void *ptr; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 105 | int i; |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 106 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 107 | for (i = 0; i < MAX_SESS_STKCTR; i++) { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 108 | if (!stkctr_entry(&s->stkctr[i])) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 109 | continue; |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 110 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_CONN_CUR); |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 111 | if (ptr) |
| 112 | stktable_data_cast(ptr, conn_cur)--; |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 113 | stkctr_entry(&s->stkctr[i])->ref_cnt--; |
| 114 | stksess_kill_if_expired(s->stkctr[i].table, stkctr_entry(&s->stkctr[i])); |
| 115 | stkctr_set_entry(&s->stkctr[i], NULL); |
Willy Tarreau | 38285c1 | 2010-06-18 16:35:43 +0200 | [diff] [blame] | 116 | } |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 117 | } |
| 118 | |
Willy Tarreau | f333834 | 2014-01-28 21:40:28 +0100 | [diff] [blame] | 119 | /* Remove the refcount from the session counters tracked at the content level if |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 120 | * any, and clear the pointer to ensure this is only performed once. The caller |
| 121 | * is responsible for ensuring that the pointer is valid first. |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 122 | */ |
Willy Tarreau | f333834 | 2014-01-28 21:40:28 +0100 | [diff] [blame] | 123 | static inline void session_stop_content_counters(struct session *s) |
Willy Tarreau | 9ba2dcc | 2010-06-14 21:04:55 +0200 | [diff] [blame] | 124 | { |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 125 | void *ptr; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 126 | int i; |
Willy Tarreau | e348793 | 2010-06-18 21:03:20 +0200 | [diff] [blame] | 127 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 128 | for (i = 0; i < MAX_SESS_STKCTR; i++) { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 129 | if (!stkctr_entry(&s->stkctr[i])) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 130 | continue; |
Willy Tarreau | 0a4838c | 2010-08-06 20:11:05 +0200 | [diff] [blame] | 131 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 132 | if (!(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_CONTENT)) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 133 | continue; |
| 134 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 135 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_CONN_CUR); |
Willy Tarreau | 0a4838c | 2010-08-06 20:11:05 +0200 | [diff] [blame] | 136 | if (ptr) |
| 137 | stktable_data_cast(ptr, conn_cur)--; |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 138 | stkctr_entry(&s->stkctr[i])->ref_cnt--; |
| 139 | stksess_kill_if_expired(s->stkctr[i].table, stkctr_entry(&s->stkctr[i])); |
| 140 | stkctr_set_entry(&s->stkctr[i], NULL); |
Willy Tarreau | 0a4838c | 2010-08-06 20:11:05 +0200 | [diff] [blame] | 141 | } |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 142 | } |
Willy Tarreau | e348793 | 2010-06-18 21:03:20 +0200 | [diff] [blame] | 143 | |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 144 | /* Increase total and concurrent connection count for stick entry <ts> of table |
| 145 | * <t>. The caller is responsible for ensuring that <t> and <ts> are valid |
| 146 | * pointers, and for calling this only once per connection. |
| 147 | */ |
| 148 | static inline void session_start_counters(struct stktable *t, struct stksess *ts) |
| 149 | { |
| 150 | void *ptr; |
Willy Tarreau | 91c43d7 | 2010-06-20 11:19:22 +0200 | [diff] [blame] | 151 | |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 152 | ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CUR); |
| 153 | if (ptr) |
| 154 | stktable_data_cast(ptr, conn_cur)++; |
| 155 | |
| 156 | ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CNT); |
| 157 | if (ptr) |
| 158 | stktable_data_cast(ptr, conn_cnt)++; |
| 159 | |
| 160 | ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_RATE); |
| 161 | if (ptr) |
| 162 | update_freq_ctr_period(&stktable_data_cast(ptr, conn_rate), |
| 163 | t->data_arg[STKTABLE_DT_CONN_RATE].u, 1); |
| 164 | if (tick_isset(t->expire)) |
| 165 | ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire)); |
| 166 | } |
| 167 | |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 168 | /* Enable tracking of session counters as <stkctr> on stksess <ts>. The caller is |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 169 | * responsible for ensuring that <t> and <ts> are valid pointers. Some controls |
| 170 | * are performed to ensure the state can still change. |
| 171 | */ |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 172 | static inline void session_track_stkctr(struct stkctr *ctr, struct stktable *t, struct stksess *ts) |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 173 | { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 174 | if (stkctr_entry(ctr)) |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 175 | return; |
| 176 | |
| 177 | ts->ref_cnt++; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 178 | ctr->table = t; |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 179 | stkctr_set_entry(ctr, ts); |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 180 | session_start_counters(t, ts); |
| 181 | } |
| 182 | |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 183 | /* Increase the number of cumulated HTTP requests in the tracked counters */ |
| 184 | static void inline session_inc_http_req_ctr(struct session *s) |
| 185 | { |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 186 | void *ptr; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 187 | int i; |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 188 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 189 | for (i = 0; i < MAX_SESS_STKCTR; i++) { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 190 | if (!stkctr_entry(&s->stkctr[i])) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 191 | continue; |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 192 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 193 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_CNT); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 194 | if (ptr) |
| 195 | stktable_data_cast(ptr, http_req_cnt)++; |
| 196 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 197 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_RATE); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 198 | if (ptr) |
| 199 | update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 200 | s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 204 | /* Increase the number of cumulated HTTP requests in the backend's tracked counters */ |
| 205 | static void inline session_inc_be_http_req_ctr(struct session *s) |
| 206 | { |
| 207 | void *ptr; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 208 | int i; |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 209 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 210 | for (i = 0; i < MAX_SESS_STKCTR; i++) { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 211 | if (!stkctr_entry(&s->stkctr[i])) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 212 | continue; |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 213 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 214 | if (!(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_BACKEND)) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 215 | continue; |
| 216 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 217 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_CNT); |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 218 | if (ptr) |
| 219 | stktable_data_cast(ptr, http_req_cnt)++; |
| 220 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 221 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_REQ_RATE); |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 222 | if (ptr) |
| 223 | update_freq_ctr_period(&stktable_data_cast(ptr, http_req_rate), |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 224 | s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_REQ_RATE].u, 1); |
Willy Tarreau | 5d5b5d8 | 2012-12-09 12:00:04 +0100 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 228 | /* Increase the number of cumulated failed HTTP requests in the tracked |
| 229 | * counters. Only 4xx requests should be counted here so that we can |
| 230 | * distinguish between errors caused by client behaviour and other ones. |
| 231 | * Note that even 404 are interesting because they're generally caused by |
| 232 | * vulnerability scans. |
| 233 | */ |
| 234 | static void inline session_inc_http_err_ctr(struct session *s) |
| 235 | { |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 236 | void *ptr; |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 237 | int i; |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 238 | |
Willy Tarreau | b4c8493 | 2013-07-23 19:15:30 +0200 | [diff] [blame] | 239 | for (i = 0; i < MAX_SESS_STKCTR; i++) { |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 240 | if (!stkctr_entry(&s->stkctr[i])) |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 241 | continue; |
Willy Tarreau | f059a0f | 2010-08-03 16:29:52 +0200 | [diff] [blame] | 242 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 243 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_ERR_CNT); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 244 | if (ptr) |
| 245 | stktable_data_cast(ptr, http_err_cnt)++; |
| 246 | |
Willy Tarreau | cc08d2c | 2014-01-28 23:18:23 +0100 | [diff] [blame] | 247 | ptr = stktable_data_ptr(s->stkctr[i].table, stkctr_entry(&s->stkctr[i]), STKTABLE_DT_HTTP_ERR_RATE); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 248 | if (ptr) |
| 249 | update_freq_ctr_period(&stktable_data_cast(ptr, http_err_rate), |
Willy Tarreau | 20d46a5 | 2012-12-09 15:55:40 +0100 | [diff] [blame] | 250 | s->stkctr[i].table->data_arg[STKTABLE_DT_HTTP_ERR_RATE].u, 1); |
Willy Tarreau | da7ff64 | 2010-06-23 11:44:09 +0200 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | |
Simon Horman | af51495 | 2011-06-21 14:34:57 +0900 | [diff] [blame] | 254 | static void inline session_add_srv_conn(struct session *sess, struct server *srv) |
| 255 | { |
| 256 | sess->srv_conn = srv; |
| 257 | LIST_ADD(&srv->actconns, &sess->by_srv); |
| 258 | } |
| 259 | |
| 260 | static void inline session_del_srv_conn(struct session *sess) |
| 261 | { |
| 262 | if (!sess->srv_conn) |
| 263 | return; |
| 264 | |
| 265 | sess->srv_conn = NULL; |
| 266 | LIST_DEL(&sess->by_srv); |
| 267 | } |
| 268 | |
Willy Tarreau | 9bd0d74 | 2011-07-20 00:17:39 +0200 | [diff] [blame] | 269 | static void inline session_init_srv_conn(struct session *sess) |
| 270 | { |
| 271 | sess->srv_conn = NULL; |
| 272 | LIST_INIT(&sess->by_srv); |
| 273 | } |
| 274 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 275 | #endif /* _PROTO_SESSION_H */ |
Willy TARREAU | 3dc0644 | 2006-06-15 21:48:13 +0200 | [diff] [blame] | 276 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 277 | /* |
| 278 | * Local variables: |
| 279 | * c-indent-level: 8 |
| 280 | * c-basic-offset: 8 |
| 281 | * End: |
| 282 | */ |