2006-06-15 19:48:13 +00:00
|
|
|
/*
|
2020-06-04 21:46:14 +00:00
|
|
|
* include/haproxy/stream.h
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
* This file defines everything related to streams.
|
2010-06-01 15:45:26 +00:00
|
|
|
*
|
2020-06-04 21:46:14 +00:00
|
|
|
* Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
|
2010-06-01 15:45:26 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
|
|
* exclusively.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2006-06-15 19:48:13 +00:00
|
|
|
|
2020-06-04 21:46:14 +00:00
|
|
|
#ifndef _HAPROXY_STREAM_H
|
|
|
|
#define _HAPROXY_STREAM_H
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2020-06-04 08:15:32 +00:00
|
|
|
#include <haproxy/action-t.h>
|
2020-05-27 10:58:42 +00:00
|
|
|
#include <haproxy/api.h>
|
2020-06-03 17:33:00 +00:00
|
|
|
#include <haproxy/fd.h>
|
2020-06-01 10:18:08 +00:00
|
|
|
#include <haproxy/freq_ctr.h>
|
2020-06-04 09:29:21 +00:00
|
|
|
#include <haproxy/obj_type.h>
|
2020-06-04 21:46:14 +00:00
|
|
|
#include <haproxy/pool-t.h>
|
2020-06-04 20:59:39 +00:00
|
|
|
#include <haproxy/queue.h>
|
2020-06-04 16:46:44 +00:00
|
|
|
#include <haproxy/stick_table.h>
|
2020-06-04 21:46:14 +00:00
|
|
|
#include <haproxy/stream-t.h>
|
|
|
|
#include <haproxy/task-t.h>
|
|
|
|
#include <haproxy/trace-t.h>
|
2019-11-05 15:18:10 +00:00
|
|
|
|
|
|
|
extern struct trace_source trace_strm;
|
|
|
|
|
|
|
|
/* Details about these events are defined in <src/stream.c> */
|
|
|
|
#define STRM_EV_STRM_NEW (1ULL << 0)
|
|
|
|
#define STRM_EV_STRM_FREE (1ULL << 1)
|
|
|
|
#define STRM_EV_STRM_ERR (1ULL << 2)
|
|
|
|
#define STRM_EV_STRM_ANA (1ULL << 3)
|
|
|
|
#define STRM_EV_STRM_PROC (1ULL << 4)
|
|
|
|
#define STRM_EV_SI_ST (1ULL << 5)
|
|
|
|
#define STRM_EV_HTTP_ANA (1ULL << 6)
|
|
|
|
#define STRM_EV_HTTP_ERR (1ULL << 7)
|
|
|
|
#define STRM_EV_TCP_ANA (1ULL << 8)
|
|
|
|
#define STRM_EV_TCP_ERR (1ULL << 9)
|
|
|
|
#define STRM_EV_FLT_ANA (1ULL << 10)
|
|
|
|
#define STRM_EV_FLT_ERR (1ULL << 11)
|
2006-06-15 19:48:13 +00:00
|
|
|
|
2019-05-14 20:05:28 +00:00
|
|
|
#define IS_HTX_STRM(strm) ((strm)->flags & SF_HTX)
|
|
|
|
|
2017-11-24 16:34:44 +00:00
|
|
|
extern struct pool_head *pool_head_stream;
|
2020-02-28 14:13:33 +00:00
|
|
|
extern struct pool_head *pool_head_uniqueid;
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
extern struct list streams;
|
2007-05-13 17:43:47 +00:00
|
|
|
|
2012-11-19 15:10:32 +00:00
|
|
|
extern struct data_cb sess_conn_cb;
|
|
|
|
|
2020-09-14 09:40:13 +00:00
|
|
|
struct stream *stream_new(struct session *sess, enum obj_type *origin, struct buffer *input);
|
|
|
|
int stream_create_from_cs(struct conn_stream *cs, struct buffer *input);
|
2006-06-15 19:48:13 +00:00
|
|
|
|
2015-04-02 23:14:29 +00:00
|
|
|
/* kill a stream and set the termination flags to <why> (one of SF_ERR_*) */
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void stream_shutdown(struct stream *stream, int why);
|
2019-05-22 07:33:03 +00:00
|
|
|
void stream_dump(struct buffer *buf, const struct stream *s, const char *pfx, char eol);
|
2019-04-25 17:08:48 +00:00
|
|
|
void stream_dump_and_crash(enum obj_type *obj, int rate);
|
2011-06-08 00:19:07 +00:00
|
|
|
|
2020-03-05 19:19:02 +00:00
|
|
|
struct ist stream_generate_unique_id(struct stream *strm, struct list *format);
|
2020-02-28 14:13:33 +00:00
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void stream_process_counters(struct stream *s);
|
|
|
|
void sess_change_server(struct stream *sess, struct server *newsrv);
|
2018-05-25 12:04:04 +00:00
|
|
|
struct task *process_stream(struct task *t, void *context, unsigned short state);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void default_srv_error(struct stream *s, struct stream_interface *si);
|
2010-06-14 19:04:55 +00:00
|
|
|
int parse_track_counters(char **args, int *arg,
|
|
|
|
int section_type, struct proxy *curpx,
|
|
|
|
struct track_ctr_prm *prm,
|
2012-05-08 17:47:01 +00:00
|
|
|
struct proxy *defpx, char **err);
|
2010-06-14 19:04:55 +00:00
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
/* Update the stream's backend and server time stats */
|
|
|
|
void stream_update_time_stats(struct stream *s);
|
|
|
|
void stream_release_buffers(struct stream *s);
|
2018-11-06 14:50:21 +00:00
|
|
|
int stream_buf_available(void *arg);
|
2014-06-17 10:19:18 +00:00
|
|
|
|
2015-04-03 11:53:24 +00:00
|
|
|
/* returns the session this stream belongs to */
|
|
|
|
static inline struct session *strm_sess(const struct stream *strm)
|
|
|
|
{
|
|
|
|
return strm->sess;
|
|
|
|
}
|
|
|
|
|
2015-04-04 00:10:38 +00:00
|
|
|
/* returns the frontend this stream was initiated from */
|
|
|
|
static inline struct proxy *strm_fe(const struct stream *strm)
|
|
|
|
{
|
|
|
|
return strm->sess->fe;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns the listener this stream was initiated from */
|
|
|
|
static inline struct listener *strm_li(const struct stream *strm)
|
|
|
|
{
|
|
|
|
return strm->sess->listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns a pointer to the origin of the session which created this stream */
|
|
|
|
static inline enum obj_type *strm_orig(const struct stream *strm)
|
|
|
|
{
|
|
|
|
return strm->sess->origin;
|
|
|
|
}
|
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
/* Remove the refcount from the stream to the tracked counters, and clear the
|
2010-06-14 19:04:55 +00:00
|
|
|
* pointer to ensure this is only performed once. The caller is responsible for
|
2015-09-21 15:48:24 +00:00
|
|
|
* ensuring that the pointer is valid first. We must be extremely careful not
|
|
|
|
* to touch the entries we inherited from the session.
|
2010-06-14 19:04:55 +00:00
|
|
|
*/
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
static inline void stream_store_counters(struct stream *s)
|
2010-06-14 19:04:55 +00:00
|
|
|
{
|
2010-08-03 14:29:52 +00:00
|
|
|
void *ptr;
|
2012-12-09 14:55:40 +00:00
|
|
|
int i;
|
2017-06-13 17:37:32 +00:00
|
|
|
struct stksess *ts;
|
2010-08-03 14:29:52 +00:00
|
|
|
|
2013-07-23 17:15:30 +00:00
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
2017-06-13 17:37:32 +00:00
|
|
|
ts = stkctr_entry(&s->stkctr[i]);
|
|
|
|
if (!ts)
|
2012-12-09 14:55:40 +00:00
|
|
|
continue;
|
2015-09-21 15:48:24 +00:00
|
|
|
|
|
|
|
if (stkctr_entry(&s->sess->stkctr[i]))
|
|
|
|
continue;
|
|
|
|
|
2017-06-13 17:37:32 +00:00
|
|
|
ptr = stktable_data_ptr(s->stkctr[i].table, ts, STKTABLE_DT_CONN_CUR);
|
|
|
|
if (ptr) {
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2019-01-03 23:11:59 +00:00
|
|
|
if (stktable_data_cast(ptr, conn_cur) > 0)
|
|
|
|
stktable_data_cast(ptr, conn_cur)--;
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-11-29 15:15:07 +00:00
|
|
|
|
|
|
|
/* If data was modified, we need to touch to re-schedule sync */
|
|
|
|
stktable_touch_local(s->stkctr[i].table, ts, 0);
|
2017-06-13 17:37:32 +00:00
|
|
|
}
|
2014-01-28 22:18:23 +00:00
|
|
|
stkctr_set_entry(&s->stkctr[i], NULL);
|
2017-06-13 17:37:32 +00:00
|
|
|
stksess_kill_if_expired(s->stkctr[i].table, ts, 1);
|
2010-06-18 14:35:43 +00:00
|
|
|
}
|
2010-06-14 19:04:55 +00:00
|
|
|
}
|
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
/* Remove the refcount from the stream counters tracked at the content level if
|
2010-08-03 14:29:52 +00:00
|
|
|
* any, and clear the pointer to ensure this is only performed once. The caller
|
2015-09-21 15:48:24 +00:00
|
|
|
* is responsible for ensuring that the pointer is valid first. We must be
|
|
|
|
* extremely careful not to touch the entries we inherited from the session.
|
2010-06-14 19:04:55 +00:00
|
|
|
*/
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
static inline void stream_stop_content_counters(struct stream *s)
|
2010-06-14 19:04:55 +00:00
|
|
|
{
|
2017-06-13 17:37:32 +00:00
|
|
|
struct stksess *ts;
|
2010-08-03 14:29:52 +00:00
|
|
|
void *ptr;
|
2012-12-09 14:55:40 +00:00
|
|
|
int i;
|
2010-06-18 19:03:20 +00:00
|
|
|
|
2013-07-23 17:15:30 +00:00
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
2017-06-13 17:37:32 +00:00
|
|
|
ts = stkctr_entry(&s->stkctr[i]);
|
|
|
|
if (!ts)
|
2012-12-09 14:55:40 +00:00
|
|
|
continue;
|
|
|
|
|
2015-09-21 15:48:24 +00:00
|
|
|
if (stkctr_entry(&s->sess->stkctr[i]))
|
|
|
|
continue;
|
|
|
|
|
2014-01-28 22:18:23 +00:00
|
|
|
if (!(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_CONTENT))
|
2012-12-09 14:55:40 +00:00
|
|
|
continue;
|
|
|
|
|
2017-06-13 17:37:32 +00:00
|
|
|
ptr = stktable_data_ptr(s->stkctr[i].table, ts, STKTABLE_DT_CONN_CUR);
|
|
|
|
if (ptr) {
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2019-01-03 23:11:59 +00:00
|
|
|
if (stktable_data_cast(ptr, conn_cur) > 0)
|
|
|
|
stktable_data_cast(ptr, conn_cur)--;
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-11-29 15:15:07 +00:00
|
|
|
|
|
|
|
/* If data was modified, we need to touch to re-schedule sync */
|
|
|
|
stktable_touch_local(s->stkctr[i].table, ts, 0);
|
2017-06-13 17:37:32 +00:00
|
|
|
}
|
2014-01-28 22:18:23 +00:00
|
|
|
stkctr_set_entry(&s->stkctr[i], NULL);
|
2017-06-13 17:37:32 +00:00
|
|
|
stksess_kill_if_expired(s->stkctr[i].table, ts, 1);
|
2010-08-06 18:11:05 +00:00
|
|
|
}
|
2010-08-03 14:29:52 +00:00
|
|
|
}
|
2010-06-18 19:03:20 +00:00
|
|
|
|
2010-08-03 14:29:52 +00:00
|
|
|
/* Increase total and concurrent connection count for stick entry <ts> of table
|
|
|
|
* <t>. The caller is responsible for ensuring that <t> and <ts> are valid
|
|
|
|
* pointers, and for calling this only once per connection.
|
|
|
|
*/
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
static inline void stream_start_counters(struct stktable *t, struct stksess *ts)
|
2010-08-03 14:29:52 +00:00
|
|
|
{
|
|
|
|
void *ptr;
|
|
|
|
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2010-08-03 14:29:52 +00:00
|
|
|
ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CUR);
|
|
|
|
if (ptr)
|
|
|
|
stktable_data_cast(ptr, conn_cur)++;
|
|
|
|
|
|
|
|
ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_CNT);
|
|
|
|
if (ptr)
|
|
|
|
stktable_data_cast(ptr, conn_cnt)++;
|
|
|
|
|
|
|
|
ptr = stktable_data_ptr(t, ts, STKTABLE_DT_CONN_RATE);
|
|
|
|
if (ptr)
|
|
|
|
update_freq_ctr_period(&stktable_data_cast(ptr, conn_rate),
|
|
|
|
t->data_arg[STKTABLE_DT_CONN_RATE].u, 1);
|
|
|
|
if (tick_isset(t->expire))
|
|
|
|
ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
|
2017-06-13 17:37:32 +00:00
|
|
|
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_RWLOCK_WRUNLOCK(STK_SESS_LOCK, &ts->lock);
|
2017-11-29 15:15:07 +00:00
|
|
|
|
|
|
|
/* If data was modified, we need to touch to re-schedule sync */
|
|
|
|
stktable_touch_local(t, ts, 0);
|
2010-08-03 14:29:52 +00:00
|
|
|
}
|
2010-06-20 09:19:22 +00:00
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
/* Enable tracking of stream counters as <stkctr> on stksess <ts>. The caller is
|
2010-08-03 14:29:52 +00:00
|
|
|
* responsible for ensuring that <t> and <ts> are valid pointers. Some controls
|
|
|
|
* are performed to ensure the state can still change.
|
|
|
|
*/
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
static inline void stream_track_stkctr(struct stkctr *ctr, struct stktable *t, struct stksess *ts)
|
2010-08-03 14:29:52 +00:00
|
|
|
{
|
2017-06-13 17:37:32 +00:00
|
|
|
/* Why this test ???? */
|
2014-01-28 22:18:23 +00:00
|
|
|
if (stkctr_entry(ctr))
|
2010-08-03 14:29:52 +00:00
|
|
|
return;
|
|
|
|
|
2012-12-09 14:55:40 +00:00
|
|
|
ctr->table = t;
|
2014-01-28 22:18:23 +00:00
|
|
|
stkctr_set_entry(ctr, ts);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
stream_start_counters(t, ts);
|
2010-06-14 19:04:55 +00:00
|
|
|
}
|
2007-11-24 21:12:47 +00:00
|
|
|
|
2010-06-23 09:44:09 +00:00
|
|
|
/* Increase the number of cumulated HTTP requests in the tracked counters */
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_inc_http_req_ctr(struct stream *s)
|
2010-06-23 09:44:09 +00:00
|
|
|
{
|
2012-12-09 14:55:40 +00:00
|
|
|
int i;
|
2010-06-23 09:44:09 +00:00
|
|
|
|
2013-07-23 17:15:30 +00:00
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
2020-10-06 11:52:40 +00:00
|
|
|
if (!stkctr_inc_http_req_ctr(&s->stkctr[i]))
|
|
|
|
stkctr_inc_http_req_ctr(&s->sess->stkctr[i]);
|
2012-12-09 11:00:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-04 14:29:12 +00:00
|
|
|
/* Increase the number of cumulated HTTP requests in the backend's tracked
|
|
|
|
* counters. We don't look up the session since it cannot happen in the bakcend.
|
|
|
|
*/
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_inc_be_http_req_ctr(struct stream *s)
|
2012-12-09 11:00:04 +00:00
|
|
|
{
|
2012-12-09 14:55:40 +00:00
|
|
|
int i;
|
2012-12-09 11:00:04 +00:00
|
|
|
|
2013-07-23 17:15:30 +00:00
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
2020-10-06 11:52:40 +00:00
|
|
|
if (!stkctr_entry(&s->stkctr[i]) || !(stkctr_flags(&s->stkctr[i]) & STKCTR_TRACK_BACKEND))
|
2012-12-09 14:55:40 +00:00
|
|
|
continue;
|
2012-12-09 11:00:04 +00:00
|
|
|
|
2020-10-06 11:52:40 +00:00
|
|
|
stkctr_inc_http_req_ctr(&s->stkctr[i]);
|
2010-06-23 09:44:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Increase the number of cumulated failed HTTP requests in the tracked
|
|
|
|
* counters. Only 4xx requests should be counted here so that we can
|
|
|
|
* distinguish between errors caused by client behaviour and other ones.
|
|
|
|
* Note that even 404 are interesting because they're generally caused by
|
|
|
|
* vulnerability scans.
|
|
|
|
*/
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_inc_http_err_ctr(struct stream *s)
|
2010-06-23 09:44:09 +00:00
|
|
|
{
|
2012-12-09 14:55:40 +00:00
|
|
|
int i;
|
2010-08-03 14:29:52 +00:00
|
|
|
|
2013-07-23 17:15:30 +00:00
|
|
|
for (i = 0; i < MAX_SESS_STKCTR; i++) {
|
2020-10-06 11:52:40 +00:00
|
|
|
if (!stkctr_inc_http_err_ctr(&s->stkctr[i]))
|
|
|
|
stkctr_inc_http_err_ctr(&s->sess->stkctr[i]);
|
2010-06-23 09:44:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void __stream_add_srv_conn(struct stream *sess, struct server *srv)
|
2011-06-21 05:34:57 +00:00
|
|
|
{
|
|
|
|
sess->srv_conn = srv;
|
|
|
|
LIST_ADD(&srv->actconns, &sess->by_srv);
|
2017-11-26 17:48:14 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_add_srv_conn(struct stream *sess, struct server *srv)
|
2017-11-26 17:48:14 +00:00
|
|
|
{
|
|
|
|
HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
|
|
|
|
__stream_add_srv_conn(sess, srv);
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
|
2011-06-21 05:34:57 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_del_srv_conn(struct stream *sess)
|
2011-06-21 05:34:57 +00:00
|
|
|
{
|
2017-06-08 12:04:45 +00:00
|
|
|
struct server *srv = sess->srv_conn;
|
|
|
|
|
|
|
|
if (!srv)
|
2011-06-21 05:34:57 +00:00
|
|
|
return;
|
|
|
|
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
|
2011-06-21 05:34:57 +00:00
|
|
|
sess->srv_conn = NULL;
|
|
|
|
LIST_DEL(&sess->by_srv);
|
2017-11-07 09:42:54 +00:00
|
|
|
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
|
2011-06-21 05:34:57 +00:00
|
|
|
}
|
|
|
|
|
2019-04-15 19:25:03 +00:00
|
|
|
static inline void stream_init_srv_conn(struct stream *sess)
|
2011-07-19 22:17:39 +00:00
|
|
|
{
|
|
|
|
sess->srv_conn = NULL;
|
|
|
|
LIST_INIT(&sess->by_srv);
|
|
|
|
}
|
|
|
|
|
2019-07-12 14:16:59 +00:00
|
|
|
static inline void stream_choose_redispatch(struct stream *s)
|
|
|
|
{
|
|
|
|
struct stream_interface *si = &s->si[1];
|
|
|
|
|
|
|
|
/* If the "redispatch" option is set on the backend, we are allowed to
|
|
|
|
* retry on another server. By default this redispatch occurs on the
|
|
|
|
* last retry, but if configured we allow redispatches to occur on
|
|
|
|
* configurable intervals, e.g. on every retry. In order to achieve this,
|
|
|
|
* we must mark the stream unassigned, and eventually clear the DIRECT
|
|
|
|
* bit to ignore any persistence cookie. We won't count a retry nor a
|
|
|
|
* redispatch yet, because this will depend on what server is selected.
|
|
|
|
* If the connection is not persistent, the balancing algorithm is not
|
|
|
|
* determinist (round robin) and there is more than one active server,
|
|
|
|
* we accept to perform an immediate redispatch without waiting since
|
|
|
|
* we don't care about this particular server.
|
|
|
|
*/
|
|
|
|
if (objt_server(s->target) &&
|
|
|
|
(s->be->options & PR_O_REDISP) && !(s->flags & SF_FORCE_PRST) &&
|
|
|
|
((__objt_server(s->target)->cur_state < SRV_ST_RUNNING) ||
|
|
|
|
(((s->be->redispatch_after > 0) &&
|
|
|
|
((s->be->conn_retries - si->conn_retries) %
|
|
|
|
s->be->redispatch_after == 0)) ||
|
|
|
|
((s->be->redispatch_after < 0) &&
|
|
|
|
((s->be->conn_retries - si->conn_retries) %
|
|
|
|
(s->be->conn_retries + 1 + s->be->redispatch_after) == 0))) ||
|
|
|
|
(!(s->flags & SF_DIRECT) && s->be->srv_act > 1 &&
|
|
|
|
((s->be->lbprm.algo & BE_LB_KIND) == BE_LB_KIND_RR)))) {
|
|
|
|
sess_change_server(s, NULL);
|
|
|
|
if (may_dequeue_tasks(objt_server(s->target), s->be))
|
|
|
|
process_srv_queue(objt_server(s->target));
|
|
|
|
|
|
|
|
s->flags &= ~(SF_DIRECT | SF_ASSIGNED | SF_ADDR_SET);
|
|
|
|
si->state = SI_ST_REQ;
|
|
|
|
} else {
|
|
|
|
if (objt_server(s->target))
|
|
|
|
_HA_ATOMIC_ADD(&__objt_server(s->target)->counters.retries, 1);
|
|
|
|
_HA_ATOMIC_ADD(&s->be->be_counters.retries, 1);
|
|
|
|
si->state = SI_ST_ASS;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-09-27 17:29:33 +00:00
|
|
|
void service_keywords_register(struct action_kw_list *kw_list);
|
2020-11-28 18:32:14 +00:00
|
|
|
struct action_kw *service_find(const char *kw);
|
2019-03-19 07:08:10 +00:00
|
|
|
void list_services(FILE *out);
|
2015-09-27 17:29:33 +00:00
|
|
|
|
2020-06-04 21:46:14 +00:00
|
|
|
#endif /* _HAPROXY_STREAM_H */
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|