src/proto_http.o src/raw_sock.o src/appsession.o src/backend.o \
src/lb_chash.o src/lb_fwlc.o src/lb_fwrr.o src/lb_map.o src/lb_fas.o \
src/stream_interface.o src/dumpstats.o src/proto_tcp.o \
- src/session.o src/hdr_idx.o src/ev_select.o src/signal.o \
+ src/stream.o src/hdr_idx.o src/ev_select.o src/signal.o \
src/acl.o src/sample.o src/memory.o src/freq_ctr.o src/auth.o \
src/compression.o src/payload.o src/hash.o src/pattern.o src/map.o \
src/namespace.o src/mailers.o
#define ABORT_NOW() (*(int*)0=0)
/* this one is provided for easy code tracing.
- * Usage: TRACE(sess||0, fmt, args...);
- * TRACE(sess, "");
+ * Usage: TRACE(strm||0, fmt, args...);
+ * TRACE(strm, "");
*/
-#define TRACE(sess, fmt, args...) do { \
+#define TRACE(strm, fmt, args...) do { \
fprintf(stderr, \
- "%d.%06d [%s:%d %s] [sess %p(%x)] " fmt "\n", \
+ "%d.%06d [%s:%d %s] [strm %p(%x)] " fmt "\n", \
(int)now.tv_sec, (int)now.tv_usec, \
__FILE__, __LINE__, __FUNCTION__, \
- sess, sess?((struct session *)sess)->uniq_id:~0U, \
+ strm, strm?((struct stream *)strm)->uniq_id:~0U, \
##args); \
} while (0)
/*
* BUFSIZE defines the size of a read and write buffer. It is the maximum
- * amount of bytes which can be stored by the proxy for each session. However,
+ * amount of bytes which can be stored by the proxy for each stream. However,
* when reading HTTP headers, the proxy needs some spare space to add or rewrite
* headers if needed. The size of this spare is defined with MAXREWRITE. So it
* is not possible to process headers longer than BUFSIZE-MAXREWRITE bytes. By
#define SSL_HANDSHAKE_MAX_COST (76*1024) // measured
#endif
-/* approximate session size (for maxconn estimate) */
-#ifndef SESSION_MAX_COST
-#define SESSION_MAX_COST (sizeof(struct session) + \
+/* approximate stream size (for maxconn estimate) */
+#ifndef STREAM_MAX_COST
+#define STREAM_MAX_COST (sizeof(struct stream) + \
2 * sizeof(struct channel) + \
2 * sizeof(struct connection) + \
REQURI_LEN + \
* function only computes the condition, it does not apply the polarity required
* by IF/UNLESS, it's up to the caller to do this.
*/
-enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, void *l7, unsigned int opt);
+enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct stream *l4, void *l7, unsigned int opt);
/* Returns a pointer to the first ACL conflicting with usage at place <where>
* which is one of the SMP_VAL_* bits indicating a check place, or NULL if
#include <types/backend.h>
#include <types/proxy.h>
#include <types/server.h>
-#include <types/session.h>
+#include <types/stream.h>
-int assign_server(struct session *s);
-int assign_server_address(struct session *s);
-int assign_server_and_queue(struct session *s);
-int connect_server(struct session *s);
-int srv_redispatch_connect(struct session *t);
+int assign_server(struct stream *s);
+int assign_server_address(struct stream *s);
+int assign_server_and_queue(struct stream *s);
+int connect_server(struct stream *s);
+int srv_redispatch_connect(struct stream *t);
const char *backend_lb_algo_str(int algo);
int backend_parse_balance(const char **args, char **err, struct proxy *curproxy);
-int tcp_persist_rdp_cookie(struct session *s, struct channel *req, int an_bit);
+int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit);
int be_downtime(struct proxy *px);
void recount_servers(struct proxy *px);
#include <types/channel.h>
#include <types/global.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/stream_interface.h>
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
int bo_getblk_nc(struct channel *chn, char **blk1, int *len1, char **blk2, int *len2);
-/* returns a pointer to the session the channel belongs to */
-static inline struct session *chn_sess(const struct channel *chn)
+/* returns a pointer to the stream the channel belongs to */
+static inline struct stream *chn_sess(const struct channel *chn)
{
if (chn->flags & CF_ISRESP)
- return LIST_ELEM(chn, struct session *, res);
+ return LIST_ELEM(chn, struct stream *, res);
else
- return LIST_ELEM(chn, struct session *, req);
+ return LIST_ELEM(chn, struct stream *, req);
}
/* returns a pointer to the stream interface feeding the channel (producer) */
static inline struct stream_interface *chn_prod(const struct channel *chn)
{
if (chn->flags & CF_ISRESP)
- return &LIST_ELEM(chn, struct session *, res)->si[1];
+ return &LIST_ELEM(chn, struct stream *, res)->si[1];
else
- return &LIST_ELEM(chn, struct session *, req)->si[0];
+ return &LIST_ELEM(chn, struct stream *, req)->si[0];
}
/* returns a pointer to the stream interface consuming the channel (producer) */
static inline struct stream_interface *chn_cons(const struct channel *chn)
{
if (chn->flags & CF_ISRESP)
- return &LIST_ELEM(chn, struct session *, res)->si[0];
+ return &LIST_ELEM(chn, struct stream *, res)->si[0];
else
- return &LIST_ELEM(chn, struct session *, req)->si[1];
+ return &LIST_ELEM(chn, struct stream *, req)->si[1];
}
/* Initialize all fields in the channel. */
int comp_append_algo(struct comp *comp, const char *algo);
int http_emit_chunk_size(char *end, unsigned int chksz);
-int http_compression_buffer_init(struct session *s, struct buffer *in, struct buffer *out);
-int http_compression_buffer_add_data(struct session *s, struct buffer *in, struct buffer *out);
-int http_compression_buffer_end(struct session *s, struct buffer **in, struct buffer **out, int end);
+int http_compression_buffer_init(struct stream *s, struct buffer *in, struct buffer *out);
+int http_compression_buffer_add_data(struct stream *s, struct buffer *in, struct buffer *out);
+int http_compression_buffer_end(struct stream *s, struct buffer **in, struct buffer **out, int end);
#ifdef USE_ZLIB
extern long zlib_used_memory;
#define _PROTO_FRONTEND_H
#include <common/config.h>
-#include <types/session.h>
+#include <types/stream.h>
-int frontend_accept(struct session *s);
+int frontend_accept(struct stream *s);
#endif /* _PROTO_FRONTEND_H */
#include <common/memory.h>
#include <types/log.h>
#include <types/proxy.h>
-#include <types/session.h>
+#include <types/stream.h>
extern struct pool_head *pool2_requri;
extern struct pool_head *pool2_uniqueid;
extern char *logline;
-int build_logline(struct session *s, char *dst, size_t maxsize, struct list *list_format);
+int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format);
/*
- * send a log for the session when we have enough info about it.
+ * send a log for the stream when we have enough info about it.
* Will not log if the frontend has no log defined.
*/
-void sess_log(struct session *s);
+void strm_log(struct stream *s);
/*
* Parse args in a logformat_var
#include <common/config.h>
#include <types/sample.h>
-#include <types/session.h>
+#include <types/stream.h>
-int fetch_rdp_cookie_name(struct session *s, struct sample *smp, const char *cname, int clen);
+int fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, int clen);
int val_payload_lv(struct arg *arg, char **err_msg);
#endif /* _PROTO_PROTO_PAYLOAD_H */
#include <common/config.h>
#include <common/ticks.h>
#include <common/time.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/peers.h>
void peers_register_table(struct peers *, struct stktable *table);
#include <common/config.h>
#include <types/proto_http.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/task.h>
/*
#define HTTP_IS_TOKEN(x) (http_is_token[(unsigned char)(x)])
#define HTTP_IS_VER_TOKEN(x) (http_is_ver_token[(unsigned char)(x)])
-int process_cli(struct session *s);
-int process_srv_data(struct session *s);
-int process_srv_conn(struct session *s);
-int http_wait_for_request(struct session *s, struct channel *req, int an_bit);
-int http_process_req_common(struct session *s, struct channel *req, int an_bit, struct proxy *px);
-int http_process_request(struct session *s, struct channel *req, int an_bit);
-int http_process_tarpit(struct session *s, struct channel *req, int an_bit);
-int http_wait_for_request_body(struct session *s, struct channel *req, int an_bit);
+int process_cli(struct stream *s);
+int process_srv_data(struct stream *s);
+int process_srv_conn(struct stream *s);
+int http_wait_for_request(struct stream *s, struct channel *req, int an_bit);
+int http_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px);
+int http_process_request(struct stream *s, struct channel *req, int an_bit);
+int http_process_tarpit(struct stream *s, struct channel *req, int an_bit);
+int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit);
int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* svr_name);
-int http_wait_for_response(struct session *s, struct channel *rep, int an_bit);
-int http_process_res_common(struct session *s, struct channel *rep, int an_bit, struct proxy *px);
-int http_request_forward_body(struct session *s, struct channel *req, int an_bit);
-int http_response_forward_body(struct session *s, struct channel *res, int an_bit);
+int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit);
+int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px);
+int http_request_forward_body(struct stream *s, struct channel *req, int an_bit);
+int http_response_forward_body(struct stream *s, struct channel *res, int an_bit);
-void debug_hdr(const char *dir, struct session *s, const char *start, const char *end);
-void get_srv_from_appsession(struct session *s, const char *begin, int len);
-int apply_filter_to_req_headers(struct session *s, struct channel *req, struct hdr_exp *exp);
-int apply_filter_to_req_line(struct session *s, struct channel *req, struct hdr_exp *exp);
-int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px);
-int apply_filters_to_response(struct session *s, struct channel *rtr, struct proxy *px);
-void manage_client_side_appsession(struct session *s, const char *buf, int len);
-void manage_client_side_cookies(struct session *s, struct channel *req);
-void manage_server_side_cookies(struct session *s, struct channel *rtr);
-void check_response_for_cacheability(struct session *s, struct channel *rtr);
+void debug_hdr(const char *dir, struct stream *s, const char *start, const char *end);
+void get_srv_from_appsession(struct stream *s, const char *begin, int len);
+int apply_filter_to_req_headers(struct stream *s, struct channel *req, struct hdr_exp *exp);
+int apply_filter_to_req_line(struct stream *s, struct channel *req, struct hdr_exp *exp);
+int apply_filters_to_request(struct stream *s, struct channel *req, struct proxy *px);
+int apply_filters_to_response(struct stream *s, struct channel *rtr, struct proxy *px);
+void manage_client_side_appsession(struct stream *s, const char *buf, int len);
+void manage_client_side_cookies(struct stream *s, struct channel *req);
+void manage_server_side_cookies(struct stream *s, struct channel *rtr);
+void check_response_for_cacheability(struct stream *s, struct channel *rtr);
int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
void init_proto_http();
int http_find_full_header2(const char *name, int len,
int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx);
int http_header_add_tail2(struct http_msg *msg, struct hdr_idx *hdr_idx, const char *text, int len);
int http_replace_req_line(int action, const char *replace, int len,
- struct proxy *px, struct session *s, struct http_txn *txn);
-int http_transform_header_str(struct session* s, struct http_msg *msg, const char* name,
+ struct proxy *px, struct stream *s, struct http_txn *txn);
+int http_transform_header_str(struct stream* s, struct http_msg *msg, const char* name,
unsigned int name_len, const char *str, struct my_regex *re,
int action);
-void http_sess_log(struct session *s);
void inet_set_tos(int fd, struct sockaddr_storage from, int tos);
-void http_perform_server_redirect(struct session *s, struct stream_interface *si);
-void http_return_srv_error(struct session *s, struct stream_interface *si);
-void http_capture_bad_message(struct error_snapshot *es, struct session *s,
+void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
+void http_return_srv_error(struct stream *s, struct stream_interface *si);
+void http_capture_bad_message(struct error_snapshot *es, struct stream *s,
struct http_msg *msg,
enum ht_state state, struct proxy *other_end);
unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
struct hdr_idx *idx, int occ,
struct hdr_ctx *ctx, char **vptr, int *vlen);
-void http_init_txn(struct session *s);
-void http_end_txn(struct session *s);
-void http_reset_txn(struct session *s);
-void http_adjust_conn_mode(struct session *s, struct http_txn *txn, struct http_msg *msg);
+void http_init_txn(struct stream *s);
+void http_end_txn(struct stream *s);
+void http_reset_txn(struct stream *s);
+void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg);
struct http_req_rule *parse_http_req_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
struct http_res_rule *parse_http_res_cond(const char **args, const char *file, int linenum, struct proxy *proxy);
void free_http_req_rules(struct list *r);
void free_http_res_rules(struct list *r);
-struct chunk *http_error_message(struct session *s, int msgnum);
+struct chunk *http_error_message(struct stream *s, int msgnum);
struct redirect_rule *http_parse_redirect_rule(const char *file, int linenum, struct proxy *curproxy,
const char **args, char **errmsg, int use_fmt);
-int smp_fetch_cookie(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+int smp_fetch_cookie(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private);
int
-smp_fetch_base32(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_base32(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private);
enum http_meth_t find_http_meth(const char *str, const int len);
int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_drain(int fd);
-int tcp_inspect_request(struct session *s, struct channel *req, int an_bit);
-int tcp_inspect_response(struct session *s, struct channel *rep, int an_bit);
-int tcp_exec_req_rules(struct session *s);
+int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit);
+int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit);
+int tcp_exec_req_rules(struct stream *s);
/* TCP keywords. */
void tcp_req_conn_keywords_register(struct tcp_action_kw_list *kw_list);
#define _PROTO_PROTO_UXST_H
#include <common/config.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/task.h>
void uxst_add_listener(struct listener *listener);
void stop_proxy(struct proxy *p);
void pause_proxies(void);
void resume_proxies(void);
-int session_set_backend(struct session *s, struct proxy *be);
+int stream_set_backend(struct stream *s, struct proxy *be);
const char *proxy_cap_str(int cap);
const char *proxy_mode_str(int mode);
#include <types/proxy.h>
#include <types/queue.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/server.h>
#include <types/task.h>
extern struct pool_head *pool2_pendconn;
int init_pendconn();
-struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px);
-struct pendconn *pendconn_add(struct session *sess);
+struct stream *pendconn_get_next_strm(struct server *srv, struct proxy *px);
+struct pendconn *pendconn_add(struct stream *strm);
void pendconn_free(struct pendconn *p);
void process_srv_queue(struct server *s);
unsigned int srv_dynamic_maxconn(const struct server *s);
struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, int line, char **err, struct arg_list *al);
struct sample_conv *find_sample_conv(const char *kw, int len);
-struct sample *sample_process(struct proxy *px, struct session *l4,
+struct sample *sample_process(struct proxy *px, struct stream *l4,
void *l7, unsigned int dir, struct sample_expr *expr,
struct sample *p);
-struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l7,
+struct sample *sample_fetch_string(struct proxy *px, struct stream *l4, void *l7,
unsigned int opt, struct sample_expr *expr);
void sample_register_fetches(struct sample_fetch_kw_list *psl);
void sample_register_convs(struct sample_conv_kw_list *psl);
struct stksess *stktable_update_key(struct stktable *table, struct stktable_key *key);
struct stktable_key *smp_to_stkey(struct sample *smp, struct stktable *t);
struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px,
- struct session *l4, void *l7, unsigned int opt,
+ struct stream *l4, void *l7, unsigned int opt,
struct sample_expr *expr, struct sample *smp);
int stktable_compatible_sample(struct sample_expr *expr, unsigned long table_type);
int stktable_register_data_store(int idx, const char *name, int std_type, int arg_type);
/*
- * include/proto/session.h
- * This file defines everything related to sessions.
+ * include/proto/stream.h
+ * This file defines everything related to streams.
*
* Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
*
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _PROTO_SESSION_H
-#define _PROTO_SESSION_H
+#ifndef _PROTO_STREAM_H
+#define _PROTO_STREAM_H
#include <common/config.h>
#include <common/memory.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <proto/fd.h>
#include <proto/freq_ctr.h>
#include <proto/stick_table.h>
#include <proto/task.h>
-extern struct pool_head *pool2_session;
-extern struct list sessions;
+extern struct pool_head *pool2_stream;
+extern struct list streams;
extern struct list buffer_wq;
extern struct data_cb sess_conn_cb;
-int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr);
+int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr);
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_session();
+int init_stream();
-/* kill a session and set the termination flags to <why> (one of SN_ERR_*) */
-void session_shutdown(struct session *session, int why);
+/* kill a stream and set the termination flags to <why> (one of SN_ERR_*) */
+void stream_shutdown(struct stream *stream, int why);
-void session_process_counters(struct session *s);
-void sess_change_server(struct session *sess, struct server *newsrv);
-struct task *process_session(struct task *t);
-void default_srv_error(struct session *s, struct stream_interface *si);
-struct stkctr *smp_fetch_sc_stkctr(struct session *l4, const struct arg *args, const char *kw);
+void stream_process_counters(struct stream *s);
+void sess_change_server(struct stream *sess, struct server *newsrv);
+struct task *process_stream(struct task *t);
+void default_srv_error(struct stream *s, struct stream_interface *si);
+struct stkctr *smp_fetch_sc_stkctr(struct stream *l4, const struct arg *args, const char *kw);
int parse_track_counters(char **args, int *arg,
int section_type, struct proxy *curpx,
struct track_ctr_prm *prm,
struct proxy *defpx, char **err);
-/* Update the session's backend and server time stats */
-void session_update_time_stats(struct session *s);
-void __session_offer_buffers(int rqlimit);
-static inline void session_offer_buffers();
-int session_alloc_work_buffer(struct session *s);
-void session_release_buffers(struct session *s);
-int session_alloc_recv_buffer(struct channel *chn);
+/* Update the stream's backend and server time stats */
+void stream_update_time_stats(struct stream *s);
+void __stream_offer_buffers(int rqlimit);
+static inline void stream_offer_buffers();
+int stream_alloc_work_buffer(struct stream *s);
+void stream_release_buffers(struct stream *s);
+int stream_alloc_recv_buffer(struct channel *chn);
/* sets the stick counter's entry pointer */
static inline void stkctr_set_entry(struct stkctr *stkctr, struct stksess *entry)
stkctr->entry = caddr_clr_flags(stkctr->entry, flags);
}
-/* Remove the refcount from the session to the tracked counters, and clear the
+/* Remove the refcount from the stream to the tracked counters, and clear the
* pointer to ensure this is only performed once. The caller is responsible for
* ensuring that the pointer is valid first.
*/
-static inline void session_store_counters(struct session *s)
+static inline void stream_store_counters(struct stream *s)
{
void *ptr;
int i;
}
}
-/* Remove the refcount from the session counters tracked at the content level if
+/* Remove the refcount from the stream counters tracked at the content level if
* any, and clear the pointer to ensure this is only performed once. The caller
* is responsible for ensuring that the pointer is valid first.
*/
-static inline void session_stop_content_counters(struct session *s)
+static inline void stream_stop_content_counters(struct stream *s)
{
void *ptr;
int i;
* <t>. The caller is responsible for ensuring that <t> and <ts> are valid
* pointers, and for calling this only once per connection.
*/
-static inline void session_start_counters(struct stktable *t, struct stksess *ts)
+static inline void stream_start_counters(struct stktable *t, struct stksess *ts)
{
void *ptr;
ts->expire = tick_add(now_ms, MS_TO_TICKS(t->expire));
}
-/* Enable tracking of session counters as <stkctr> on stksess <ts>. The caller is
+/* Enable tracking of stream counters as <stkctr> on stksess <ts>. The caller is
* responsible for ensuring that <t> and <ts> are valid pointers. Some controls
* are performed to ensure the state can still change.
*/
-static inline void session_track_stkctr(struct stkctr *ctr, struct stktable *t, struct stksess *ts)
+static inline void stream_track_stkctr(struct stkctr *ctr, struct stktable *t, struct stksess *ts)
{
if (stkctr_entry(ctr))
return;
ts->ref_cnt++;
ctr->table = t;
stkctr_set_entry(ctr, ts);
- session_start_counters(t, ts);
+ stream_start_counters(t, ts);
}
/* Increase the number of cumulated HTTP requests in the tracked counters */
-static void inline session_inc_http_req_ctr(struct session *s)
+static void inline stream_inc_http_req_ctr(struct stream *s)
{
void *ptr;
int i;
}
/* Increase the number of cumulated HTTP requests in the backend's tracked counters */
-static void inline session_inc_be_http_req_ctr(struct session *s)
+static void inline stream_inc_be_http_req_ctr(struct stream *s)
{
void *ptr;
int i;
* Note that even 404 are interesting because they're generally caused by
* vulnerability scans.
*/
-static void inline session_inc_http_err_ctr(struct session *s)
+static void inline stream_inc_http_err_ctr(struct stream *s)
{
void *ptr;
int i;
}
}
-static void inline session_add_srv_conn(struct session *sess, struct server *srv)
+static void inline stream_add_srv_conn(struct stream *sess, struct server *srv)
{
sess->srv_conn = srv;
LIST_ADD(&srv->actconns, &sess->by_srv);
}
-static void inline session_del_srv_conn(struct session *sess)
+static void inline stream_del_srv_conn(struct stream *sess)
{
if (!sess->srv_conn)
return;
LIST_DEL(&sess->by_srv);
}
-static void inline session_init_srv_conn(struct session *sess)
+static void inline stream_init_srv_conn(struct stream *sess)
{
sess->srv_conn = NULL;
LIST_INIT(&sess->by_srv);
}
-static inline void session_offer_buffers()
+static inline void stream_offer_buffers()
{
int avail;
if (LIST_ISEMPTY(&buffer_wq))
return;
- /* all sessions will need 1 buffer, so we can stop waking up sessions
+ /* all streams will need 1 buffer, so we can stop waking up streams
* once we have enough of them to eat all the buffers. Note that we
- * don't really know if they are sessions or just other tasks, but
+ * don't really know if they are streams or just other tasks, but
* that's a rough estimate. Similarly, for each cached event we'll need
* 1 buffer. If no buffer is currently used, always wake up the number
* of tasks we can offer a buffer based on what is allocated, and in
avail = pool2_buffer->allocated - pool2_buffer->used - global.tune.reserved_bufs / 2;
if (avail > (int)run_queue)
- __session_offer_buffers(avail);
+ __stream_offer_buffers(avail);
}
-#endif /* _PROTO_SESSION_H */
+#endif /* _PROTO_STREAM_H */
/*
* Local variables:
#include <stdlib.h>
#include <common/config.h>
-#include <types/session.h>
+#include <types/stream.h>
#include <types/stream_interface.h>
#include <proto/channel.h>
#include <proto/connection.h>
static inline struct channel *si_ic(struct stream_interface *si)
{
if (si->flags & SI_FL_ISBACK)
- return &LIST_ELEM(si, struct session *, si[1])->res;
+ return &LIST_ELEM(si, struct stream *, si[1])->res;
else
- return &LIST_ELEM(si, struct session *, si[0])->req;
+ return &LIST_ELEM(si, struct stream *, si[0])->req;
}
/* returns the channel which feeds data to this stream interface (output channel) */
static inline struct channel *si_oc(struct stream_interface *si)
{
if (si->flags & SI_FL_ISBACK)
- return &LIST_ELEM(si, struct session *, si[1])->req;
+ return &LIST_ELEM(si, struct stream *, si[1])->req;
else
- return &LIST_ELEM(si, struct session *, si[0])->res;
+ return &LIST_ELEM(si, struct stream *, si[0])->res;
}
/* returns the buffer which receives data from this stream interface (input channel's buffer) */
return si_oc(si)->buf;
}
-/* returns the session associated to a stream interface */
-static inline struct session *si_sess(struct stream_interface *si)
+/* returns the stream associated to a stream interface */
+static inline struct stream *si_strm(struct stream_interface *si)
{
if (si->flags & SI_FL_ISBACK)
- return LIST_ELEM(si, struct session *, si[1]);
+ return LIST_ELEM(si, struct stream *, si[1]);
else
- return LIST_ELEM(si, struct session *, si[0]);
+ return LIST_ELEM(si, struct stream *, si[0]);
}
/* returns the task associated to this stream interface */
static inline struct task *si_task(struct stream_interface *si)
{
if (si->flags & SI_FL_ISBACK)
- return LIST_ELEM(si, struct session *, si[1])->task;
+ return LIST_ELEM(si, struct stream *, si[1])->task;
else
- return LIST_ELEM(si, struct session *, si[0])->task;
+ return LIST_ELEM(si, struct stream *, si[0])->task;
}
/* returns the stream interface on the other side. Used during forwarding. */
static inline struct stream_interface *si_opposite(struct stream_interface *si)
{
if (si->flags & SI_FL_ISBACK)
- return &LIST_ELEM(si, struct session *, si[1])->si[0];
+ return &LIST_ELEM(si, struct stream *, si[1])->si[0];
else
- return &LIST_ELEM(si, struct session *, si[0])->si[1];
+ return &LIST_ELEM(si, struct stream *, si[0])->si[1];
}
/* Initializes all required fields for a new appctx. Note that it does the
/* some dummy declarations to silent the compiler */
struct proxy;
-struct session;
+struct stream;
/*
* ACL keyword: Associates keywords with parsers, methods to retrieve the value and testers.
#define CLASS_CHANNEL "Channel"
#define CLASS_HTTP "HTTP"
-struct session;
+struct stream;
#define HLUA_RUN 0x00000001
#define HLUA_CTRLYIELD 0x00000002
* associated with the lua object called "TXN".
*/
struct hlua_txn {
- struct session *s;
+ struct stream *s;
struct proxy *p;
void *l7;
};
/* This struc is used with sample fetches and sample converters. */
struct hlua_smp {
- struct session *s;
+ struct stream *s;
struct proxy *p;
void *l7;
int stringsafe;
};
/* This struct is used to create coprocess doing TCP or
- * SSL I/O. It uses a fake session.
+ * SSL I/O. It uses a fake stream.
*/
struct hlua_socket {
- struct session *s; /* Session used for socket I/O. */
+ struct stream *s; /* Stream used for socket I/O. */
luaL_Buffer b; /* buffer used to prepare strings. */
};
struct peer_session {
struct shared_table *table; /* shared table */
struct peer *peer; /* current peer */
- struct session *session; /* current transport session */
+ struct stream *stream; /* current transport stream */
unsigned int flags; /* peer session flags */
unsigned int statuscode; /* current/last session status code */
unsigned int update; /* current peer acked update */
#define TX_CLALLOW 0x00000002 /* a client header matches an allow regex */
#define TX_SVDENY 0x00000004 /* a server header matches a deny regex */
#define TX_SVALLOW 0x00000008 /* a server header matches an allow regex */
-#define TX_CLTARPIT 0x00000010 /* the session is tarpitted (anti-dos) */
+#define TX_CLTARPIT 0x00000010 /* the transaction is tarpitted (anti-dos) */
/* transaction flags dedicated to cookies : bits values 0x20 to 0x80 (0-7 shift 5) */
-#define TX_CK_NONE 0x00000000 /* this session had no cookie */
-#define TX_CK_INVALID 0x00000020 /* this session had a cookie which matches no server */
-#define TX_CK_DOWN 0x00000040 /* this session had cookie matching a down server */
-#define TX_CK_VALID 0x00000060 /* this session had cookie matching a valid server */
-#define TX_CK_EXPIRED 0x00000080 /* this session had an expired cookie (idle for too long) */
-#define TX_CK_OLD 0x000000A0 /* this session had too old a cookie (offered too long ago) */
-#define TX_CK_UNUSED 0x000000C0 /* this session had a cookie but it was not used (eg: use-server was preferred) */
-#define TX_CK_MASK 0x000000E0 /* mask to get this session's cookie flags */
+#define TX_CK_NONE 0x00000000 /* this transaction had no cookie */
+#define TX_CK_INVALID 0x00000020 /* this transaction had a cookie which matches no server */
+#define TX_CK_DOWN 0x00000040 /* this transaction had cookie matching a down server */
+#define TX_CK_VALID 0x00000060 /* this transaction had cookie matching a valid server */
+#define TX_CK_EXPIRED 0x00000080 /* this transaction had an expired cookie (idle for too long) */
+#define TX_CK_OLD 0x000000A0 /* this transaction had too old a cookie (offered too long ago) */
+#define TX_CK_UNUSED 0x000000C0 /* this transaction had a cookie but it was not used (eg: use-server was preferred) */
+#define TX_CK_MASK 0x000000E0 /* mask to get this transaction's cookie flags */
#define TX_CK_SHIFT 5 /* bit shift */
/* response cookie information, bits values 0x100 to 0x700 (0-7 shift 8) */
struct proxy;
struct http_txn;
-struct session;
+struct stream;
struct http_req_rule {
struct list list;
struct acl_cond *cond; /* acl condition to meet */
unsigned int action; /* HTTP_REQ_* */
- int (*action_ptr)(struct http_req_rule *rule, struct proxy *px, struct session *s, struct http_txn *http_txn); /* ptr to custom action */
+ int (*action_ptr)(struct http_req_rule *rule, struct proxy *px, struct stream *s, struct http_txn *http_txn); /* ptr to custom action */
union {
struct {
char *realm;
struct list list;
struct acl_cond *cond; /* acl condition to meet */
unsigned int action; /* HTTP_RES_* */
- int (*action_ptr)(struct http_res_rule *rule, struct proxy *px, struct session *s, struct http_txn *http_txn); /* ptr to custom action */
+ int (*action_ptr)(struct http_res_rule *rule, struct proxy *px, struct stream *s, struct http_txn *http_txn); /* ptr to custom action */
union {
struct {
char *name; /* header name */
#include <common/mini-clist.h>
#include <types/acl.h>
-#include <types/session.h>
+#include <types/stream.h>
/* Layer4 accept/reject rules */
enum {
struct acl_cond *cond;
int action;
int (*action_ptr)(struct tcp_rule *rule, struct proxy *px,
- struct session *s);
+ struct stream *s);
union {
struct track_ctr_prm trk_ctr;
struct capture_prm cap;
/* unused: 0x0800, 0x1000 */
#define PR_O_FF_ALWAYS 0x00002000 /* always set x-forwarded-for */
#define PR_O_PERSIST 0x00004000 /* server persistence stays effective even when server is down */
-#define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the session to complete */
+#define PR_O_LOGASAP 0x00008000 /* log as soon as possible, without waiting for the stream to complete */
/* unused: 0x00010000 */
#define PR_O_CHK_CACHE 0x00020000 /* require examination of cacheability of the 'set-cookie' field */
-#define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side sessions */
-#define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side sessions */
+#define PR_O_TCP_CLI_KA 0x00040000 /* enable TCP keep-alive on client-side streams */
+#define PR_O_TCP_SRV_KA 0x00080000 /* enable TCP keep-alive on server-side streams */
#define PR_O_USE_ALL_BK 0x00100000 /* load-balance between backup servers */
/* unused: 0x00020000 */
#define PR_O_TCP_NOLING 0x00400000 /* disable lingering on client and server connections */
#define PR_O_HTTP_MODE 0x07000000 /* MASK to retrieve the HTTP mode */
#define PR_O_TCPCHK_SSL 0x08000000 /* at least one TCPCHECK connect rule requires SSL */
#define PR_O_CONTSTATS 0x10000000 /* continous counters */
-#define PR_O_HTTP_PROXY 0x20000000 /* Enable session to use HTTP proxy operations */
+#define PR_O_HTTP_PROXY 0x20000000 /* Enable stream to use HTTP proxy operations */
#define PR_O_DISABLE404 0x40000000 /* Disable a server on a 404 response to a health-check */
#define PR_O_ORGTO 0x80000000 /* insert x-original-to with destination address */
#define STK_IS_STORE 0x00000002 /* store on request fetch */
#define STK_ON_RSP 0x00000004 /* store on response fetch */
-struct session;
+struct stream;
struct error_snapshot {
struct timeval when; /* date of this event, (tv_sec == 0) means "never" */
unsigned int len; /* original length of the last invalid request/response */
unsigned int pos; /* position of the first invalid character */
- unsigned int sid; /* ID of the faulty session */
+ unsigned int sid; /* ID of the faulty stream */
unsigned int ev_id; /* event number (counter incremented for each capture) */
unsigned int state; /* message state before the error (when saved) */
unsigned int b_flags; /* buffer flags */
- unsigned int s_flags; /* session flags */
+ unsigned int s_flags; /* stream flags */
unsigned int t_flags; /* transaction flags */
unsigned int m_flags; /* message flags */
unsigned int b_out; /* pending output bytes */
enum pr_state state; /* proxy state, one of PR_* */
enum pr_mode mode; /* mode = PR_MODE_TCP, PR_MODE_HTTP or PR_MODE_HEALTH */
char cap; /* supported capabilities (PR_CAP_*) */
- unsigned int maxconn; /* max # of active sessions on the frontend */
+ unsigned int maxconn; /* max # of active streams on the frontend */
int options; /* PR_O_REDISP, PR_O_TRANSP, ... */
int options2; /* PR_O2_* */
struct list pendconns; /* pending connections with no server assigned yet */
int nbpend; /* number of pending connections with no server assigned yet */
int totpend; /* total number of pending connections on this instance (for stats) */
- unsigned int feconn, beconn; /* # of active frontend and backends sessions */
+ unsigned int feconn, beconn; /* # of active frontend and backends streams */
struct freq_ctr fe_req_per_sec; /* HTTP requests per second on the frontend */
struct freq_ctr fe_conn_per_sec; /* received connections per second on the frontend */
struct freq_ctr fe_sess_per_sec; /* accepted sessions per second on the frontend (after tcp rules) */
unsigned down_trans; /* up-down transitions */
unsigned down_time; /* total time the proxy was down */
time_t last_change; /* last time, when the state was changed */
- int (*accept)(struct session *s); /* application layer's accept() */
+ int (*accept)(struct stream *s); /* application layer's accept() */
struct conn_src conn_src; /* connection source settings */
- enum obj_type *default_target; /* default target to use for accepted sessions or NULL */
+ enum obj_type *default_target; /* default target to use for accepted streams or NULL */
struct proxy *next;
unsigned int log_count; /* number of logs produced by the frontend */
int nb_req_cap, nb_rsp_cap; /* # of headers to be captured */
struct cap_hdr *req_cap; /* chained list of request headers to be captured */
struct cap_hdr *rsp_cap; /* chained list of response headers to be captured */
- struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the sessions */
+ struct pool_head *req_cap_pool, /* pools of pre-allocated char ** used to build the streams */
*rsp_cap_pool;
struct list req_add, rsp_add; /* headers to be added */
struct pxcounters be_counters; /* backend statistics counters */
struct pxcounters fe_counters; /* frontend statistics counters */
struct list listener_queue; /* list of the temporarily limited listeners because of lack of a proxy resource */
- struct stktable table; /* table for storing sticking sessions */
+ struct stktable table; /* table for storing sticking streams */
struct task *task; /* the associated task, mandatory to manage rate limiting, stopping and resource shortage, NULL if disabled */
struct list tcpcheck_rules; /* tcp-check send / expect rules */
#include <types/server.h>
-struct session;
+struct stream;
struct pendconn {
struct list list; /* chaining ... */
- struct session *sess; /* the session waiting for a connection */
+ struct stream *strm; /* the stream waiting for a connection */
struct server *srv; /* the server we are waiting for */
};
SMP_SRC_RQFIN, /* final information about request buffer (eg: tot bytes) */
SMP_SRC_RSFIN, /* final information about response buffer (eg: tot bytes) */
SMP_SRC_TXFIN, /* final information about the transaction (eg: #comp rate) */
- SMP_SRC_SSFIN, /* final information about the session (eg: #requests, final flags) */
+ SMP_SRC_SSFIN, /* final information about the stream (eg: #requests, final flags) */
SMP_SRC_ENTRIES /* nothing after this */
};
*/
enum {
SMP_CKP_FE_CON_ACC, /* FE connection accept rules ("tcp request connection") */
- SMP_CKP_FE_SES_ACC, /* FE session accept rules (to come soon) */
+ SMP_CKP_FE_SES_ACC, /* FE stream accept rules (to come soon) */
SMP_CKP_FE_REQ_CNT, /* FE request content rules ("tcp request content") */
SMP_CKP_FE_HRQ_HDR, /* FE HTTP request headers (rules, headers, monitor, stats, redirect) */
SMP_CKP_FE_HRQ_BDY, /* FE HTTP request body */
SMP_CKP_FE_RES_CNT, /* FE response content rules ("tcp response content") */
SMP_CKP_FE_HRS_HDR, /* FE HTTP response headers (rules, headers) */
SMP_CKP_FE_HRS_BDY, /* FE HTTP response body */
- SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/session */
+ SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/stream */
SMP_CKP_ENTRIES /* nothing after this */
};
SMP_USE_RQFIN = 1 << SMP_SRC_RQFIN, /* final information about request buffer (eg: tot bytes) */
SMP_USE_RSFIN = 1 << SMP_SRC_RSFIN, /* final information about response buffer (eg: tot bytes) */
SMP_USE_TXFIN = 1 << SMP_SRC_TXFIN, /* final information about the transaction (eg: #comp rate) */
- SMP_USE_SSFIN = 1 << SMP_SRC_SSFIN, /* final information about the session (eg: #requests, final flags) */
+ SMP_USE_SSFIN = 1 << SMP_SRC_SSFIN, /* final information about the stream (eg: #requests, final flags) */
/* This composite one is useful to detect if an hdr_idx needs to be allocated */
SMP_USE_HTTP_ANY = SMP_USE_HRQHV | SMP_USE_HRQHP | SMP_USE_HRQBO |
enum {
SMP_VAL___________ = 0, /* Just used as a visual marker */
SMP_VAL_FE_CON_ACC = 1 << SMP_CKP_FE_CON_ACC, /* FE connection accept rules ("tcp request connection") */
- SMP_VAL_FE_SES_ACC = 1 << SMP_CKP_FE_SES_ACC, /* FE session accept rules (to come soon) */
+ SMP_VAL_FE_SES_ACC = 1 << SMP_CKP_FE_SES_ACC, /* FE stream accept rules (to come soon) */
SMP_VAL_FE_REQ_CNT = 1 << SMP_CKP_FE_REQ_CNT, /* FE request content rules ("tcp request content") */
SMP_VAL_FE_HRQ_HDR = 1 << SMP_CKP_FE_HRQ_HDR, /* FE HTTP request headers (rules, headers, monitor, stats, redirect) */
SMP_VAL_FE_HRQ_BDY = 1 << SMP_CKP_FE_HRQ_BDY, /* FE HTTP request body */
SMP_VAL_FE_RES_CNT = 1 << SMP_CKP_FE_RES_CNT, /* FE response content rules ("tcp response content") */
SMP_VAL_FE_HRS_HDR = 1 << SMP_CKP_FE_HRS_HDR, /* FE HTTP response headers (rules, headers) */
SMP_VAL_FE_HRS_BDY = 1 << SMP_CKP_FE_HRS_BDY, /* FE HTTP response body */
- SMP_VAL_FE_LOG_END = 1 << SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/session */
+ SMP_VAL_FE_LOG_END = 1 << SMP_CKP_FE_LOG_END, /* FE log at the end of the txn/stream */
/* a few combinations to decide what direction to try to fetch (useful for logs) */
SMP_VAL_REQUEST = SMP_VAL_FE_CON_ACC | SMP_VAL_FE_SES_ACC | SMP_VAL_FE_REQ_CNT |
};
/* needed below */
-struct session;
+struct stream;
/* a sample context might be used by any sample fetch function in order to
* store information needed across multiple calls (eg: restart point for a
/* Descriptor for a sample conversion */
struct sample_conv {
const char *kw; /* configuration keyword */
- int (*process)(struct session *session,
+ int (*process)(struct stream *stream,
const struct arg *arg_p,
struct sample *smp,
void *private); /* process function */
struct sample_fetch {
const char *kw; /* configuration keyword */
int (*process)(struct proxy *px,
- struct session *l4,
+ struct stream *l4,
void *l7,
unsigned int opt, /* fetch options (SMP_OPT_*) */
const struct arg *arg_p,
+++ /dev/null
-/*
- * include/types/session.h
- * This file defines everything related to sessions.
- *
- * Copyright (C) 2000-2010 Willy Tarreau - w@1wt.eu
- *
- * 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
- */
-
-#ifndef _TYPES_SESSION_H
-#define _TYPES_SESSION_H
-
-
-#include <sys/time.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#include <common/config.h>
-#include <common/mini-clist.h>
-
-#include <types/channel.h>
-#include <types/compression.h>
-#include <types/hlua.h>
-#include <types/obj_type.h>
-#include <types/proto_http.h>
-#include <types/proxy.h>
-#include <types/queue.h>
-#include <types/server.h>
-#include <types/stream_interface.h>
-#include <types/task.h>
-#include <types/stick_table.h>
-
-
-/* various session flags, bits values 0x01 to 0x100 (shift 0) */
-#define SN_DIRECT 0x00000001 /* connection made on the server matching the client cookie */
-#define SN_ASSIGNED 0x00000002 /* no need to assign a server to this session */
-#define SN_ADDR_SET 0x00000004 /* this session's server address has been set */
-#define SN_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */
-
-#define SN_FORCE_PRST 0x00000010 /* force persistence here, even if server is down */
-#define SN_MONITOR 0x00000020 /* this session comes from a monitoring system */
-#define SN_CURR_SESS 0x00000040 /* a connection is currently being counted on the server */
-#define SN_INITIALIZED 0x00000080 /* the session was fully initialized */
-#define SN_REDISP 0x00000100 /* set if this session was redispatched from one server to another */
-#define SN_CONN_TAR 0x00000200 /* set if this session is turning around before reconnecting */
-#define SN_REDIRECTABLE 0x00000400 /* set if this session is redirectable (GET or HEAD) */
-#define SN_TUNNEL 0x00000800 /* tunnel-mode session, nothing to catch after data */
-
-/* session termination conditions, bits values 0x1000 to 0x7000 (0-9 shift 12) */
-#define SN_ERR_NONE 0x00000000 /* normal end of request */
-#define SN_ERR_LOCAL 0x00001000 /* the proxy locally processed this request => not an error */
-#define SN_ERR_CLITO 0x00002000 /* client time-out */
-#define SN_ERR_CLICL 0x00003000 /* client closed (read/write error) */
-#define SN_ERR_SRVTO 0x00004000 /* server time-out, connect time-out */
-#define SN_ERR_SRVCL 0x00005000 /* server closed (connect/read/write error) */
-#define SN_ERR_PRXCOND 0x00006000 /* the proxy decided to close (deny...) */
-#define SN_ERR_RESOURCE 0x00007000 /* the proxy encountered a lack of a local resources (fd, mem, ...) */
-#define SN_ERR_INTERNAL 0x00008000 /* the proxy encountered an internal error */
-#define SN_ERR_DOWN 0x00009000 /* the proxy killed a session because the backend became unavailable */
-#define SN_ERR_KILLED 0x0000a000 /* the proxy killed a session because it was asked to do so */
-#define SN_ERR_UP 0x0000b000 /* the proxy killed a session because a preferred backend became available */
-#define SN_ERR_MASK 0x0000f000 /* mask to get only session error flags */
-#define SN_ERR_SHIFT 12 /* bit shift */
-
-/* session state at termination, bits values 0x10000 to 0x70000 (0-7 shift 16) */
-#define SN_FINST_R 0x00010000 /* session ended during client request */
-#define SN_FINST_C 0x00020000 /* session ended during server connect */
-#define SN_FINST_H 0x00030000 /* session ended during server headers */
-#define SN_FINST_D 0x00040000 /* session ended during data phase */
-#define SN_FINST_L 0x00050000 /* session ended while pushing last data to client */
-#define SN_FINST_Q 0x00060000 /* session ended while waiting in queue for a server slot */
-#define SN_FINST_T 0x00070000 /* session ended tarpitted */
-#define SN_FINST_MASK 0x00070000 /* mask to get only final session state flags */
-#define SN_FINST_SHIFT 16 /* bit shift */
-
-#define SN_IGNORE_PRST 0x00080000 /* ignore persistence */
-
-#define SN_COMP_READY 0x00100000 /* the compression is initialized */
-#define SN_SRV_REUSED 0x00200000 /* the server-side connection was reused */
-
-/*
- * Note: some session flags have dependencies :
- * - SN_DIRECT cannot exist without SN_ASSIGNED, because a server is
- * immediately assigned when SN_DIRECT is determined. Both must be cleared
- * when clearing SN_DIRECT (eg: redispatch).
- * - ->srv has no meaning without SN_ASSIGNED and must not be checked without
- * it. ->target may be used to check previous ->srv after a failed connection attempt.
- * - a session being processed has srv_conn set.
- * - srv_conn might remain after SN_DIRECT has been reset, but the assigned
- * server should eventually be released.
- */
-struct session {
- int flags; /* some flags describing the session */
- unsigned int uniq_id; /* unique ID used for the traces */
- enum obj_type *target; /* target to use for this session ; for mini-sess: incoming connection */
-
- struct channel req; /* request channel */
- struct channel res; /* response channel */
-
- struct proxy *fe; /* the proxy this session depends on for the client side */
- struct proxy *be; /* the proxy this session depends on for the server side */
-
- struct listener *listener; /* the listener by which the request arrived */
- struct server *srv_conn; /* session already has a slot on a server and is not in queue */
- struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
-
- struct http_txn txn; /* current HTTP transaction being processed. Should become a list. */
-
- struct task *task; /* the task associated with this session */
- struct list list; /* position in global sessions list */
- struct list by_srv; /* position in server session list */
- struct list back_refs; /* list of users tracking this session */
- struct list buffer_wait; /* position in the list of sessions waiting for a buffer */
-
- struct {
- struct stksess *ts;
- struct stktable *table;
- } store[8]; /* tracked stickiness values to store */
- int store_count;
- /* 4 unused bytes here */
-
- struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters */
-
- struct stream_interface si[2]; /* client and server stream interfaces */
- struct {
- int logwait; /* log fields waiting to be collected : LW_* */
- int level; /* log level to force + 1 if > 0, -1 = no log */
- struct timeval accept_date; /* date of the accept() in user date */
- struct timeval tv_accept; /* date of the accept() in internal date (monotonic) */
- struct timeval tv_request; /* date the request arrives, {0,0} if never occurs */
- long t_queue; /* delay before the session gets out of the connect queue, -1 if never occurs */
- long t_connect; /* delay before the connect() to the server succeeds, -1 if never occurs */
- long t_data; /* delay before the first data byte from the server ... */
- unsigned long t_close; /* total session duration */
- unsigned long srv_queue_size; /* number of sessions waiting for a connect slot on this server at accept() time (in direct assignment) */
- unsigned long prx_queue_size; /* overall number of sessions waiting for a connect slot on this instance at accept() time */
- long long bytes_in; /* number of bytes transferred from the client to the server */
- long long bytes_out; /* number of bytes transferred from the server to the client */
- } logs;
- void (*do_log)(struct session *s); /* the function to call in order to log (or NULL) */
- void (*srv_error)(struct session *s, /* the function to call upon unrecoverable server errors (or NULL) */
- struct stream_interface *si);
- struct comp_ctx *comp_ctx; /* HTTP compression context */
- struct comp_algo *comp_algo; /* HTTP compression algorithm if not NULL */
- char *unique_id; /* custom unique ID */
-
- /* These two pointers are used to resume the execution of the rule lists. */
- struct list *current_rule_list; /* this is used to store the current executed rule list. */
- struct list *current_rule; /* this is used to store the current rule to be resumed. */
-
- struct hlua hlua; /* lua runtime context */
-};
-
-#endif /* _TYPES_SESSION_H */
-
-/*
- * Local variables:
- * c-indent-level: 8
- * c-basic-offset: 8
- * End:
- */
/* The types of extra data we can store in a stick table */
enum {
- STKTABLE_DT_SERVER_ID, /* the server ID to use with this session if > 0 */
+ STKTABLE_DT_SERVER_ID, /* the server ID to use with this stream if > 0 */
STKTABLE_DT_GPC0, /* General Purpose Counter 0 (unsigned 32-bit integer) */
STKTABLE_DT_GPC0_RATE, /* General Purpose Counter 0's event rate */
STKTABLE_DT_CONN_CNT, /* cumulated number of connections */
union stktable_key_data data; /* data, must always be last */
};
-/* WARNING: if new fields are added, they must be initialized in session_accept()
- * and freed in session_free() !
+/* WARNING: if new fields are added, they must be initialized in stream_accept()
+ * and freed in stream_free() !
*/
#define STKCTR_TRACK_BACKEND 1
#define STKCTR_TRACK_CONTENT 2
* pointer to an stksess struct, and two flags among STKCTR_TRACK_* above.
*/
struct stkctr {
- unsigned long entry; /* entry containing counters currently being tracked by this session */
+ unsigned long entry; /* entry containing counters currently being tracked by this stream */
struct stktable *table; /* table the counters above belong to (undefined if counters are null) */
};
--- /dev/null
+/*
+ * include/types/stream.h
+ * This file defines everything related to streams.
+ *
+ * Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
+ *
+ * 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
+ */
+
+#ifndef _TYPES_STREAM_H
+#define _TYPES_STREAM_H
+
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include <common/config.h>
+#include <common/mini-clist.h>
+
+#include <types/channel.h>
+#include <types/compression.h>
+#include <types/hlua.h>
+#include <types/obj_type.h>
+#include <types/proto_http.h>
+#include <types/proxy.h>
+#include <types/queue.h>
+#include <types/server.h>
+#include <types/stream_interface.h>
+#include <types/task.h>
+#include <types/stick_table.h>
+
+
+/* various stream flags, bits values 0x01 to 0x100 (shift 0) */
+#define SN_DIRECT 0x00000001 /* connection made on the server matching the client cookie */
+#define SN_ASSIGNED 0x00000002 /* no need to assign a server to this stream */
+#define SN_ADDR_SET 0x00000004 /* this stream's server address has been set */
+#define SN_BE_ASSIGNED 0x00000008 /* a backend was assigned. Conns are accounted. */
+
+#define SN_FORCE_PRST 0x00000010 /* force persistence here, even if server is down */
+#define SN_MONITOR 0x00000020 /* this stream comes from a monitoring system */
+#define SN_CURR_SESS 0x00000040 /* a connection is currently being counted on the server */
+#define SN_INITIALIZED 0x00000080 /* the stream was fully initialized */
+#define SN_REDISP 0x00000100 /* set if this stream was redispatched from one server to another */
+#define SN_CONN_TAR 0x00000200 /* set if this stream is turning around before reconnecting */
+#define SN_REDIRECTABLE 0x00000400 /* set if this stream is redirectable (GET or HEAD) */
+#define SN_TUNNEL 0x00000800 /* tunnel-mode stream, nothing to catch after data */
+
+/* stream termination conditions, bits values 0x1000 to 0x7000 (0-9 shift 12) */
+#define SN_ERR_NONE 0x00000000 /* normal end of request */
+#define SN_ERR_LOCAL 0x00001000 /* the proxy locally processed this request => not an error */
+#define SN_ERR_CLITO 0x00002000 /* client time-out */
+#define SN_ERR_CLICL 0x00003000 /* client closed (read/write error) */
+#define SN_ERR_SRVTO 0x00004000 /* server time-out, connect time-out */
+#define SN_ERR_SRVCL 0x00005000 /* server closed (connect/read/write error) */
+#define SN_ERR_PRXCOND 0x00006000 /* the proxy decided to close (deny...) */
+#define SN_ERR_RESOURCE 0x00007000 /* the proxy encountered a lack of a local resources (fd, mem, ...) */
+#define SN_ERR_INTERNAL 0x00008000 /* the proxy encountered an internal error */
+#define SN_ERR_DOWN 0x00009000 /* the proxy killed a stream because the backend became unavailable */
+#define SN_ERR_KILLED 0x0000a000 /* the proxy killed a stream because it was asked to do so */
+#define SN_ERR_UP 0x0000b000 /* the proxy killed a stream because a preferred backend became available */
+#define SN_ERR_MASK 0x0000f000 /* mask to get only stream error flags */
+#define SN_ERR_SHIFT 12 /* bit shift */
+
+/* stream state at termination, bits values 0x10000 to 0x70000 (0-7 shift 16) */
+#define SN_FINST_R 0x00010000 /* stream ended during client request */
+#define SN_FINST_C 0x00020000 /* stream ended during server connect */
+#define SN_FINST_H 0x00030000 /* stream ended during server headers */
+#define SN_FINST_D 0x00040000 /* stream ended during data phase */
+#define SN_FINST_L 0x00050000 /* stream ended while pushing last data to client */
+#define SN_FINST_Q 0x00060000 /* stream ended while waiting in queue for a server slot */
+#define SN_FINST_T 0x00070000 /* stream ended tarpitted */
+#define SN_FINST_MASK 0x00070000 /* mask to get only final stream state flags */
+#define SN_FINST_SHIFT 16 /* bit shift */
+
+#define SN_IGNORE_PRST 0x00080000 /* ignore persistence */
+
+#define SN_COMP_READY 0x00100000 /* the compression is initialized */
+#define SN_SRV_REUSED 0x00200000 /* the server-side connection was reused */
+
+/* some external definitions */
+struct strm_logs {
+ int logwait; /* log fields waiting to be collected : LW_* */
+ int level; /* log level to force + 1 if > 0, -1 = no log */
+ struct timeval accept_date; /* date of the stream's accept() in user date */
+ struct timeval tv_accept; /* date of the stream's accept() in internal date (monotonic) */
+ struct timeval tv_request; /* date the request arrives, {0,0} if never occurs */
+ long t_queue; /* delay before the stream gets out of the connect queue, -1 if never occurs */
+ long t_connect; /* delay before the connect() to the server succeeds, -1 if never occurs */
+ long t_data; /* delay before the first data byte from the server ... */
+ unsigned long t_close; /* total stream duration */
+ unsigned long srv_queue_size; /* number of streams waiting for a connect slot on this server at accept() time (in direct assignment) */
+ unsigned long prx_queue_size; /* overall number of streams waiting for a connect slot on this instance at accept() time */
+ long long bytes_in; /* number of bytes transferred from the client to the server */
+ long long bytes_out; /* number of bytes transferred from the server to the client */
+};
+
+struct stream {
+ int flags; /* some flags describing the stream */
+ unsigned int uniq_id; /* unique ID used for the traces */
+ enum obj_type *target; /* target to use for this stream ; for mini-sess: incoming connection */
+
+ struct channel req; /* request channel */
+ struct channel res; /* response channel */
+
+ struct proxy *fe; /* the proxy this stream depends on for the client side */
+ struct proxy *be; /* the proxy this stream depends on for the server side */
+
+ struct listener *listener; /* the listener by which the request arrived */
+ struct server *srv_conn; /* stream already has a slot on a server and is not in queue */
+ struct pendconn *pend_pos; /* if not NULL, points to the position in the pending queue */
+
+ struct http_txn txn; /* current HTTP transaction being processed. Should become a list. */
+
+ struct task *task; /* the task associated with this stream */
+ struct list list; /* position in global streams list */
+ struct list by_srv; /* position in server stream list */
+ struct list back_refs; /* list of users tracking this stream */
+ struct list buffer_wait; /* position in the list of streams waiting for a buffer */
+
+ struct {
+ struct stksess *ts;
+ struct stktable *table;
+ } store[8]; /* tracked stickiness values to store */
+ int store_count;
+ /* 4 unused bytes here */
+
+ struct stkctr stkctr[MAX_SESS_STKCTR]; /* stick counters */
+
+ struct stream_interface si[2]; /* client and server stream interfaces */
+ struct strm_logs logs; /* logs for this stream */
+
+ void (*do_log)(struct stream *s); /* the function to call in order to log (or NULL) */
+ void (*srv_error)(struct stream *s, /* the function to call upon unrecoverable server errors (or NULL) */
+ struct stream_interface *si);
+ struct comp_ctx *comp_ctx; /* HTTP compression context */
+ struct comp_algo *comp_algo; /* HTTP compression algorithm if not NULL */
+ char *unique_id; /* custom unique ID */
+
+ /* These two pointers are used to resume the execution of the rule lists. */
+ struct list *current_rule_list; /* this is used to store the current executed rule list. */
+ struct list *current_rule; /* this is used to store the current rule to be resumed. */
+ struct hlua hlua; /* lua runtime context */
+};
+
+#endif /* _TYPES_STREAM_H */
+
+/*
+ * Local variables:
+ * c-indent-level: 8
+ * c-basic-offset: 8
+ * End:
+ */
* if (cond->pol == ACL_COND_UNLESS)
* res = !res;
*/
-enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct session *l4, void *l7, unsigned int opt)
+enum acl_test_res acl_exec_cond(struct acl_cond *cond, struct proxy *px, struct stream *l4, void *l7, unsigned int opt)
{
__label__ fetch_next;
struct acl_term_suite *suite;
#include <proto/queue.h>
#include <proto/sample.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/raw_sock.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
/*
* this does the same as the previous server_ph, but check the body contents
*/
-struct server *get_server_ph_post(struct session *s)
+struct server *get_server_ph_post(struct stream *s)
{
unsigned int hash = 0;
struct http_txn *txn = &s->txn;
* is returned. If any server is found, it will be returned. If no valid server
* is found, NULL is returned.
*/
-struct server *get_server_hh(struct session *s)
+struct server *get_server_hh(struct stream *s)
{
unsigned int hash = 0;
struct http_txn *txn = &s->txn;
}
/* RDP Cookie HASH. */
-struct server *get_server_rch(struct session *s)
+struct server *get_server_rch(struct stream *s)
{
unsigned int hash = 0;
struct proxy *px = s->be;
}
/*
- * This function applies the load-balancing algorithm to the session, as
- * defined by the backend it is assigned to. The session is then marked as
+ * This function applies the load-balancing algorithm to the stream, as
+ * defined by the backend it is assigned to. The stream is then marked as
* 'assigned'.
*
- * This function MAY NOT be called with SN_ASSIGNED already set. If the session
+ * This function MAY NOT be called with SN_ASSIGNED already set. If the stream
* had a server previously assigned, it is rebalanced, trying to avoid the same
* server, which should still be present in target_srv(&s->target) before the call.
* The function tries to keep the original connection slot if it reconnects to
* the same server, otherwise it releases it and tries to offer it.
*
- * It is illegal to call this function with a session in a queue.
+ * It is illegal to call this function with a stream in a queue.
*
* It may return :
* SRV_STATUS_OK if everything is OK. ->srv and ->target are assigned.
- * SRV_STATUS_NOSRV if no server is available. Session is not ASSIGNED
- * SRV_STATUS_FULL if all servers are saturated. Session is not ASSIGNED
+ * SRV_STATUS_NOSRV if no server is available. Stream is not ASSIGNED
+ * SRV_STATUS_FULL if all servers are saturated. Stream is not ASSIGNED
* SRV_STATUS_INTERNAL for other unrecoverable errors.
*
- * Upon successful return, the session flag SN_ASSIGNED is set to indicate that
+ * Upon successful return, the stream flag SN_ASSIGNED is set to indicate that
* it does not need to be called anymore. This means that target_srv(&s->target)
* can be trusted in balance and direct modes.
*
*/
-int assign_server(struct session *s)
+int assign_server(struct stream *s)
{
struct connection *conn;
struct server *conn_slot;
server_has_room(__objt_server(conn->target)) ||
(__objt_server(conn->target)->nbpend + 1) < s->be->max_ka_queue))) &&
srv_is_usable(__objt_server(conn->target))) {
- /* This session was relying on a server in a previous request
+ /* This stream was relying on a server in a previous request
* and the proxy has "option prefer-last-server" set, so
* let's try to reuse the same server.
*/
}
/*
- * This function assigns a server address to a session, and sets SN_ADDR_SET.
+ * This function assigns a server address to a stream, and sets SN_ADDR_SET.
* The address is taken from the currently assigned server, or from the
* dispatch or transparent address.
*
* SRV_STATUS_OK if everything is OK.
* SRV_STATUS_INTERNAL for other unrecoverable errors.
*
- * Upon successful return, the session flag SN_ADDR_SET is set. This flag is
+ * Upon successful return, the stream flag SN_ADDR_SET is set. This flag is
* not cleared, so it's to the caller to clear it if required.
*
* The caller is responsible for having already assigned a connection
* to si->end.
*
*/
-int assign_server_address(struct session *s)
+int assign_server_address(struct stream *s)
{
struct connection *cli_conn = objt_conn(s->si[0].end);
struct connection *srv_conn = objt_conn(s->si[1].end);
#endif
if ((s->flags & SN_DIRECT) || (s->be->lbprm.algo & BE_LB_KIND)) {
- /* A server is necessarily known for this session */
+ /* A server is necessarily known for this stream */
if (!(s->flags & SN_ASSIGNED))
return SRV_STATUS_INTERNAL;
return SRV_STATUS_OK;
}
-/* This function assigns a server to session <s> if required, and can add the
+/* This function assigns a server to stream <s> if required, and can add the
* connection to either the assigned server's queue or to the proxy's queue.
- * If ->srv_conn is set, the session is first released from the server.
+ * If ->srv_conn is set, the stream is first released from the server.
* It may also be called with SN_DIRECT and/or SN_ASSIGNED though. It will
* be called before any connection and after any retry or redispatch occurs.
*
- * It is not allowed to call this function with a session in a queue.
+ * It is not allowed to call this function with a stream in a queue.
*
* Returns :
*
* SRV_STATUS_INTERNAL for other unrecoverable errors.
*
*/
-int assign_server_and_queue(struct session *s)
+int assign_server_and_queue(struct stream *s)
{
struct pendconn *p;
struct server *srv;
err = assign_server(s);
if (prev_srv) {
- /* This session was previously assigned to a server. We have to
- * update the session's and the server's stats :
+ /* This stream was previously assigned to a server. We have to
+ * update the stream's and the server's stats :
* - if the server changed :
* - set TX_CK_DOWN if txn.flags was TX_CK_VALID
* - set SN_REDISP if it was successfully redispatched
if (s->srv_conn == srv)
return SRV_STATUS_OK;
- /* OK, this session already has an assigned server, but no
+ /* OK, this stream already has an assigned server, but no
* connection slot yet. Either it is a redispatch, or it was
* assigned from persistence information (direct mode).
*/
return SRV_STATUS_OK;
}
- /* We might have to queue this session if the assigned server is full.
+ /* We might have to queue this stream if the assigned server is full.
* We know we have to queue it into the server's queue, so if a maxqueue
* is set on the server, we must also check that the server's queue is
* not full, in which case we have to return FULL.
return SRV_STATUS_OK;
case SRV_STATUS_FULL:
- /* queue this session into the proxy's queue */
+ /* queue this stream into the proxy's queue */
p = pendconn_add(s);
if (p)
return SRV_STATUS_QUEUED;
/* If an explicit source binding is specified on the server and/or backend, and
* this source makes use of the transparent proxy, then it is extracted now and
- * assigned to the session's pending connection. This function assumes that an
+ * assigned to the stream's pending connection. This function assumes that an
* outgoing connection has already been assigned to s->si[1].end.
*/
-static void assign_tproxy_address(struct session *s)
+static void assign_tproxy_address(struct stream *s)
{
#if defined(CONFIG_HAP_CTTPROXY) || defined(CONFIG_HAP_TRANSPARENT)
struct server *srv = objt_server(s->target);
/*
- * This function initiates a connection to the server assigned to this session
+ * This function initiates a connection to the server assigned to this stream
* (s->target, s->si[1].addr.to). It will assign a server if none
* is assigned yet.
* It can return one of :
* The server-facing stream interface is expected to hold a pre-allocated connection
* in s->si[1].conn.
*/
-int connect_server(struct session *s)
+int connect_server(struct stream *s)
{
struct connection *cli_conn;
struct connection *srv_conn;
}
if (!conn_xprt_ready(srv_conn)) {
- /* the target was only on the session, assign it to the SI now */
+ /* the target was only on the stream, assign it to the SI now */
srv_conn->target = s->target;
/* set the correct protocol on the output stream interface */
* that the connection is ready to use.
*/
-int srv_redispatch_connect(struct session *s)
+int srv_redispatch_connect(struct stream *s)
{
struct server *srv;
int conn_err;
case SRV_STATUS_QUEUED:
s->si[1].exp = tick_add_ifset(now_ms, s->be->timeout.queue);
s->si[1].state = SI_ST_QUE;
- /* do nothing else and do not wake any other session up */
+ /* do nothing else and do not wake any other stream up */
return 1;
case SRV_STATUS_INTERNAL:
srv->counters.failed_conns++;
s->be->be_counters.failed_conns++;
- /* release other sessions waiting for this server */
+ /* release other streams waiting for this server */
if (may_dequeue_tasks(srv, s->be))
process_srv_queue(srv);
return 1;
send_log(be, LOG_EMERG, "%s %s has no server available!\n", proxy_type_str(be), be->id);
}
-/* Apply RDP cookie persistence to the current session. For this, the function
+/* Apply RDP cookie persistence to the current stream. For this, the function
* tries to extract an RDP cookie from the request buffer, and look for the
* matching server in the list. If the server is found, it is assigned to the
- * session. This always returns 1, and the analyser removes itself from the
+ * stream. This always returns 1, and the analyser removes itself from the
* list. Nothing is performed if a server was already assigned.
*/
-int tcp_persist_rdp_cookie(struct session *s, struct channel *req, int an_bit)
+int tcp_persist_rdp_cookie(struct stream *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
int ret;
struct sockaddr_in addr;
char *p;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
* undefined behaviour.
*/
static int
-smp_fetch_nbsrv(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_nbsrv(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* undefined behaviour.
*/
static int
-smp_fetch_srv_is_up(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_srv_is_up(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct server *srv = args->data.srv;
* undefined behaviour.
*/
static int
-smp_fetch_connslots(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_connslots(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct server *iterator;
/* set temp integer to the id of the backend */
static int
-smp_fetch_be_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_be_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TXN;
/* set temp integer to the id of the server */
static int
-smp_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_srv_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
if (!objt_server(l4->target))
* undefined behaviour.
*/
static int
-smp_fetch_be_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_be_sess_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* undefined behaviour.
*/
static int
-smp_fetch_be_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_be_conn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* undefined behaviour.
*/
static int
-smp_fetch_queue_size(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_queue_size(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* undefined behaviour.
*/
static int
-smp_fetch_avg_queue_size(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_avg_queue_size(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int nbsrv;
* undefined behaviour.
*/
static int
-smp_fetch_srv_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_srv_conn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* undefined behaviour.
*/
static int
-smp_fetch_srv_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_srv_sess_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
#include <proto/peers.h>
#include <proto/sample.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/raw_sock.h>
#include <proto/task.h>
#include <proto/stick_table.h>
l->maxaccept = 1;
l->maxconn = ((struct proxy *)curpeers->peers_fe)->maxconn;
l->backlog = ((struct proxy *)curpeers->peers_fe)->backlog;
- l->accept = session_accept;
- l->handler = process_session;
+ l->accept = stream_accept;
+ l->handler = process_stream;
l->analysers |= ((struct proxy *)curpeers->peers_fe)->fe_req_ana;
l->default_target = ((struct proxy *)curpeers->peers_fe)->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
curproxy->conf.lfs_line = curproxy->conf.args.line;
}
else if (!strcmp(args[1], "tcpka")) {
- /* enable TCP keep-alives on client and server sessions */
+ /* enable TCP keep-alives on client and server streams */
if (warnifnotcap(curproxy, PR_CAP_BE | PR_CAP_FE, file, linenum, args[1], NULL))
err_code |= ERR_WARN;
listener->maxaccept = (listener->maxaccept + nbproc - 1) / nbproc;
}
- listener->accept = session_accept;
- listener->handler = process_session;
+ listener->accept = stream_accept;
+ listener->handler = process_stream;
listener->analysers |= curproxy->fe_req_ana;
listener->default_target = curproxy->default_target;
#include <proto/proxy.h>
#include <proto/raw_sock.h>
#include <proto/server.h>
-#include <proto/session.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
/*
* Init HTTP compression
*/
-int http_compression_buffer_init(struct session *s, struct buffer *in, struct buffer *out)
+int http_compression_buffer_init(struct stream *s, struct buffer *in, struct buffer *out)
{
/* output stream requires at least 10 bytes for the gzip header, plus
* at least 8 bytes for the gzip trailer (crc+len), plus a possible
/*
* Add data to compress
*/
-int http_compression_buffer_add_data(struct session *s, struct buffer *in, struct buffer *out)
+int http_compression_buffer_add_data(struct stream *s, struct buffer *in, struct buffer *out)
{
struct http_msg *msg = &s->txn.rsp;
int consumed_data = 0;
* Flush data in process, and write the header and footer of the chunk. Upon
* success, in and out buffers are swapped to avoid a copy.
*/
-int http_compression_buffer_end(struct session *s, struct buffer **in, struct buffer **out, int end)
+int http_compression_buffer_end(struct stream *s, struct buffer **in, struct buffer **out, int end)
{
int to_forward;
int left;
/* boolean, returns true if compression is used (either gzip or deflate) in the response */
static int
-smp_fetch_res_comp(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_res_comp(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_BOOL;
/* string, returns algo */
static int
-smp_fetch_res_comp_algo(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_res_comp_algo(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
if (!l4->comp_algo)
#include <proto/fd.h>
#include <proto/frontend.h>
#include <proto/proto_tcp.h>
-#include <proto/session.h>
#include <proto/stream_interface.h>
#ifdef USE_OPENSSL
#include <proto/proto_uxst.h>
#include <proto/proxy.h>
#include <proto/sample.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/server.h>
#include <proto/raw_sock.h>
#include <proto/stream_interface.h>
STAT_CLI_PRINT, /* display message in cli->msg */
STAT_CLI_PRINT_FREE, /* display message in cli->msg. After the display, free the pointer */
STAT_CLI_O_INFO, /* dump info */
- STAT_CLI_O_SESS, /* dump sessions */
+ STAT_CLI_O_SESS, /* dump streams */
STAT_CLI_O_ERR, /* dump errors */
STAT_CLI_O_TAB, /* dump tables */
STAT_CLI_O_CLR, /* clear tables */
static int stats_dump_info_to_buffer(struct stream_interface *si);
static int stats_dump_pools_to_buffer(struct stream_interface *si);
-static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct session *sess);
+static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct stream *sess);
static int stats_dump_sess_to_buffer(struct stream_interface *si);
static int stats_dump_errors_to_buffer(struct stream_interface *si);
static int stats_table_request(struct stream_interface *si, int show);
list_for_each_entry(l, &bind_conf->listeners, by_bind) {
l->maxconn = global.stats_fe->maxconn;
l->backlog = global.stats_fe->backlog;
- l->accept = session_accept;
- l->handler = process_session;
+ l->accept = stream_accept;
+ l->handler = process_stream;
l->default_target = global.stats_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
l->nice = -64; /* we want to boost priority for local stats */
static int stats_dump_table_head_to_buffer(struct chunk *msg, struct stream_interface *si,
struct proxy *proxy, struct proxy *target)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
chunk_appendf(msg, "# table: %s, type: %s, size:%d, used:%d\n",
proxy->id, stktable_types[proxy->table.type].kw, proxy->table.size, proxy->table.current);
static void stats_sock_table_key_request(struct stream_interface *si, char **args, int action)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct appctx *appctx = __objt_appctx(si->end);
struct proxy *px = appctx->ctx.table.target;
struct stksess *ts;
}
/* Expects to find a frontend named <arg> and returns it, otherwise displays various
- * adequate error messages and returns NULL. This function also expects the session
+ * adequate error messages and returns NULL. This function also expects the stream
* level to be admin.
*/
-static struct proxy *expect_frontend_admin(struct session *s, struct stream_interface *si, const char *arg)
+static struct proxy *expect_frontend_admin(struct stream *s, struct stream_interface *si, const char *arg)
{
struct appctx *appctx = __objt_appctx(si->end);
struct proxy *px;
/* Expects to find a backend and a server in <arg> under the form <backend>/<server>,
* and returns the pointer to the server. Otherwise, display adequate error messages
- * and returns NULL. This function also expects the session level to be admin. Note:
+ * and returns NULL. This function also expects the stream level to be admin. Note:
* the <arg> is modified to remove the '/'.
*/
-static struct server *expect_server_admin(struct session *s, struct stream_interface *si, char *arg)
+static struct server *expect_server_admin(struct stream *s, struct stream_interface *si, char *arg)
{
struct appctx *appctx = __objt_appctx(si->end);
struct proxy *px;
*/
static int stats_sock_parse_request(struct stream_interface *si, char *line)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct appctx *appctx = __objt_appctx(si->end);
char *args[MAX_STATS_ARGS + 1];
int arg;
appctx->ctx.sess.target = (void *)strtoul(args[2], NULL, 0);
else
appctx->ctx.sess.target = NULL;
- appctx->ctx.sess.section = 0; /* start with session status */
+ appctx->ctx.sess.section = 0; /* start with stream status */
appctx->ctx.sess.pos = 0;
appctx->st0 = STAT_CLI_O_SESS; // stats_dump_sess_to_buffer
}
return 1;
}
else if (strcmp(args[1], "session") == 0) {
- struct session *sess, *ptr;
+ struct stream *sess, *ptr;
if (s->listener->bind_conf->level < ACCESS_LVL_ADMIN) {
appctx->ctx.cli.msg = stats_permission_denied_msg;
ptr = (void *)strtoul(args[2], NULL, 0);
- /* first, look for the requested session in the session table */
- list_for_each_entry(sess, &sessions, list) {
+ /* first, look for the requested stream in the stream table */
+ list_for_each_entry(sess, &streams, list) {
if (sess == ptr)
break;
}
- /* do we have the session ? */
+ /* do we have the stream ? */
if (sess != ptr) {
appctx->ctx.cli.msg = "No such session (use 'show sess').\n";
appctx->st0 = STAT_CLI_PRINT;
return 1;
}
- session_shutdown(sess, SN_ERR_KILLED);
+ stream_shutdown(sess, SN_ERR_KILLED);
return 1;
}
else if (strcmp(args[1], "sessions") == 0) {
if (strcmp(args[2], "server") == 0) {
struct server *sv;
- struct session *sess, *sess_bck;
+ struct stream *sess, *sess_bck;
sv = expect_server_admin(s, si, args[3]);
if (!sv)
return 1;
- /* kill all the session that are on this server */
+ /* kill all the stream that are on this server */
list_for_each_entry_safe(sess, sess_bck, &sv->actconns, by_srv)
if (sess->srv_conn == sv)
- session_shutdown(sess, SN_ERR_KILLED);
+ stream_shutdown(sess, SN_ERR_KILLED);
return 1;
}
static int stats_dump_proxy_to_buffer(struct stream_interface *si, struct proxy *px, struct uri_auth *uri)
{
struct appctx *appctx = __objt_appctx(si->end);
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct channel *rep = si_ic(si);
struct server *sv, *svs; /* server and server-state, server-state=server or server->track */
struct listener *l;
* either CSV or HTML format. <uri> contains some HTML-specific parameters that
* are ignored for CSV format (hence <uri> may be NULL there). It returns 0 if
* it had to stop writing data and an I/O is needed, 1 if the dump is finished
- * and the session must be closed, or -1 in case of any error. This function is
+ * and the stream must be closed, or -1 in case of any error. This function is
* used by both the CLI and the HTTP handlers.
*/
static int stats_dump_stat_to_buffer(struct stream_interface *si, struct uri_auth *uri)
*/
static int stats_process_http_post(struct stream_interface *si)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct appctx *appctx = objt_appctx(si->end);
struct proxy *px = NULL;
break;
case ST_ADM_ACTION_SHUTDOWN:
if (px->state != PR_STSTOPPED) {
- struct session *sess, *sess_bck;
+ struct stream *sess, *sess_bck;
list_for_each_entry_safe(sess, sess_bck, &sv->actconns, by_srv)
if (sess->srv_conn == sv)
- session_shutdown(sess, SN_ERR_KILLED);
+ stream_shutdown(sess, SN_ERR_KILLED);
altered_servers++;
total_servers++;
static int stats_send_http_headers(struct stream_interface *si)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct uri_auth *uri = s->be->uri_auth;
struct appctx *appctx = objt_appctx(si->end);
static int stats_send_http_redirect(struct stream_interface *si)
{
char scope_txt[STAT_SCOPE_TXT_MAXLEN + sizeof STAT_SCOPE_PATTERN];
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct uri_auth *uri = s->be->uri_auth;
struct appctx *appctx = objt_appctx(si->end);
static void http_stats_io_handler(struct stream_interface *si)
{
struct appctx *appctx = __objt_appctx(si->end);
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct channel *req = si_oc(si);
struct channel *res = si_ic(si);
return ptr;
}
-/* This function dumps a complete session state onto the stream interface's
- * read buffer. The session has to be set in sess->target. It returns
+/* This function dumps a complete stream state onto the stream interface's
+ * read buffer. The stream has to be set in sess->target. It returns
* 0 if the output buffer is full and it needs to be called again, otherwise
* non-zero. It is designed to be called from stats_dump_sess_to_buffer() below.
*/
-static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct session *sess)
+static int stats_dump_full_sess_to_buffer(struct stream_interface *si, struct stream *sess)
{
struct appctx *appctx = __objt_appctx(si->end);
struct tm tm;
chunk_reset(&trash);
if (appctx->ctx.sess.section > 0 && appctx->ctx.sess.uid != sess->uniq_id) {
- /* session changed, no need to go any further */
+ /* stream changed, no need to go any further */
chunk_appendf(&trash, " *** session terminated while we were watching it ***\n");
if (bi_putchk(si_ic(si), &trash) == -1) {
si->flags |= SI_FL_WAIT_ROOM;
}
switch (appctx->ctx.sess.section) {
- case 0: /* main status of the session */
+ case 0: /* main status of the stream */
appctx->ctx.sess.uid = sess->uniq_id;
appctx->ctx.sess.section = 1;
/* fall through */
appctx->ctx.map.ref->display);
if (bi_putchk(si_ic(si), &trash) == -1) {
- /* let's try again later from this session. We add ourselves into
- * this session's users so that it can remove us upon termination.
+ /* let's try again later from this stream. We add ourselves into
+ * this stream's users so that it can remove us upon termination.
*/
si->flags |= SI_FL_WAIT_ROOM;
return 0;
/* display response */
if (bi_putchk(si_ic(si), &trash) == -1) {
- /* let's try again later from this session. We add ourselves into
- * this session's users so that it can remove us upon termination.
+ /* let's try again later from this stream. We add ourselves into
+ * this stream's users so that it can remove us upon termination.
*/
si->flags |= SI_FL_WAIT_ROOM;
return 0;
appctx->ctx.map.elt, appctx->ctx.map.elt->pattern);
if (bi_putchk(si_ic(si), &trash) == -1) {
- /* let's try again later from this session. We add ourselves into
- * this session's users so that it can remove us upon termination.
+ /* let's try again later from this stream. We add ourselves into
+ * this stream's users so that it can remove us upon termination.
*/
si->flags |= SI_FL_WAIT_ROOM;
return 0;
}
}
-/* This function dumps all sessions' states onto the stream interface's
+/* This function dumps all streams' states onto the stream interface's
* read buffer. It returns 0 if the output buffer is full and it needs
* to be called again, otherwise non-zero. It is designed to be called
* from stats_dump_sess_to_buffer() below.
if (unlikely(si_ic(si)->flags & (CF_WRITE_ERROR|CF_SHUTW))) {
/* If we're forced to shut down, we might have to remove our
- * reference to the last session being dumped.
+ * reference to the last stream being dumped.
*/
if (appctx->st2 == STAT_ST_LIST) {
if (!LIST_ISEMPTY(&appctx->ctx.sess.bref.users)) {
switch (appctx->st2) {
case STAT_ST_INIT:
/* the function had not been called yet, let's prepare the
- * buffer for a response. We initialize the current session
+ * buffer for a response. We initialize the current stream
* pointer to the first in the global list. When a target
- * session is being destroyed, it is responsible for updating
+ * stream is being destroyed, it is responsible for updating
* this pointer. We know we have reached the end when this
- * pointer points back to the head of the sessions list.
+ * pointer points back to the head of the streams list.
*/
LIST_INIT(&appctx->ctx.sess.bref.users);
- appctx->ctx.sess.bref.ref = sessions.n;
+ appctx->ctx.sess.bref.ref = streams.n;
appctx->st2 = STAT_ST_LIST;
/* fall through */
case STAT_ST_LIST:
- /* first, let's detach the back-ref from a possible previous session */
+ /* first, let's detach the back-ref from a possible previous stream */
if (!LIST_ISEMPTY(&appctx->ctx.sess.bref.users)) {
LIST_DEL(&appctx->ctx.sess.bref.users);
LIST_INIT(&appctx->ctx.sess.bref.users);
}
/* and start from where we stopped */
- while (appctx->ctx.sess.bref.ref != &sessions) {
+ while (appctx->ctx.sess.bref.ref != &streams) {
char pn[INET6_ADDRSTRLEN];
- struct session *curr_sess;
+ struct stream *curr_sess;
- curr_sess = LIST_ELEM(appctx->ctx.sess.bref.ref, struct session *, list);
+ curr_sess = LIST_ELEM(appctx->ctx.sess.bref.ref, struct stream *, list);
if (appctx->ctx.sess.target) {
if (appctx->ctx.sess.target != (void *)-1 && appctx->ctx.sess.target != curr_sess)
if (!stats_dump_full_sess_to_buffer(si, curr_sess))
return 0;
- /* session dump complete */
+ /* stream dump complete */
LIST_DEL(&appctx->ctx.sess.bref.users);
LIST_INIT(&appctx->ctx.sess.bref.users);
if (appctx->ctx.sess.target != (void *)-1) {
chunk_appendf(&trash, "\n");
if (bi_putchk(si_ic(si), &trash) == -1) {
- /* let's try again later from this session. We add ourselves into
- * this session's users so that it can remove us upon termination.
+ /* let's try again later from this stream. We add ourselves into
+ * this stream's users so that it can remove us upon termination.
*/
si->flags |= SI_FL_WAIT_ROOM;
LIST_ADDQ(&curr_sess->back_refs, &appctx->ctx.sess.bref.users);
}
if (appctx->ctx.sess.target && appctx->ctx.sess.target != (void *)-1) {
- /* specified session not found */
+ /* specified stream not found */
if (appctx->ctx.sess.section > 0)
chunk_appendf(&trash, " *** session terminated while we were watching it ***\n");
else
/* This is called when the stream interface is closed. For instance, upon an
* external abort, we won't call the i/o handler anymore so we may need to
- * remove back references to the session currently being dumped.
+ * remove back references to the stream currently being dumped.
*/
static void cli_release_handler(struct stream_interface *si)
{
static int stats_table_request(struct stream_interface *si, int action)
{
struct appctx *appctx = __objt_appctx(si->end);
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct ebmb_node *eb;
int dt;
int skip_entry;
#include <proto/proto_http.h>
#include <proto/proxy.h>
#include <proto/sample.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
-/* Finish a session accept() for a proxy (TCP or HTTP). It returns a negative
+/* Finish a stream accept() for a proxy (TCP or HTTP). It returns a negative
* value in case of a critical failure which must cause the listener to be
* disabled, a positive value in case of success, or zero if it is a success
- * but the session must be closed ASAP (eg: monitoring). It only supports
- * sessions with a connection in si[0].
+ * but the stream must be closed ASAP (eg: monitoring). It only supports
+ * streams with a connection in si[0].
*/
-int frontend_accept(struct session *s)
+int frontend_accept(struct stream *s)
{
struct connection *conn = __objt_conn(s->si[0].end);
int cfd = conn->t.sock.fd;
/* FIXME: the logs are horribly complicated now, because they are
* defined in <p>, <p>, and later <be> and <be>.
*/
- s->do_log = sess_log;
+ s->do_log = strm_log;
/* default error reporting function, may be changed by analysers */
s->srv_error = default_srv_error;
/* set temp integer to the id of the frontend */
static int
-smp_fetch_fe_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_SESS;
* an undefined behaviour.
*/
static int
-smp_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_sess_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* an undefined behaviour.
*/
static int
-smp_fetch_fe_conn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fe_conn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
#include <proto/proxy.h>
#include <proto/queue.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/signal.h>
#include <proto/task.h>
if (init_acl() != 0)
exit(1);
init_task();
- init_session();
+ init_stream();
init_connection();
/* warning, we init buffers later */
init_pendconn();
mem = mem * MEM_USABLE_RATIO;
global.maxconn = mem /
- ((SESSION_MAX_COST + 2 * global.tune.bufsize) + // session + 2 buffers per session
+ ((STREAM_MAX_COST + 2 * global.tune.bufsize) + // stream + 2 buffers per stream
sides * global.ssl_session_max_cost + // SSL buffers, one per side
global.ssl_handshake_max_cost); // 1 handshake per connection max
mem -= global.maxzlibmem;
mem = mem * MEM_USABLE_RATIO;
- sslmem = mem - global.maxconn * (int64_t)(SESSION_MAX_COST + 2 * global.tune.bufsize);
+ sslmem = mem - global.maxconn * (int64_t)(STREAM_MAX_COST + 2 * global.tune.bufsize);
global.maxsslconn = sslmem / (global.ssl_session_max_cost + global.ssl_handshake_max_cost);
global.maxsslconn = round_2dig(global.maxsslconn);
"high for the global.memmax value (%d MB). The absolute maximum possible value "
"without SSL is %d, but %d was found and SSL is in use.\n",
global.rlimit_memmax,
- (int)(mem / (SESSION_MAX_COST + 2 * global.tune.bufsize)),
+ (int)(mem / (STREAM_MAX_COST + 2 * global.tune.bufsize)),
global.maxconn);
exit(1);
}
if (sides)
clearmem -= (global.ssl_session_max_cost + global.ssl_handshake_max_cost) * (int64_t)global.maxsslconn;
- global.maxconn = clearmem / (SESSION_MAX_COST + 2 * global.tune.bufsize);
+ global.maxconn = clearmem / (STREAM_MAX_COST + 2 * global.tune.bufsize);
global.maxconn = round_2dig(global.maxconn);
#ifdef SYSTEM_MAXCONN
if (global.maxconn > DEFAULT_MAXCONN)
free(wl);
}
- pool_destroy2(pool2_session);
+ pool_destroy2(pool2_stream);
pool_destroy2(pool2_connection);
pool_destroy2(pool2_buffer);
pool_destroy2(pool2_requri);
#include <proto/raw_sock.h>
#include <proto/sample.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/ssl_sock.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
static int class_http_ref;
/* Global Lua execution timeout. By default Lua, execution linked
- * with session (actions, sample-fetches and converters) have a
+ * with stream (actions, sample-fetches and converters) have a
* short timeout. Lua linked with tasks doesn't have a timeout
* because a task may remain alive during all the haproxy execution.
*/
WILL_LJMP(lua_yieldk(L, nresults, ctx, k));
}
-/* This function initialises the Lua environment stored in the session.
- * It must be called at the start of the session. This function creates
+/* This function initialises the Lua environment stored in the stream.
+ * It must be called at the start of the stream. This function creates
* an LUA coroutine. It can not be use to crete the main LUA context.
*/
int hlua_ctx_init(struct hlua *lua, struct task *task)
return 1;
}
-/* Used to destroy the Lua coroutine when the attached session or task
+/* Used to destroy the Lua coroutine when the attached stream or task
* is destroyed. The destroy also the memory context. The struct "lua"
* is not freed.
*/
struct appctx *appctx = objt_appctx(si->end);
struct connection *c = objt_conn(si_opposite(si)->end);
- /* Wakeup the main session if the client connection is closed. */
+ /* Wakeup the main stream if the client connection is closed. */
if (!c || channel_output_closed(si_ic(si)) || channel_input_closed(si_oc(si))) {
if (appctx->ctx.hlua.socket) {
appctx->ctx.hlua.socket->s = NULL;
hlua_com_wake(&appctx->ctx.hlua.wake_on_read);
}
-/* This function is called when the "struct session" is destroyed.
- * Remove the link from the object to this session.
+/* This function is called when the "struct stream" is destroyed.
+ * Remove the link from the object to this stream.
* Wake all the pending signals.
*/
static void hlua_socket_release(struct stream_interface *si)
}
/* If the garbage collectio of the object is launch, nobody
- * uses this object. If the session does not exists, just quit.
- * Send the shutdown signal to the session. In some cases,
+ * uses this object. If the stream does not exists, just quit.
+ * Send the shutdown signal to the stream. In some cases,
* pending signal can rest in the read and write lists. destroy
* it.
*/
if (!socket->s)
return 0;
- /* Remove all reference between the Lua stack and the coroutine session. */
+ /* Remove all reference between the Lua stack and the coroutine stream. */
appctx = objt_appctx(socket->s->si[0].end);
- session_shutdown(socket->s, SN_ERR_KILLED);
+ stream_shutdown(socket->s, SN_ERR_KILLED);
socket->s = NULL;
appctx->ctx.hlua.socket = NULL;
}
/* The close function send shutdown signal and break the
- * links between the session and the object.
+ * links between the stream and the object.
*/
__LJMP static int hlua_socket_close(lua_State *L)
{
if (!socket->s)
return 0;
- /* Close the session and remove the associated stop task. */
- session_shutdown(socket->s, SN_ERR_KILLED);
+ /* Close the stream and remove the associated stop task. */
+ stream_shutdown(socket->s, SN_ERR_KILLED);
appctx = objt_appctx(socket->s->si[0].end);
appctx->ctx.hlua.socket = NULL;
socket->s = NULL;
* the request buffer if its not required.
*/
if (socket->s->req.buf->size == 0) {
- if (!session_alloc_recv_buffer(&socket->s->req)) {
+ if (!stream_alloc_recv_buffer(&socket->s->req)) {
socket->s->si[0].flags |= SI_FL_WAIT_ROOM;
goto hlua_socket_write_yield_return;
}
memset(socket, 0, sizeof(*socket));
/* Check if the various memory pools are intialized. */
- if (!pool2_session || !pool2_buffer) {
+ if (!pool2_stream || !pool2_buffer) {
hlua_pusherror(L, "socket: uninitialized pools.");
goto out_fail_conf;
}
- /* Pop a class session metatable and affect it to the userdata. */
+ /* Pop a class stream metatable and affect it to the userdata. */
lua_rawgeti(L, LUA_REGISTRYINDEX, class_socket_ref);
lua_setmetatable(L, -2);
*
*/
- socket->s = pool_alloc2(pool2_session);
+ socket->s = pool_alloc2(pool2_stream);
if (!socket->s) {
hlua_pusherror(L, "socket: out of memory");
goto out_fail_conf;
goto out_fail_rep_buf;
}
- /* Configura empty Lua for the session. */
+ /* Configura empty Lua for the stream. */
socket->s->hlua.T = NULL;
socket->s->hlua.Tref = LUA_REFNIL;
socket->s->hlua.Mref = LUA_REFNIL;
socket->s->hlua.flags = 0;
LIST_INIT(&socket->s->hlua.com);
- /* session initialisation. */
- session_init_srv_conn(socket->s);
+ /* stream initialisation. */
+ stream_init_srv_conn(socket->s);
/*
*
*
*/
- /* This is the dedicated function to process the session. This function
+ /* This is the dedicated function to process the stream. This function
* is able to establish the conection, process the timeouts, etc ...
*/
- socket->s->task->process = process_session;
+ socket->s->task->process = process_stream;
- /* Back reference to session. This is used by process_session(). */
+ /* Back reference to stream. This is used by process_stream(). */
socket->s->task->context = socket->s;
/* The priority of the task is normal. */
/*
*
- * Configure the session.
+ * Configure the stream.
*
*/
- /* The session dont have listener. The listener is used with real
+ /* The stream dont have listener. The listener is used with real
* proxies.
*/
socket->s->listener = NULL;
/* The flags are initialized to 0. Values are setted later. */
socket->s->flags = 0;
- /* Assign the configured proxy to the new session. */
+ /* Assign the configured proxy to the new stream. */
socket->s->be = &socket_proxy;
socket->s->fe = &socket_proxy;
socket->s->flags |= SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET | SN_BE_ASSIGNED;
socket->s->target = &socket_tcp.obj_type;
- /* This session is added to te lists of alive sessions. */
- LIST_ADDQ(&sessions, &socket->s->list);
+ /* This stream is added to te lists of alive streams. */
+ LIST_ADDQ(&streams, &socket->s->list);
/* XXX: I think that this list is used by stats. */
LIST_INIT(&socket->s->back_refs);
out_fail_req_buf:
task_free(socket->s->task);
out_free_session:
- pool_free2(pool2_session, socket->s);
+ pool_free2(pool2_stream, socket->s);
out_fail_conf:
WILL_LJMP(lua_error(L));
return 0;
* the request buffer if its not required.
*/
if (chn->buf->size == 0) {
- if (!session_alloc_recv_buffer(chn)) {
+ if (!stream_alloc_recv_buffer(chn)) {
chn_prod(chn)->flags |= SI_FL_WAIT_ROOM;
WILL_LJMP(hlua_yieldk(L, 0, 0, hlua_channel_send_yield, TICK_ETERNITY, 0));
}
*/
/* Returns a struct hlua_session if the stack entry "ud" is
- * a class session, otherwise it throws an error.
+ * a class stream, otherwise it throws an error.
*/
__LJMP static struct hlua_smp *hlua_checkfetches(lua_State *L, int ud)
{
*/
/* Returns a struct hlua_session if the stack entry "ud" is
- * a class session, otherwise it throws an error.
+ * a class stream, otherwise it throws an error.
*/
__LJMP static struct hlua_smp *hlua_checkconverters(lua_State *L, int ud)
{
hsmp->l7 = txn->l7;
hsmp->stringsafe = stringsafe;
- /* Pop a class session metatable and affect it to the table. */
+ /* Pop a class stream metatable and affect it to the table. */
lua_rawgeti(L, LUA_REGISTRYINDEX, class_converters_ref);
lua_setmetatable(L, -2);
*/
/* Returns a struct hlua_txn if the stack entry "ud" is
- * a class session, otherwise it throws an error.
+ * a class stream, otherwise it throws an error.
*/
__LJMP static struct hlua_txn *hlua_checkhttp(lua_State *L, int ud)
{
htxn->p = txn->p;
htxn->l7 = txn->l7;
- /* Pop a class session metatable and affect it to the table. */
+ /* Pop a class stream metatable and affect it to the table. */
lua_rawgeti(L, LUA_REGISTRYINDEX, class_http_ref);
lua_setmetatable(L, -2);
*/
/* Returns a struct hlua_session if the stack entry "ud" is
- * a class session, otherwise it throws an error.
+ * a class stream, otherwise it throws an error.
*/
__LJMP static struct hlua_txn *hlua_checktxn(lua_State *L, int ud)
{
MAY_LJMP(check_args(L, 2, "set_priv"));
- /* It is useles to retrieve the session, but this function
- * runs only in a session context.
+ /* It is useles to retrieve the stream, but this function
+ * runs only in a stream context.
*/
MAY_LJMP(hlua_checktxn(L, 1));
hlua = hlua_gethlua(L);
MAY_LJMP(check_args(L, 1, "get_priv"));
- /* It is useles to retrieve the session, but this function
- * runs only in a session context.
+ /* It is useles to retrieve the stream, but this function
+ * runs only in a stream context.
*/
MAY_LJMP(hlua_checktxn(L, 1));
hlua = hlua_gethlua(L);
* return 0 if the stack does not contains free slots,
* otherwise it returns 1.
*/
-static int hlua_txn_new(lua_State *L, struct session *s, struct proxy *p, void *l7)
+static int hlua_txn_new(lua_State *L, struct stream *s, struct proxy *p, void *l7)
{
struct hlua_txn *htxn;
* doesn't allow "yield" functions because the HAProxy engine cannot
* resume converters.
*/
-static int hlua_sample_conv_wrapper(struct session *session, const struct arg *arg_p,
+static int hlua_sample_conv_wrapper(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct hlua_function *fcn = (struct hlua_function *)private;
- /* In the execution wrappers linked with a session, the
+ /* In the execution wrappers linked with a stream, the
* Lua context can be not initialized. This behavior
* permits to save performances because a systematic
* Lua initialization cause 5% performances loss.
*/
- if (!session->hlua.T && !hlua_ctx_init(&session->hlua, session->task)) {
- send_log(session->be, LOG_ERR, "Lua converter '%s': can't initialize Lua context.", fcn->name);
+ if (!stream->hlua.T && !hlua_ctx_init(&stream->hlua, stream->task)) {
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': can't initialize Lua context.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s': can't initialize Lua context.\n", fcn->name);
return 0;
}
/* If it is the first run, initialize the data for the call. */
- if (!HLUA_IS_RUNNING(&session->hlua)) {
+ if (!HLUA_IS_RUNNING(&stream->hlua)) {
/* Check stack available size. */
- if (!lua_checkstack(session->hlua.T, 1)) {
- send_log(session->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
+ if (!lua_checkstack(stream->hlua.T, 1)) {
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s': full stack.\n", fcn->name);
return 0;
}
/* Restore the function in the stack. */
- lua_rawgeti(session->hlua.T, LUA_REGISTRYINDEX, fcn->function_ref);
+ lua_rawgeti(stream->hlua.T, LUA_REGISTRYINDEX, fcn->function_ref);
/* convert input sample and pust-it in the stack. */
- if (!lua_checkstack(session->hlua.T, 1)) {
- send_log(session->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
+ if (!lua_checkstack(stream->hlua.T, 1)) {
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s': full stack.\n", fcn->name);
return 0;
}
- hlua_smp2lua(session->hlua.T, smp);
- session->hlua.nargs = 2;
+ hlua_smp2lua(stream->hlua.T, smp);
+ stream->hlua.nargs = 2;
/* push keywords in the stack. */
if (arg_p) {
for (; arg_p->type != ARGT_STOP; arg_p++) {
- if (!lua_checkstack(session->hlua.T, 1)) {
- send_log(session->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
+ if (!lua_checkstack(stream->hlua.T, 1)) {
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': full stack.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s': full stack.\n", fcn->name);
return 0;
}
- hlua_arg2lua(session->hlua.T, arg_p);
- session->hlua.nargs++;
+ hlua_arg2lua(stream->hlua.T, arg_p);
+ stream->hlua.nargs++;
}
}
/* We must initialize the execution timeouts. */
- session->hlua.expire = tick_add(now_ms, hlua_timeout_session);
+ stream->hlua.expire = tick_add(now_ms, hlua_timeout_session);
/* Set the currently running flag. */
- HLUA_SET_RUN(&session->hlua);
+ HLUA_SET_RUN(&stream->hlua);
}
/* Execute the function. */
- switch (hlua_ctx_resume(&session->hlua, 0)) {
+ switch (hlua_ctx_resume(&stream->hlua, 0)) {
/* finished. */
case HLUA_E_OK:
/* Convert the returned value in sample. */
- hlua_lua2smp(session->hlua.T, -1, smp);
- lua_pop(session->hlua.T, 1);
+ hlua_lua2smp(stream->hlua.T, -1, smp);
+ lua_pop(stream->hlua.T, 1);
return 1;
/* yield. */
case HLUA_E_AGAIN:
- send_log(session->be, LOG_ERR, "Lua converter '%s': cannot use yielded functions.", fcn->name);
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': cannot use yielded functions.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s': cannot use yielded functions.\n", fcn->name);
return 0;
/* finished with error. */
case HLUA_E_ERRMSG:
/* Display log. */
- send_log(session->be, LOG_ERR, "Lua converter '%s': %s.", fcn->name, lua_tostring(session->hlua.T, -1));
+ send_log(stream->be, LOG_ERR, "Lua converter '%s': %s.", fcn->name, lua_tostring(stream->hlua.T, -1));
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
- Alert("Lua converter '%s': %s.\n", fcn->name, lua_tostring(session->hlua.T, -1));
- lua_pop(session->hlua.T, 1);
+ Alert("Lua converter '%s': %s.\n", fcn->name, lua_tostring(stream->hlua.T, -1));
+ lua_pop(stream->hlua.T, 1);
return 0;
case HLUA_E_ERR:
/* Display log. */
- send_log(session->be, LOG_ERR, "Lua converter '%s' returns an unknown error.", fcn->name);
+ send_log(stream->be, LOG_ERR, "Lua converter '%s' returns an unknown error.", fcn->name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
Alert("Lua converter '%s' returns an unknown error.\n", fcn->name);
* doesn't allow "yield" functions because the HAProxy engine cannot
* resume sample-fetches.
*/
-static int hlua_sample_fetch_wrapper(struct proxy *px, struct session *s, void *l7,
+static int hlua_sample_fetch_wrapper(struct proxy *px, struct stream *s, void *l7,
unsigned int opt, const struct arg *arg_p,
struct sample *smp, const char *kw, void *private)
{
struct hlua_function *fcn = (struct hlua_function *)private;
- /* In the execution wrappers linked with a session, the
+ /* In the execution wrappers linked with a stream, the
* Lua context can be not initialized. This behavior
* permits to save performances because a systematic
* Lua initialization cause 5% performances loss.
* returns a yield.
*/
static int hlua_request_act_wrapper(struct hlua_rule *rule, struct proxy *px,
- struct session *s, struct http_txn *http_txn,
+ struct stream *s, struct http_txn *http_txn,
unsigned int analyzer)
{
char **arg;
- /* In the execution wrappers linked with a session, the
+ /* In the execution wrappers linked with a stream, the
* Lua context can be not initialized. This behavior
* permits to save performances because a systematic
* Lua initialization cause 5% performances loss.
/* Restore the function in the stack. */
lua_rawgeti(s->hlua.T, LUA_REGISTRYINDEX, rule->fcn.function_ref);
- /* Create and and push object session in the stack. */
+ /* Create and and push object stream in the stack. */
if (!hlua_txn_new(s->hlua.T, s, px, http_txn)) {
send_log(px, LOG_ERR, "Lua function '%s': full stack.", rule->fcn.name);
if (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE))
* "hlua_request_act_wrapper" for executing the LUA code.
*/
int hlua_tcp_req_act_wrapper(struct tcp_rule *tcp_rule, struct proxy *px,
- struct session *s)
+ struct stream *s)
{
return hlua_request_act_wrapper((struct hlua_rule *)tcp_rule->act_prm.data,
px, s, NULL, AN_REQ_INSPECT_FE);
* "hlua_request_act_wrapper" for executing the LUA code.
*/
int hlua_tcp_res_act_wrapper(struct tcp_rule *tcp_rule, struct proxy *px,
- struct session *s)
+ struct stream *s)
{
return hlua_request_act_wrapper((struct hlua_rule *)tcp_rule->act_prm.data,
px, s, NULL, AN_RES_INSPECT);
* the LUA code.
*/
int hlua_http_req_act_wrapper(struct http_req_rule *rule, struct proxy *px,
- struct session *s, struct http_txn *http_txn)
+ struct stream *s, struct http_txn *http_txn)
{
return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.data, px,
s, http_txn, AN_REQ_HTTP_PROCESS_FE);
* the LUA code.
*/
int hlua_http_res_act_wrapper(struct http_res_rule *rule, struct proxy *px,
- struct session *s, struct http_txn *http_txn)
+ struct stream *s, struct http_txn *http_txn)
{
return hlua_request_act_wrapper((struct hlua_rule *)rule->arg.data, px,
s, http_txn, AN_RES_HTTP_PROCESS_BE);
};
#endif
- /* Initialise com signals pool session. */
+ /* Initialise com signals pool */
pool2_hlua_com = create_pool("hlua_com", sizeof(struct hlua_com), MEM_F_SHARED);
/* Register configuration keywords. */
return 1;
}
-/* Marks a ready listener as full so that the session code tries to re-enable
+/* Marks a ready listener as full so that the stream code tries to re-enable
* it upon next close() using resume_listener().
*/
void listener_full(struct listener *l)
ret = l->accept(l, cfd, &addr);
if (unlikely(ret <= 0)) {
- /* The connection was closed by session_accept(). Either
+ /* The connection was closed by stream_accept(). Either
* we just have to ignore it (ret == 0) or it's a critical
* error due to a resource shortage, and we must stop the
* listener (ret < 0).
/* set temp integer to the number of connexions to the same listening socket */
static int
-smp_fetch_dconn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_dconn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_UINT;
/* set temp integer to the id of the socket (listener) */
static int
-smp_fetch_so_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_so_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_UINT;
* not counting the trailing zero which is always added if the resulting size
* is not zero.
*/
-int build_logline(struct session *s, char *dst, size_t maxsize, struct list *list_format)
+int build_logline(struct stream *s, char *dst, size_t maxsize, struct list *list_format)
{
struct proxy *fe = s->fe;
struct proxy *be = s->be;
}
/*
- * send a log for the session when we have enough info about it.
+ * send a log for the stream when we have enough info about it.
* Will not log if the frontend has no log defined.
*/
-void sess_log(struct session *s)
+void strm_log(struct stream *s)
{
char *tmplog;
int size, err, level;
return 1;
}
-static int sample_conv_map(struct session *session, const struct arg *arg_p,
+static int sample_conv_map(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct map_descriptor *desc;
* used with content inspection.
*/
static int
-smp_fetch_wait_end(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_wait_end(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
if (!(opt & SMP_OPT_FINAL)) {
/* return the number of bytes in the request buffer */
static int
-smp_fetch_len(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_len(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct channel *chn;
/* returns the type of SSL hello message (mainly used to detect an SSL hello) */
static int
-smp_fetch_ssl_hello_type(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_ssl_hello_type(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int hs_len;
* Note: this decoder only works with non-wrapping data.
*/
static int
-smp_fetch_req_ssl_ver(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_req_ssl_ver(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int version, bleft, msg_len;
* - opaque hostname[name_len bytes]
*/
static int
-smp_fetch_ssl_hello_sni(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_ssl_hello_sni(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int hs_len, ext_len, bleft;
* of type SMP_T_CSTR. Note: this decoder only works with non-wrapping data.
*/
int
-fetch_rdp_cookie_name(struct session *s, struct sample *smp, const char *cname, int clen)
+fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, int clen)
{
int bleft;
const unsigned char *data;
* returned sample has type SMP_T_CSTR.
*/
int
-smp_fetch_rdp_cookie(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_rdp_cookie(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
return fetch_rdp_cookie_name(s, smp, args ? args->data.str.str : NULL, args ? args->data.str.len : 0);
/* returns either 1 or 0 depending on whether an RDP cookie is found or not */
static int
-smp_fetch_rdp_cookie_cnt(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_rdp_cookie_cnt(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int ret;
/* extracts part of a payload with offset and length at a given position */
static int
-smp_fetch_payload_lv(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_payload_lv(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *arg_p, struct sample *smp, const char *kw, void *private)
{
unsigned int len_offset = arg_p[0].data.uint;
/* extracts some payload at a fixed position and length */
static int
-smp_fetch_payload(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_payload(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *arg_p, struct sample *smp, const char *kw, void *private)
{
unsigned int buf_offset = arg_p[0].data.uint;
#include <proto/proto_tcp.h>
#include <proto/proto_http.h>
#include <proto/proxy.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/signal.h>
#include <proto/stick_table.h>
#include <proto/stream_interface.h>
#define PEER_SESSION_PROTO_NAME "HAProxyS"
struct peers *peers = NULL;
-static void peer_session_forceshutdown(struct session * session);
+static void peer_session_forceshutdown(struct stream * stream);
/*
*/
static void peer_session_release(struct stream_interface *si)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct appctx *appctx = objt_appctx(si->end);
struct peer_session *ps = (struct peer_session *)appctx->ctx.peers.ptr;
/* peer session identified */
if (ps) {
- if (ps->session == s) {
- ps->session = NULL;
+ if (ps->stream == s) {
+ ps->stream = NULL;
if (ps->flags & PEER_F_LEARN_ASSIGN) {
/* unassign current peer for learning */
ps->flags &= ~(PEER_F_LEARN_ASSIGN);
*/
static void peer_io_handler(struct stream_interface *si)
{
- struct session *s = si_sess(si);
+ struct stream *s = si_strm(si);
struct peers *curpeers = (struct peers *)s->fe->parent;
struct appctx *appctx = objt_appctx(si->end);
int reql = 0;
goto switchstate;
}
- /* lookup peer session of current peer */
+ /* lookup peer stream of current peer */
for (ps = st->sessions; ps; ps = ps->next) {
if (ps->peer == curpeer) {
- /* If session already active, replaced by new one */
- if (ps->session && ps->session != s) {
+ /* If stream already active, replaced by new one */
+ if (ps->stream && ps->stream != s) {
if (ps->peer->local) {
/* Local connection, reply a retry */
appctx->st0 = PEER_SESS_ST_EXIT;
appctx->st1 = PEER_SESS_SC_TRYAGAIN;
goto switchstate;
}
- peer_session_forceshutdown(ps->session);
+ peer_session_forceshutdown(ps->stream);
}
- ps->session = s;
+ ps->stream = s;
break;
}
}
/*
* Use this function to force a close of a peer session
*/
-static void peer_session_forceshutdown(struct session * session)
+static void peer_session_forceshutdown(struct stream * stream)
{
struct stream_interface *oldsi = NULL;
struct appctx *appctx = NULL;
int i;
for (i = 0; i <= 1; i++) {
- appctx = objt_appctx(session->si[i].end);
+ appctx = objt_appctx(stream->si[i].end);
if (!appctx)
continue;
if (appctx->applet != &peer_applet)
continue;
- oldsi = &session->si[i];
+ oldsi = &stream->si[i];
break;
}
peer_session_release(oldsi);
appctx->st0 = PEER_SESS_ST_END;
appctx->ctx.peers.ptr = NULL;
- task_wakeup(session->task, TASK_WOKEN_MSG);
+ task_wakeup(stream->task, TASK_WOKEN_MSG);
}
/* Pre-configures a peers frontend to accept incoming connections */
/*
* Create a new peer session in assigned state (connect will start automatically)
*/
-static struct session *peer_session_create(struct peer *peer, struct peer_session *ps)
+static struct stream *peer_session_create(struct peer *peer, struct peer_session *ps)
{
struct listener *l = LIST_NEXT(&peer->peers->peers_fe->conf.listeners, struct listener *, by_fe);
struct proxy *p = (struct proxy *)l->frontend; /* attached frontend */
struct appctx *appctx;
- struct session *s;
+ struct stream *s;
struct http_txn *txn;
struct task *t;
struct connection *conn;
- if ((s = pool_alloc2(pool2_session)) == NULL) { /* disable this proxy for a while */
+ if ((s = pool_alloc2(pool2_stream)) == NULL) { /* disable this proxy for a while */
Alert("out of memory in peer_session_create().\n");
goto out_close;
}
- LIST_ADDQ(&sessions, &s->list);
+ LIST_ADDQ(&streams, &s->list);
LIST_INIT(&s->back_refs);
LIST_INIT(&s->buffer_wait);
s->task = t;
s->listener = l;
- /* Note: initially, the session's backend points to the frontend.
+ /* Note: initially, the stream's backend points to the frontend.
* This changes later when switching rules are executed or
* when the default backend is assigned.
*/
conn->target = s->target = &s->be->obj_type;
memcpy(&conn->addr.to, &peer->addr, sizeof(conn->addr.to));
- session_init_srv_conn(s);
+ stream_init_srv_conn(s);
s->pend_pos = NULL;
/* init store persistence */
txn = &s->txn;
/* Those variables will be checked and freed if non-NULL in
- * session.c:session_free(). It is important that they are
+ * stream.c:stream_free(). It is important that they are
* properly initialized.
*/
txn->sessid = NULL;
task_free(t);
out_free_session:
LIST_DEL(&s->list);
- pool_free2(pool2_session, s);
+ pool_free2(pool2_stream, s);
out_close:
return s;
}
for (ps = st->sessions; ps; ps = ps->next) {
/* For each remote peers */
if (!ps->peer->local) {
- if (!ps->session) {
- /* no active session */
+ if (!ps->stream) {
+ /* no active stream */
if (ps->statuscode == 0 ||
ps->statuscode == PEER_SESS_SC_SUCCESSCODE ||
((ps->statuscode == PEER_SESS_SC_CONNECTCODE ||
ps->statuscode == PEER_SESS_SC_CONNECTEDCODE) &&
tick_is_expired(ps->reconnect, now_ms))) {
/* connection never tried
- * or previous session established with success
- * or previous session failed during connection
+ * or previous stream established with success
+ * or previous stream failed during connection
* and reconnection timer is expired */
/* retry a connect */
- ps->session = peer_session_create(ps->peer, ps);
+ ps->stream = peer_session_create(ps->peer, ps);
}
else if (ps->statuscode == PEER_SESS_SC_CONNECTCODE ||
ps->statuscode == PEER_SESS_SC_CONNECTEDCODE) {
task->expire = tick_first(task->expire, ps->reconnect);
}
/* else do nothing */
- } /* !ps->session */
+ } /* !ps->stream */
else if (ps->statuscode == PEER_SESS_SC_SUCCESSCODE) {
- /* current session is active and established */
+ /* current stream is active and established */
if (((st->flags & SHTABLE_RESYNC_STATEMASK) == SHTABLE_RESYNC_FROMREMOTE) &&
!(st->flags & SHTABLE_F_RESYNC_ASSIGN) &&
!(ps->flags & PEER_F_LEARN_NOTUP2DATE)) {
ps->flags |= PEER_F_LEARN_ASSIGN;
st->flags |= SHTABLE_F_RESYNC_ASSIGN;
- /* awake peer session task to handle a request of resync */
- task_wakeup(ps->session->task, TASK_WOKEN_MSG);
+ /* awake peer stream task to handle a request of resync */
+ task_wakeup(ps->stream->task, TASK_WOKEN_MSG);
}
else if ((int)(ps->pushed - ps->table->table->localupdate) < 0) {
- /* awake peer session task to push local updates */
- task_wakeup(ps->session->task, TASK_WOKEN_MSG);
+ /* awake peer stream task to push local updates */
+ task_wakeup(ps->stream->task, TASK_WOKEN_MSG);
}
/* else do nothing */
} /* SUCCESSCODE */
/* disconnect all connected peers */
for (ps = st->sessions; ps; ps = ps->next) {
- if (ps->session) {
- peer_session_forceshutdown(ps->session);
- ps->session = NULL;
+ if (ps->stream) {
+ peer_session_forceshutdown(ps->stream);
+ ps->stream = NULL;
}
}
}
st->table->syncing--;
}
}
- else if (!ps->session) {
- /* If session is not active */
+ else if (!ps->stream) {
+ /* If stream is not active */
if (ps->statuscode == 0 ||
ps->statuscode == PEER_SESS_SC_SUCCESSCODE ||
ps->statuscode == PEER_SESS_SC_CONNECTEDCODE ||
ps->statuscode == PEER_SESS_SC_TRYAGAIN) {
/* connection never tried
- * or previous session was successfully established
- * or previous session tcp connect success but init state incomplete
+ * or previous stream was successfully established
+ * or previous stream tcp connect success but init state incomplete
* or during previous connect, peer replies a try again statuscode */
/* connect to the peer */
- ps->session = peer_session_create(ps->peer, ps);
+ ps->stream = peer_session_create(ps->peer, ps);
}
else {
/* Other error cases */
}
else if (ps->statuscode == PEER_SESS_SC_SUCCESSCODE &&
(int)(ps->pushed - ps->table->table->localupdate) < 0) {
- /* current session active and established
- awake session to push remaining local updates */
- task_wakeup(ps->session->task, TASK_WOKEN_MSG);
+ /* current stream active and established
+ awake stream to push remaining local updates */
+ task_wakeup(ps->stream->task, TASK_WOKEN_MSG);
}
} /* stopping */
/* Wakeup for re-connect */
#include <proto/queue.h>
#include <proto/sample.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
#include <proto/pattern.h>
#error "Check if your OS uses bitfields for fd_sets"
#endif
-static int http_apply_redirect_rule(struct redirect_rule *rule, struct session *s, struct http_txn *txn);
+static int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn);
void init_proto_http()
{
* The error flags are set to the values in arguments. Any pending request
* in this buffer will be lost.
*/
-static void http_server_error(struct session *s, struct stream_interface *si,
+static void http_server_error(struct stream *s, struct stream_interface *si,
int err, int finst, int status, const struct chunk *msg)
{
channel_auto_read(si_oc(si));
s->flags |= finst;
}
-/* This function returns the appropriate error location for the given session
+/* This function returns the appropriate error location for the given stream
* and message.
*/
-struct chunk *http_error_message(struct session *s, int msgnum)
+struct chunk *http_error_message(struct stream *s, int msgnum)
{
if (s->be->errmsg[msgnum].str)
return &s->be->errmsg[msgnum];
* follow normal proxy processing. NOTE: this function is designed to support
* being called once data are scheduled for forwarding.
*/
-void http_perform_server_redirect(struct session *s, struct stream_interface *si)
+void http_perform_server_redirect(struct stream *s, struct stream_interface *si)
{
struct http_txn *txn;
struct server *srv;
* Note that connection errors appearing on the second request of a keep-alive
* connection are not reported since this allows the client to retry.
*/
-void http_return_srv_error(struct session *s, struct stream_interface *si)
+void http_return_srv_error(struct stream *s, struct stream_interface *si)
{
int err_type = si->err_type;
* or auth method is unknown auth_method is set to HTTP_AUTH_WRONG to avoid
* searching again for something we are unable to find anyway. However, if
* the result if valid, the cache is not reused because we would risk to
- * have the credentials overwritten by another session in parallel.
+ * have the credentials overwritten by another stream in parallel.
*/
/* This bufffer is initialized in the file 'src/haproxy.c'. This length is
char *get_http_auth_buff;
int
-get_http_auth(struct session *s)
+get_http_auth(struct stream *s)
{
struct http_txn *txn = &s->txn;
int len;
#ifdef DEBUG_AUTH
- printf("Auth for session %p: %d\n", s, txn->auth.method);
+ printf("Auth for stream %p: %d\n", s, txn->auth.method);
#endif
if (txn->auth.method == HTTP_AUTH_WRONG)
/*
* Selects a compression algorithm depending on the client request.
*/
-int select_compression_request_header(struct session *s, struct buffer *req)
+int select_compression_request_header(struct stream *s, struct buffer *req)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->req;
/*
* Selects a comression algorithm depending of the server response.
*/
-int select_compression_response_header(struct session *s, struct buffer *res)
+int select_compression_response_header(struct stream *s, struct buffer *res)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->rsp;
return 0;
}
-void http_adjust_conn_mode(struct session *s, struct http_txn *txn, struct http_msg *msg)
+void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg)
{
int tmp = TX_CON_WANT_KAL;
* when it has nothing left to do, and may remove any analyser when it wants to
* abort.
*/
-int http_wait_for_request(struct session *s, struct channel *req, int an_bit)
+int http_wait_for_request(struct stream *s, struct channel *req, int an_bit)
{
/*
* We will parse the partial (or complete) lines.
struct http_msg *msg = &txn->req;
struct hdr_ctx ctx;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
* A full request is indicated by the fact that we have seen
* the double LF/CRLF, so the state is >= HTTP_MSG_BODY. Invalid
* requests are checked first. When waiting for a second request
- * on a keep-alive session, if we encounter and error, close, t/o,
- * we note the error in the session flags but don't set any state.
+ * on a keep-alive stream, if we encounter and error, close, t/o,
+ * we note the error in the stream flags but don't set any state.
* Since the error will be noted there, it will not be counted by
- * process_session() as a frontend error.
+ * process_stream() as a frontend error.
* Last, we may increase some tracked counters' http request errors on
* the cases that are deliberately the client's fault. For instance,
* a timeout or connection reset is not counted as an error. However
* First, let's catch bad requests.
*/
if (unlikely(msg->msg_state == HTTP_MSG_ERROR)) {
- session_inc_http_req_ctr(s);
- session_inc_http_err_ctr(s);
+ stream_inc_http_req_ctr(s);
+ stream_inc_http_err_ctr(s);
proxy_inc_fe_req_ctr(s->fe);
goto return_bad_req;
}
/* 1: Since we are in header mode, if there's no space
* left for headers, we won't be able to free more
- * later, so the session will never terminate. We
+ * later, so the stream will never terminate. We
* must terminate it now.
*/
if (unlikely(buffer_full(req->buf, global.tune.maxrewrite))) {
/* FIXME: check if URI is set and return Status
* 414 Request URI too long instead.
*/
- session_inc_http_req_ctr(s);
- session_inc_http_err_ctr(s);
+ stream_inc_http_req_ctr(s);
+ stream_inc_http_err_ctr(s);
proxy_inc_fe_req_ctr(s->fe);
if (msg->err_pos < 0)
msg->err_pos = req->buf->i;
/* we cannot return any message on error */
if (msg->err_pos >= 0) {
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
}
txn->status = 400;
msg->msg_state = HTTP_MSG_ERROR;
req->analysers = 0;
- session_inc_http_req_ctr(s);
+ stream_inc_http_req_ctr(s);
proxy_inc_fe_req_ctr(s->fe);
s->fe->fe_counters.failed_req++;
if (s->listener->counters)
/* read timeout : give up with an error message. */
if (msg->err_pos >= 0) {
http_capture_bad_message(&s->fe->invalid_req, s, msg, msg->msg_state, s->fe);
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
}
txn->status = 408;
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_408));
msg->msg_state = HTTP_MSG_ERROR;
req->analysers = 0;
- session_inc_http_req_ctr(s);
+ stream_inc_http_req_ctr(s);
proxy_inc_fe_req_ctr(s->fe);
s->fe->fe_counters.failed_req++;
if (s->listener->counters)
msg->msg_state = HTTP_MSG_ERROR;
req->analysers = 0;
- session_inc_http_err_ctr(s);
- session_inc_http_req_ctr(s);
+ stream_inc_http_err_ctr(s);
+ stream_inc_http_req_ctr(s);
proxy_inc_fe_req_ctr(s->fe);
s->fe->fe_counters.failed_req++;
if (s->listener->counters)
* (for instance in the absence of headers).
*/
- session_inc_http_req_ctr(s);
+ stream_inc_http_req_ctr(s);
proxy_inc_fe_req_ctr(s->fe); /* one more valid request for this FE */
if (txn->flags & TX_WAIT_NEXT_RQ) {
* and always relies on the stats applet to complete the job. It does not touch
* analysers nor counters, which are left to the caller. It does not touch
* s->target which is supposed to already point to the stats applet. The caller
- * is expected to have already assigned an appctx to the session.
+ * is expected to have already assigned an appctx to the stream.
*/
-int http_handle_stats(struct session *s, struct channel *req)
+int http_handle_stats(struct stream *s, struct channel *req)
{
struct stats_admin_rule *stats_admin_rule;
struct stream_interface *si = &s->si[1];
#endif
}
-int http_transform_header_str(struct session* s, struct http_msg *msg,
+int http_transform_header_str(struct stream* s, struct http_msg *msg,
const char* name, unsigned int name_len,
const char *str, struct my_regex *re,
int action)
return 0;
}
-static int http_transform_header(struct session* s, struct http_msg *msg,
+static int http_transform_header(struct stream* s, struct http_msg *msg,
const char* name, unsigned int name_len,
struct list *fmt, struct my_regex *re,
int action)
return http_transform_header_str(s, msg, name, name_len, replace->str, re, action);
}
-/* Executes the http-request rules <rules> for session <s>, proxy <px> and
+/* Executes the http-request rules <rules> for stream <s>, proxy <px> and
* transaction <txn>. Returns the verdict of the first rule that prevents
* further processing of the request (auth, deny, ...), and defaults to
* HTTP_RULE_RES_STOP if it executed all rules or stopped on an allow, or
* on txn->flags if it encounters a tarpit rule.
*/
enum rule_result
-http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct session *s, struct http_txn *txn)
+http_req_get_intercept_rule(struct proxy *px, struct list *rules, struct stream *s, struct http_txn *txn)
{
struct connection *cli_conn;
struct http_req_rule *rule;
chunk_printf(&trash, (txn->flags & TX_USE_PX_CONN) ? HTTP_407_fmt : HTTP_401_fmt, auth_realm);
txn->status = (txn->flags & TX_USE_PX_CONN) ? 407 : 401;
stream_int_retnclose(&s->si[0], &trash);
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
return HTTP_RULE_RES_ABRT;
case HTTP_REQ_ACT_REDIR:
key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ | SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
if (key && (ts = stktable_get_entry(t, key))) {
- session_track_stkctr(&s->stkctr[http_req_trk_idx(rule->action)], t, ts);
+ stream_track_stkctr(&s->stkctr[http_req_trk_idx(rule->action)], t, ts);
/* let's count a new HTTP request as it's the first time we do it */
ptr = stktable_data_ptr(t, ts, STKTABLE_DT_HTTP_REQ_CNT);
}
-/* Executes the http-response rules <rules> for session <s>, proxy <px> and
+/* Executes the http-response rules <rules> for stream <s>, proxy <px> and
* transaction <txn>. Returns 3 states: HTTP_RULE_RES_CONT, HTTP_RULE_RES_YIELD
* or HTTP_RULE_RES_STOP. If *CONT is returned, the process can continue the
* evaluation of next rule list. If *STOP is returned, the process must stop
* the same context.
*/
static enum rule_result
-http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct session *s, struct http_txn *txn)
+http_res_get_intercept_rule(struct proxy *px, struct list *rules, struct stream *s, struct http_txn *txn)
{
struct connection *cli_conn;
struct http_res_rule *rule;
* returns non-zero on success, or zero in case of a, irrecoverable error such
* as too large a request to build a valid response.
*/
-static int http_apply_redirect_rule(struct redirect_rule *rule, struct session *s, struct http_txn *txn)
+static int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn)
{
struct http_msg *msg = &txn->req;
const char *msg_fmt;
* either needs more data or wants to immediately abort the request (eg: deny,
* error, ...).
*/
-int http_process_req_common(struct session *s, struct channel *req, int an_bit, struct proxy *px)
+int http_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->req;
goto return_prx_yield;
}
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
req->analysers);
/* just in case we have some per-backend tracking */
- session_inc_be_http_req_ctr(s);
+ stream_inc_be_http_req_ctr(s);
/* evaluate http-request rules */
if (!LIST_ISEMPTY(&px->http_req_rules)) {
req->analyse_exp = tick_add_ifset(now_ms, s->be->timeout.tarpit);
if (!req->analyse_exp)
req->analyse_exp = tick_add(now_ms, 0);
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
s->fe->fe_counters.denied_req++;
if (s->fe != s->be)
s->be->be_counters.denied_req++;
txn->status = 403;
s->logs.tv_request = now;
stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_403));
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
s->fe->fe_counters.denied_req++;
if (s->fe != s->be)
s->be->be_counters.denied_req++;
* needs more data, encounters an error, or wants to immediately abort the
* request. It relies on buffers flags, and updates s->req.analysers.
*/
-int http_process_request(struct session *s, struct channel *req, int an_bit)
+int http_process_request(struct stream *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->req;
return 0;
}
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
* returns zero, at the beginning because it prevents any other processing
* from occurring, and at the end because it terminates the request.
*/
-int http_process_tarpit(struct session *s, struct channel *req, int an_bit)
+int http_process_tarpit(struct stream *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
* HTTP_MSG_CHK_SIZE, HTTP_MSG_DATA or HTTP_MSG_TRAILERS. It returns zero if it
* needs to read more data, or 1 once it has completed its analysis.
*/
-int http_wait_for_request_body(struct session *s, struct channel *req, int an_bit)
+int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.req;
if (!ret)
goto missing_data;
else if (ret < 0) {
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
goto return_bad_req;
}
}
/* Terminate current transaction and prepare a new one. This is very tricky
* right now but it works.
*/
-void http_end_txn_clean_session(struct session *s)
+void http_end_txn_clean_session(struct stream *s)
{
int prev_status = s->txn.status;
}
s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);
- session_process_counters(s);
+ stream_process_counters(s);
if (s->txn.status) {
int n;
}
/* stop tracking content-based counters */
- session_stop_content_counters(s);
- session_update_time_stats(s);
+ stream_stop_content_counters(s);
+ stream_update_time_stats(s);
s->logs.accept_date = date; /* user-visible date for logging */
s->logs.tv_accept = now; /* corrected date for internal use */
s->si[1].err_type = SI_ET_NONE;
s->si[1].conn_retries = 0; /* used for logging too */
s->si[1].exp = TICK_ETERNITY;
- s->si[1].flags &= SI_FL_ISBACK | SI_FL_DONT_WAKE; /* we're in the context of process_session */
+ s->si[1].flags &= SI_FL_ISBACK | SI_FL_DONT_WAKE; /* we're in the context of process_stream */
s->req.flags &= ~(CF_SHUTW|CF_SHUTW_NOW|CF_AUTO_CONNECT|CF_WRITE_ERROR|CF_STREAMER|CF_STREAMER_FAST|CF_NEVER_WAIT|CF_WAKE_CONNECT|CF_WROTE_DATA);
s->res.flags &= ~(CF_SHUTR|CF_SHUTR_NOW|CF_READ_ATTACHED|CF_READ_ERROR|CF_READ_NOEXP|CF_STREAMER|CF_STREAMER_FAST|CF_WRITE_PARTIAL|CF_NEVER_WAIT|CF_WROTE_DATA);
s->flags &= ~(SN_DIRECT|SN_ASSIGNED|SN_ADDR_SET|SN_BE_ASSIGNED|SN_FORCE_PRST|SN_IGNORE_PRST);
* this function and its equivalent should loop until both return zero. It
* can set its own state to DONE, CLOSING, CLOSED, TUNNEL, ERROR.
*/
-int http_sync_req_state(struct session *s)
+int http_sync_req_state(struct stream *s)
{
struct channel *chn = &s->req;
struct http_txn *txn = &s->txn;
* (eg: Linux).
* Note that if we're using keep-alive on the client side, we'd
* rather poll now and keep the polling enabled for the whole
- * session's life than enabling/disabling it between each
+ * stream's life than enabling/disabling it between each
* response and next request.
*/
if (((txn->flags & TX_CON_WANT_MSK) != TX_CON_WANT_SCL) &&
else if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_CLO) {
/* Option forceclose is set, or either side wants to close,
* let's enforce it now that we're not expecting any new
- * data to come. The caller knows the session is complete
+ * data to come. The caller knows the stream is complete
* once both states are CLOSED.
*/
if (!(chn->flags & (CF_SHUTW|CF_SHUTW_NOW))) {
* this function and its equivalent should loop until both return zero. It
* can set its own state to DONE, CLOSING, CLOSED, TUNNEL, ERROR.
*/
-int http_sync_res_state(struct session *s)
+int http_sync_res_state(struct stream *s)
{
struct channel *chn = &s->res;
struct http_txn *txn = &s->txn;
else if ((txn->flags & TX_CON_WANT_MSK) == TX_CON_WANT_CLO) {
/* Option forceclose is set, or either side wants to close,
* let's enforce it now that we're not expecting any new
- * data to come. The caller knows the session is complete
+ * data to come. The caller knows the stream is complete
* once both states are CLOSED.
*/
if (!(chn->flags & (CF_SHUTW|CF_SHUTW_NOW))) {
/* Resync the request and response state machines. Return 1 if either state
* changes.
*/
-int http_resync_states(struct session *s)
+int http_resync_states(struct stream *s)
{
struct http_txn *txn = &s->txn;
int old_req_state = txn->req.msg_state;
* tunnel mode and we want to forward till the close. It's used both to forward
* remaining data and to resync after end of body. It expects the msg_state to
* be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to
- * read more data, or 1 once we can go on with next request or end the session.
+ * read more data, or 1 once we can go on with next request or end the stream.
* When in MSG_DATA or MSG_TRAILERS, it will automatically forward chunk_len
* bytes of pending data + the headers if not already done.
*/
-int http_request_forward_body(struct session *s, struct channel *req, int an_bit)
+int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.req;
if (ret == 0)
goto missing_data;
else if (ret < 0) {
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
if (msg->err_pos >= 0)
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_SIZE, s->be);
goto return_bad_req;
if (ret == 0)
goto missing_data;
else if (ret < 0) {
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
if (msg->err_pos >= 0)
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_CHUNK_CRLF, s->be);
goto return_bad_req;
if (ret == 0)
goto missing_data;
else if (ret < 0) {
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
if (msg->err_pos >= 0)
http_capture_bad_message(&s->fe->invalid_req, s, msg, HTTP_MSG_TRAILERS, s->be);
goto return_bad_req;
* when it has nothing left to do, and may remove any analyser when it wants to
* abort.
*/
-int http_wait_for_response(struct session *s, struct channel *rep, int an_bit)
+int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->rsp;
int cur_idx;
int n;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
rep,
if (!(s->flags & SN_FINST_MASK))
s->flags |= SN_FINST_H;
- /* process_session() will take care of the error */
+ /* process_stream() will take care of the error */
return 0;
}
if (!(s->flags & SN_FINST_MASK))
s->flags |= SN_FINST_H;
- /* process_session() will take care of the error */
+ /* process_stream() will take care of the error */
return 0;
}
* vulnerability scan.
*/
if (n == 4)
- session_inc_http_err_ctr(s);
+ stream_inc_http_err_ctr(s);
if (objt_server(s->target))
objt_server(s->target)->counters.p.http.rsp[n]++;
* and updates s->res.analysers. It might make sense to explode it into several
* other functions. It works like process_request (see indications above).
*/
-int http_process_res_common(struct session *s, struct channel *rep, int an_bit, struct proxy *px)
+int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &txn->rsp;
struct cond_wordlist *wl;
enum rule_result ret = HTTP_RULE_RES_CONT;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
rep,
* tunnel mode and we want to forward till the close. It's used both to forward
* remaining data and to resync after end of body. It expects the msg_state to
* be between MSG_BODY and MSG_DONE (inclusive). It returns zero if it needs to
- * read more data, or 1 once we can go on with next request or end the session.
+ * read more data, or 1 once we can go on with next request or end the stream.
*
* It is capable of compressing response data both in content-length mode and
* in chunked mode. The state machines follows different flows depending on
* is performed at once on final states for all bytes parsed, or when leaving
* on missing data.
*/
-int http_response_forward_body(struct session *s, struct channel *res, int an_bit)
+int http_response_forward_body(struct stream *s, struct channel *res, int an_bit)
{
struct http_txn *txn = &s->txn;
struct http_msg *msg = &s->txn.rsp;
if ((msg->flags & HTTP_MSGF_TE_CHNK) || s->comp_algo)
res->flags |= CF_EXPECT_MORE;
- /* the session handler will take care of timeouts and errors */
+ /* the stream handler will take care of timeouts and errors */
return 0;
return_bad_res: /* let's centralize all bad responses */
* Since it can manage the switch to another backend, it updates the per-proxy
* DENY stats.
*/
-int apply_filter_to_req_headers(struct session *s, struct channel *req, struct hdr_exp *exp)
+int apply_filter_to_req_headers(struct stream *s, struct channel *req, struct hdr_exp *exp)
{
char *cur_ptr, *cur_end, *cur_next;
int cur_idx, old_idx, last_hdr;
break;
/* Swithing Proxy */
- session_set_backend(s, (struct proxy *)exp->replace);
+ stream_set_backend(s, (struct proxy *)exp->replace);
last_hdr = 1;
break;
* Since it can manage the switch to another backend, it updates the per-proxy
* DENY stats.
*/
-int apply_filter_to_req_line(struct session *s, struct channel *req, struct hdr_exp *exp)
+int apply_filter_to_req_line(struct stream *s, struct channel *req, struct hdr_exp *exp)
{
char *cur_ptr, *cur_end;
int done;
break;
/* Swithing Proxy */
- session_set_backend(s, (struct proxy *)exp->replace);
+ stream_set_backend(s, (struct proxy *)exp->replace);
done = 1;
break;
/*
- * Apply all the req filters of proxy <px> to all headers in buffer <req> of session <s>.
+ * Apply all the req filters of proxy <px> to all headers in buffer <req> of stream <s>.
* Returns 0 if everything is alright, or -1 in case a replacement lead to an
* unparsable request. Since it can manage the switch to another backend, it
* updates the per-proxy DENY stats.
*/
-int apply_filters_to_request(struct session *s, struct channel *req, struct proxy *px)
+int apply_filters_to_request(struct stream *s, struct channel *req, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct hdr_exp *exp;
/*
* Try to retrieve the server associated to the appsession.
- * If the server is found, it's assigned to the session.
+ * If the server is found, it's assigned to the stream.
*/
-void manage_client_side_appsession(struct session *s, const char *buf, int len) {
+void manage_client_side_appsession(struct stream *s, const char *buf, int len) {
struct http_txn *txn = &s->txn;
appsess *asession = NULL;
char *sessid_temp = NULL;
}
if (s->be->options2 & PR_O2_AS_REQL) {
- /* request-learn option is enabled : store the sessid in the session for future use */
+ /* request-learn option is enabled : store the sessid in the stream for future use */
if (txn->sessid != NULL) {
- /* free previously allocated memory as we don't need the session id found in the URL anymore */
+ /* free previously allocated memory as we don't need the stream id found in the URL anymore */
pool_free2(apools.sessid, txn->sessid);
}
* of the multiple very crappy and ambiguous syntaxes we have to support. it
* highly recommended not to touch this part without a good reason !
*/
-void manage_client_side_cookies(struct session *s, struct channel *req)
+void manage_client_side_cookies(struct stream *s, struct channel *req)
{
struct http_txn *txn = &s->txn;
int preserve_hdr;
/* Iterate the same filter through all response headers contained in <rtr>.
* Returns 1 if this filter can be stopped upon return, otherwise 0.
*/
-int apply_filter_to_resp_headers(struct session *s, struct channel *rtr, struct hdr_exp *exp)
+int apply_filter_to_resp_headers(struct stream *s, struct channel *rtr, struct hdr_exp *exp)
{
char *cur_ptr, *cur_end, *cur_next;
int cur_idx, old_idx, last_hdr;
* Returns 0 if nothing has been done, 1 if the filter has been applied,
* or -1 if a replacement resulted in an invalid status line.
*/
-int apply_filter_to_sts_line(struct session *s, struct channel *rtr, struct hdr_exp *exp)
+int apply_filter_to_sts_line(struct stream *s, struct channel *rtr, struct hdr_exp *exp)
{
char *cur_ptr, *cur_end;
int done;
/*
- * Apply all the resp filters of proxy <px> to all headers in buffer <rtr> of session <s>.
+ * Apply all the resp filters of proxy <px> to all headers in buffer <rtr> of stream <s>.
* Returns 0 if everything is alright, or -1 in case a replacement lead to an
* unparsable response.
*/
-int apply_filters_to_response(struct session *s, struct channel *rtr, struct proxy *px)
+int apply_filters_to_response(struct stream *s, struct channel *rtr, struct proxy *px)
{
struct http_txn *txn = &s->txn;
struct hdr_exp *exp;
* desirable to call it only when needed. This function is also used when we
* just need to know if there is a cookie (eg: for check-cache).
*/
-void manage_server_side_cookies(struct session *s, struct channel *res)
+void manage_server_side_cookies(struct stream *s, struct channel *res)
{
struct http_txn *txn = &s->txn;
struct server *srv;
/* free a possibly previously allocated memory */
pool_free2(apools.sessid, txn->sessid);
- /* Store the sessid in the session for future use */
+ /* Store the sessid in the stream for future use */
if ((txn->sessid = pool_alloc2(apools.sessid)) == NULL) {
Alert("Not enough Memory process_srv():asession->sessid:malloc().\n");
send_log(s->be, LOG_ALERT, "Not enough Memory process_srv():asession->sessid:malloc().\n");
/*
* Check if response is cacheable or not. Updates s->flags.
*/
-void check_response_for_cacheability(struct session *s, struct channel *rtr)
+void check_response_for_cacheability(struct stream *s, struct channel *rtr)
{
struct http_txn *txn = &s->txn;
char *p1, *p2;
/*
* Try to retrieve a known appsession in the URI, then the associated server.
- * If the server is found, it's assigned to the session.
+ * If the server is found, it's assigned to the stream.
*/
-void get_srv_from_appsession(struct session *s, const char *begin, int len)
+void get_srv_from_appsession(struct stream *s, const char *begin, int len)
{
char *end_params, *first_param, *cur_param, *next_param;
char separator;
* parsing point. The function is able to deal with wrapping buffers. It always
* displays buffers as a contiguous area starting at buf->p.
*/
-void http_capture_bad_message(struct error_snapshot *es, struct session *s,
+void http_capture_bad_message(struct error_snapshot *es, struct stream *s,
struct http_msg *msg,
enum ht_state state, struct proxy *other_end)
{
* so it is safe to pass it a full buffer if needed. If <err> is not NULL, an
* arrow is printed after the line which contains the pointer.
*/
-void debug_hdr(const char *dir, struct session *s, const char *start, const char *end)
+void debug_hdr(const char *dir, struct stream *s, const char *start, const char *end)
{
int max;
chunk_printf(&trash, "%08x:%s.%s[%04x:%04x]: ", s->uniq_id, s->be->id,
}
/*
- * Initialize a new HTTP transaction for session <s>. It is assumed that all
+ * Initialize a new HTTP transaction for stream <s>. It is assumed that all
* the required fields are properly allocated and that we only need to (re)init
* them. This should be used before processing any new request.
*/
-void http_init_txn(struct session *s)
+void http_init_txn(struct stream *s)
{
struct http_txn *txn = &s->txn;
struct proxy *fe = s->fe;
}
/* to be used at the end of a transaction */
-void http_end_txn(struct session *s)
+void http_end_txn(struct stream *s)
{
struct http_txn *txn = &s->txn;
}
/* to be used at the end of a transaction to prepare a new one */
-void http_reset_txn(struct session *s)
+void http_reset_txn(struct stream *s)
{
http_end_txn(s);
http_init_txn(s);
s->be = s->fe;
s->logs.logwait = s->fe->to_log;
s->logs.level = 0;
- session_del_srv_conn(s);
+ stream_del_srv_conn(s);
s->target = NULL;
/* re-init store persistence */
s->store_count = 0;
* 1 if an HTTP message is ready
*/
static int
-smp_prefetch_http(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_prefetch_http(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, int req_vol)
{
struct http_txn *txn = l7;
* This is intended to be used with pat_match_meth() only.
*/
static int
-smp_fetch_meth(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_meth(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int meth;
}
static int
-smp_fetch_rqver(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_rqver(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
}
static int
-smp_fetch_stver(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_stver(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
/* 3. Check on Status Code. We manipulate integers here. */
static int
-smp_fetch_stcode(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_stcode(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
/* 4. Check on URL/URI. A pointer to the URI is stored. */
static int
-smp_fetch_url(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
}
static int
-smp_fetch_url_ip(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url_ip(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
}
static int
-smp_fetch_url_port(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url_port(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* returns full lines instead (useful for User-Agent or Date for example).
*/
static int
-smp_fetch_fhdr(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fhdr(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* returns full lines instead (useful for User-Agent or Date for example).
*/
static int
-smp_fetch_fhdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_fhdr_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
}
static int
-smp_fetch_hdr_names(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_hdr_names(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* headers are considered from the first one.
*/
static int
-smp_fetch_hdr(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_hdr(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* Accepts exactly 1 argument of type string.
*/
static int
-smp_fetch_hdr_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_hdr_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* may or may not be appropriate for everything.
*/
static int
-smp_fetch_hdr_val(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_hdr_val(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int ret = smp_fetch_hdr(px, l4, l7, opt, args, smp, kw, private);
* It returns an IPv4 or IPv6 address.
*/
static int
-smp_fetch_hdr_ip(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_hdr_ip(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int ret;
* the first '/' after the possible hostname, and ends before the possible '?'.
*/
static int
-smp_fetch_path(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_path(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* The returned sample is of type string.
*/
static int
-smp_fetch_base(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_base(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* high-traffic sites without having to store whole paths.
*/
int
-smp_fetch_base32(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_base32(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* 8 bytes would still work.
*/
static int
-smp_fetch_base32_src(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_base32_src(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct chunk *temp;
* of type string carrying the whole query string.
*/
static int
-smp_fetch_query(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_query(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
}
static int
-smp_fetch_proto_http(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_proto_http(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
/* Note: hdr_idx.v cannot be NULL in this ACL because the ACL is tagged
/* return a valid test if the current request is the first one on the connection */
static int
-smp_fetch_http_first_req(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_http_first_req(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
if (!s)
/* Accepts exactly 1 argument of type userlist */
static int
-smp_fetch_http_auth(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_http_auth(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
/* Accepts exactly 1 argument of type userlist */
static int
-smp_fetch_http_auth_grp(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_http_auth_grp(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
* the "capture" option in the configuration file
*/
static int
-smp_fetch_capture_header_req(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_header_req(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct proxy *fe = l4->fe;
* the "capture" option in the configuration file
*/
static int
-smp_fetch_capture_header_res(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_header_res(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct proxy *fe = l4->fe;
/* Extracts the METHOD in the HTTP request, the txn->uri should be filled before the call */
static int
-smp_fetch_capture_req_method(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_req_method(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct chunk *temp;
/* Extracts the path in the HTTP request, the txn->uri should be filled before the call */
static int
-smp_fetch_capture_req_uri(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_req_uri(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct chunk *temp;
* as a string (either "HTTP/1.0" or "HTTP/1.1").
*/
static int
-smp_fetch_capture_req_ver(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_req_ver(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* as a string (either "HTTP/1.0" or "HTTP/1.1").
*/
static int
-smp_fetch_capture_res_ver(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_capture_res_ver(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* The returned sample is of type CSTR. Can be used to parse cookies in other
* files.
*/
-int smp_fetch_cookie(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+int smp_fetch_cookie(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* type UINT. Accepts exactly 1 argument of type string.
*/
static int
-smp_fetch_cookie_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_cookie_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* takes a mandatory argument of type string. It relies on smp_fetch_cookie().
*/
static int
-smp_fetch_cookie_val(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_cookie_val(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int ret = smp_fetch_cookie(px, l4, l7, opt, args, smp, kw, private);
}
static int
-smp_fetch_url_param(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url_param(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
char delim = '?';
* above).
*/
static int
-smp_fetch_url_param_val(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url_param_val(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int ret = smp_fetch_url_param(px, l4, l7, opt, args, smp, kw, private);
* as well as the path
*/
static int
-smp_fetch_url32(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url32(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct http_txn *txn = l7;
* 8 bytes would still work.
*/
static int
-smp_fetch_url32_src(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_url32_src(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct chunk *temp;
* adds an optional offset found in args[0] and emits a string representing
* the date in RFC-1123/5322 format.
*/
-static int sample_conv_http_date(struct session *session, const struct arg *args,
+static int sample_conv_http_date(struct stream *stream, const struct arg *args,
struct sample *smp, void *private)
{
const char day[7][4] = { "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
}
/* Arguments: The list of expected value, the number of parts returned and the separator */
-static int sample_conv_q_prefered(struct session *session, const struct arg *args,
+static int sample_conv_q_prefered(struct stream *stream, const struct arg *args,
struct sample *smp, void *private)
{
const char *al = smp->data.str.str;
* string by the caller, event if the replacement query string is empty.
*/
int http_replace_req_line(int action, const char *replace, int len,
- struct proxy *px, struct session *s, struct http_txn *txn)
+ struct proxy *px, struct stream *s, struct http_txn *txn)
{
char *cur_ptr, *cur_end;
int offset = 0;
* http_action_set_req_line_exec(). It always returns 1. If an error occurs
* the action is canceled, but the rule processing continue.
*/
-int http_action_set_req_line(struct http_req_rule *rule, struct proxy *px, struct session *s, struct http_txn *txn)
+int http_action_set_req_line(struct http_req_rule *rule, struct proxy *px, struct stream *s, struct http_txn *txn)
{
chunk_reset(&trash);
{ "base32", smp_fetch_base32, 0, NULL, SMP_T_UINT, SMP_USE_HRQHV },
{ "base32+src", smp_fetch_base32_src, 0, NULL, SMP_T_BIN, SMP_USE_HRQHV },
- /* capture are allocated and are permanent in the session */
+ /* capture are allocated and are permanent in the stream */
{ "capture.req.hdr", smp_fetch_capture_header_req, ARG1(1, UINT), NULL, SMP_T_STR, SMP_USE_HRQHP },
/* retrieve these captures from the HTTP logs */
#include <proto/proto_tcp.h>
#include <proto/proxy.h>
#include <proto/sample.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stick_table.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
* function may be called for frontend rules and backend rules. It only relies
* on the backend pointer so this works for both cases.
*/
-int tcp_inspect_request(struct session *s, struct channel *req, int an_bit)
+int tcp_inspect_request(struct stream *s, struct channel *req, int an_bit)
{
struct tcp_rule *rule;
struct stksess *ts;
struct stktable *t;
int partial;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
goto missing_data; /* key might appear later */
if (key && (ts = stktable_get_entry(t, key))) {
- session_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
+ stream_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_CONTENT);
if (s->fe != s->be)
stkctr_set_flags(&s->stkctr[tcp_trk_idx(rule->action)], STKCTR_TRACK_BACKEND);
* response. It relies on buffers flags, and updates s->rep->analysers. The
* function may be called for backend rules.
*/
-int tcp_inspect_response(struct session *s, struct channel *rep, int an_bit)
+int tcp_inspect_response(struct stream *s, struct channel *rep, int an_bit)
{
struct tcp_rule *rule;
int partial;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
rep,
* matches or if no more rule matches. It can only use rules which don't need
* any data. This only works on connection-based client-facing stream interfaces.
*/
-int tcp_exec_req_rules(struct session *s)
+int tcp_exec_req_rules(struct stream *s)
{
struct tcp_rule *rule;
struct stksess *ts;
key = stktable_fetch_key(t, s->be, s, &s->txn, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->act_prm.trk_ctr.expr, NULL);
if (key && (ts = stktable_get_entry(t, key)))
- session_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
+ stream_track_stkctr(&s->stkctr[tcp_trk_idx(rule->action)], t, ts);
}
else if (rule->action == TCP_ACT_EXPECT_PX) {
conn->flags |= CO_FL_ACCEPT_PROXY;
/* fetch the connection's source IPv4/IPv6 address */
static int
-smp_fetch_src(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_src(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *cli_conn = objt_conn(l4->si[0].end);
/* set temp integer to the connection's source port */
static int
-smp_fetch_sport(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sport(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *k, void *private)
{
struct connection *cli_conn = objt_conn(l4->si[0].end);
/* fetch the connection's destination IPv4/IPv6 address */
static int
-smp_fetch_dst(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_dst(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *cli_conn = objt_conn(l4->si[0].end);
/* set temp integer to the frontend connexion's destination port */
static int
-smp_fetch_dport(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_dport(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *cli_conn = objt_conn(l4->si[0].end);
/*
* This is the proxy management task. It enables proxies when there are enough
- * free sessions, or stops them when the table is full. It is designed to be
+ * free streams, or stops them when the table is full. It is designed to be
* called as a task which is woken up upon stopping or when rate limiting must
* be enforced.
*/
/* If the proxy holds a stick table, we need to purge all unused
* entries. These are all the ones in the table with ref_cnt == 0
* and all the ones in the pool used to allocate new entries. Any
- * entry attached to an existing session waiting for a store will
+ * entry attached to an existing stream waiting for a store will
* be in neither list. Any entry being dumped will have ref_cnt > 0.
* However we protect tables that are being synced to peers.
*/
}
}
-/* Set current session's backend to <be>. Nothing is done if the
- * session already had a backend assigned, which is indicated by
+/* Set current stream's backend to <be>. Nothing is done if the
+ * stream already had a backend assigned, which is indicated by
* s->flags & SN_BE_ASSIGNED.
* All flags, stats and counters which need be updated are updated.
* Returns 1 if done, 0 in case of internal error, eg: lack of resource.
*/
-int session_set_backend(struct session *s, struct proxy *be)
+int stream_set_backend(struct stream *s, struct proxy *be)
{
if (s->flags & SN_BE_ASSIGNED)
return 1;
be->be_counters.conn_max = be->beconn;
proxy_inc_be_ctr(be);
- /* assign new parameters to the session from the new backend */
+ /* assign new parameters to the stream from the new backend */
s->si[1].flags &= ~SI_FL_INDEP_STR;
if (be->options2 & PR_O2_INDEPSTR)
s->si[1].flags |= SI_FL_INDEP_STR;
#include <proto/queue.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
/*
* Manages a server's connection queue. This function will try to dequeue as
- * many pending sessions as possible, and wake them up.
+ * many pending streams as possible, and wake them up.
*/
void process_srv_queue(struct server *s)
{
maxconn = srv_dynamic_maxconn(s);
while (s->served < maxconn) {
- struct session *sess = pendconn_get_next_sess(s, p);
- if (sess == NULL)
+ struct stream *strm = pendconn_get_next_strm(s, p);
+
+ if (strm == NULL)
break;
- task_wakeup(sess->task, TASK_WOKEN_RES);
+ task_wakeup(strm->task, TASK_WOKEN_RES);
}
}
/* Detaches the next pending connection from either a server or a proxy, and
- * returns its associated session. If no pending connection is found, NULL is
+ * returns its associated stream. If no pending connection is found, NULL is
* returned. Note that neither <srv> nor <px> may be NULL.
* Priority is given to the oldest request in the queue if both <srv> and <px>
* have pending requests. This ensures that no request will be left unserved.
* queue is still considered in this case, because if some connections remain
* there, it means that some requests have been forced there after it was seen
* down (eg: due to option persist).
- * The session is immediately marked as "assigned", and both its <srv> and
+ * The stream is immediately marked as "assigned", and both its <srv> and
* <srv_conn> are set to <srv>,
*/
-struct session *pendconn_get_next_sess(struct server *srv, struct proxy *px)
+struct stream *pendconn_get_next_strm(struct server *srv, struct proxy *px)
{
struct pendconn *ps, *pp;
- struct session *sess;
+ struct stream *strm;
struct server *rsrv;
rsrv = srv->track;
return NULL;
} else {
/* pendconn exists in the proxy queue */
- if (!ps || tv_islt(&pp->sess->logs.tv_request, &ps->sess->logs.tv_request))
+ if (!ps || tv_islt(&pp->strm->logs.tv_request, &ps->strm->logs.tv_request))
ps = pp;
}
- sess = ps->sess;
+ strm = ps->strm;
pendconn_free(ps);
- /* we want to note that the session has now been assigned a server */
- sess->flags |= SN_ASSIGNED;
- sess->target = &srv->obj_type;
- session_add_srv_conn(sess, srv);
+ /* we want to note that the stream has now been assigned a server */
+ strm->flags |= SN_ASSIGNED;
+ strm->target = &srv->obj_type;
+ stream_add_srv_conn(strm, srv);
srv->served++;
if (px->lbprm.server_take_conn)
px->lbprm.server_take_conn(srv);
- return sess;
+ return strm;
}
-/* Adds the session <sess> to the pending connection list of server <sess>->srv
- * or to the one of <sess>->proxy if srv is NULL. All counters and back pointers
+/* Adds the stream <strm> to the pending connection list of server <strm>->srv
+ * or to the one of <strm>->proxy if srv is NULL. All counters and back pointers
* are updated accordingly. Returns NULL if no memory is available, otherwise the
- * pendconn itself. If the session was already marked as served, its flag is
- * cleared. It is illegal to call this function with a non-NULL sess->srv_conn.
+ * pendconn itself. If the stream was already marked as served, its flag is
+ * cleared. It is illegal to call this function with a non-NULL strm->srv_conn.
*/
-struct pendconn *pendconn_add(struct session *sess)
+struct pendconn *pendconn_add(struct stream *strm)
{
struct pendconn *p;
struct server *srv;
if (!p)
return NULL;
- sess->pend_pos = p;
- p->sess = sess;
- p->srv = srv = objt_server(sess->target);
+ strm->pend_pos = p;
+ p->strm = strm;
+ p->srv = srv = objt_server(strm->target);
- if (sess->flags & SN_ASSIGNED && srv) {
+ if (strm->flags & SN_ASSIGNED && srv) {
LIST_ADDQ(&srv->pendconns, &p->list);
srv->nbpend++;
- sess->logs.srv_queue_size += srv->nbpend;
+ strm->logs.srv_queue_size += srv->nbpend;
if (srv->nbpend > srv->counters.nbpend_max)
srv->counters.nbpend_max = srv->nbpend;
} else {
- LIST_ADDQ(&sess->be->pendconns, &p->list);
- sess->be->nbpend++;
- sess->logs.prx_queue_size += sess->be->nbpend;
- if (sess->be->nbpend > sess->be->be_counters.nbpend_max)
- sess->be->be_counters.nbpend_max = sess->be->nbpend;
+ LIST_ADDQ(&strm->be->pendconns, &p->list);
+ strm->be->nbpend++;
+ strm->logs.prx_queue_size += strm->be->nbpend;
+ if (strm->be->nbpend > strm->be->be_counters.nbpend_max)
+ strm->be->be_counters.nbpend_max = strm->be->nbpend;
}
- sess->be->totpend++;
+ strm->be->totpend++;
return p;
}
int xferred = 0;
list_for_each_entry_safe(pc, pc_bck, &s->pendconns, list) {
- struct session *sess = pc->sess;
+ struct stream *strm = pc->strm;
- if ((sess->be->options & (PR_O_REDISP|PR_O_PERSIST)) == PR_O_REDISP &&
- !(sess->flags & SN_FORCE_PRST)) {
+ if ((strm->be->options & (PR_O_REDISP|PR_O_PERSIST)) == PR_O_REDISP &&
+ !(strm->flags & SN_FORCE_PRST)) {
/* The REDISP option was specified. We will ignore
* cookie and force to balance or use the dispatcher.
*/
/* it's left to the dispatcher to choose a server */
- sess->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
+ strm->flags &= ~(SN_DIRECT | SN_ASSIGNED | SN_ADDR_SET);
pendconn_free(pc);
- task_wakeup(sess->task, TASK_WOKEN_RES);
+ task_wakeup(strm->task, TASK_WOKEN_RES);
xferred++;
}
}
return 0;
for (xferred = 0; !s->maxconn || xferred < srv_dynamic_maxconn(s); xferred++) {
- struct session *sess;
+ struct stream *strm;
struct pendconn *p;
p = pendconn_from_px(s->proxy);
if (!p)
break;
- p->sess->target = &s->obj_type;
- sess = p->sess;
+ p->strm->target = &s->obj_type;
+ strm = p->strm;
pendconn_free(p);
- task_wakeup(sess->task, TASK_WOKEN_RES);
+ task_wakeup(strm->task, TASK_WOKEN_RES);
}
return xferred;
}
/*
* Detaches pending connection <p>, decreases the pending count, and frees
* the pending connection. The connection might have been queued to a specific
- * server as well as to the proxy. The session also gets marked unqueued.
+ * server as well as to the proxy. The stream also gets marked unqueued.
*/
void pendconn_free(struct pendconn *p)
{
LIST_DEL(&p->list);
- p->sess->pend_pos = NULL;
+ p->strm->pend_pos = NULL;
if (p->srv)
p->srv->nbpend--;
else
- p->sess->be->nbpend--;
- p->sess->be->totpend--;
+ p->strm->be->nbpend--;
+ p->strm->be->totpend--;
pool_free2(pool2_pendconn, p);
}
* smp 1 0 Present, may change (eg: request length)
* smp 1 1 Present, last known value (eg: request length)
*/
-struct sample *sample_process(struct proxy *px, struct session *l4, void *l7,
+struct sample *sample_process(struct proxy *px, struct stream *l4, void *l7,
unsigned int opt,
struct sample_expr *expr, struct sample *p)
{
* smp 1 0 Not present yet, may appear later (eg: header)
* smp 1 1 never happens (either flag is cleared on output)
*/
-struct sample *sample_fetch_string(struct proxy *px, struct session *l4, void *l7,
+struct sample *sample_fetch_string(struct proxy *px, struct stream *l4, void *l7,
unsigned int opt, struct sample_expr *expr)
{
struct sample *smp = &temp_smp;
/* These functions set the data type on return. */
/*****************************************************************/
-static int sample_conv_bin2base64(struct session *session, const struct arg *arg_p,
+static int sample_conv_bin2base64(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct chunk *trash = get_trash_chunk();
return 1;
}
-static int sample_conv_bin2hex(struct session *session, const struct arg *arg_p,
+static int sample_conv_bin2hex(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct chunk *trash = get_trash_chunk();
}
/* hashes the binary input into a 32-bit unsigned int */
-static int sample_conv_djb2(struct session *session, const struct arg *arg_p,
+static int sample_conv_djb2(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = hash_djb2(smp->data.str.str, smp->data.str.len);
return 1;
}
-static int sample_conv_str2lower(struct session *session, const struct arg *arg_p,
+static int sample_conv_str2lower(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
int i;
return 1;
}
-static int sample_conv_str2upper(struct session *session, const struct arg *arg_p,
+static int sample_conv_str2upper(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
int i;
}
/* takes the netmask in arg_p */
-static int sample_conv_ipmask(struct session *session, const struct arg *arg_p,
+static int sample_conv_ipmask(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.ipv4.s_addr &= arg_p->data.ipv4.s_addr;
* adds an optional offset found in args[1] and emits a string representing
* the local time in the format specified in args[1] using strftime().
*/
-static int sample_conv_ltime(struct session *session, const struct arg *args,
+static int sample_conv_ltime(struct stream *stream, const struct arg *args,
struct sample *smp, void *private)
{
struct chunk *temp;
}
/* hashes the binary input into a 32-bit unsigned int */
-static int sample_conv_sdbm(struct session *session, const struct arg *arg_p,
+static int sample_conv_sdbm(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = hash_sdbm(smp->data.str.str, smp->data.str.len);
* adds an optional offset found in args[1] and emits a string representing
* the UTC date in the format specified in args[1] using strftime().
*/
-static int sample_conv_utime(struct session *session, const struct arg *args,
+static int sample_conv_utime(struct stream *stream, const struct arg *args,
struct sample *smp, void *private)
{
struct chunk *temp;
}
/* hashes the binary input into a 32-bit unsigned int */
-static int sample_conv_wt6(struct session *session, const struct arg *arg_p,
+static int sample_conv_wt6(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = hash_wt6(smp->data.str.str, smp->data.str.len);
}
/* hashes the binary input into a 32-bit unsigned int */
-static int sample_conv_crc32(struct session *session, const struct arg *arg_p,
+static int sample_conv_crc32(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = hash_crc32(smp->data.str.str, smp->data.str.len);
return 0;
}
-static int sample_conv_json(struct session *session, const struct arg *arg_p,
+static int sample_conv_json(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct chunk *temp;
/* This sample function is designed to extract some bytes from an input buffer.
* First arg is the offset.
* Optional second arg is the length to truncate */
-static int sample_conv_bytes(struct session *session, const struct arg *arg_p,
+static int sample_conv_bytes(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
if (smp->data.str.len <= arg_p[0].data.uint) {
* First arg is the index of the field (start at 1)
* Second arg is a char list of separators (type string)
*/
-static int sample_conv_field(struct session *session, const struct arg *arg_p,
+static int sample_conv_field(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
unsigned int field;
* First arg is the index of the word (start at 1)
* Second arg is a char list of words separators (type string)
*/
-static int sample_conv_word(struct session *session, const struct arg *arg_p,
+static int sample_conv_word(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
unsigned int word;
* location until nothing matches anymore. First arg is the regex to apply to
* the input string, second arg is the replacement expression.
*/
-static int sample_conv_regsub(struct session *session, const struct arg *arg_p,
+static int sample_conv_regsub(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
char *start, *end;
/* Takes a UINT on input, applies a binary twos complement and returns the UINT
* result.
*/
-static int sample_conv_binary_cpl(struct session *session, const struct arg *arg_p,
+static int sample_conv_binary_cpl(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = ~smp->data.uint;
/* Takes a UINT on input, applies a binary "and" with the UINT in arg_p, and
* returns the UINT result.
*/
-static int sample_conv_binary_and(struct session *session, const struct arg *arg_p,
+static int sample_conv_binary_and(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint &= arg_p->data.uint;
/* Takes a UINT on input, applies a binary "or" with the UINT in arg_p, and
* returns the UINT result.
*/
-static int sample_conv_binary_or(struct session *session, const struct arg *arg_p,
+static int sample_conv_binary_or(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint |= arg_p->data.uint;
/* Takes a UINT on input, applies a binary "xor" with the UINT in arg_p, and
* returns the UINT result.
*/
-static int sample_conv_binary_xor(struct session *session, const struct arg *arg_p,
+static int sample_conv_binary_xor(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint ^= arg_p->data.uint;
/* Takes a UINT on input, applies an arithmetic "add" with the UINT in arg_p,
* and returns the UINT result.
*/
-static int sample_conv_arith_add(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_add(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint += arg_p->data.uint;
/* Takes a UINT on input, applies an arithmetic "sub" with the UINT in arg_p,
* and returns the UINT result.
*/
-static int sample_conv_arith_sub(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_sub(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint -= arg_p->data.uint;
/* Takes a UINT on input, applies an arithmetic "mul" with the UINT in arg_p,
* and returns the UINT result.
*/
-static int sample_conv_arith_mul(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_mul(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint *= arg_p->data.uint;
* and returns the UINT result. If arg_p makes the result overflow, then the
* largest possible quantity is returned.
*/
-static int sample_conv_arith_div(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_div(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
if (arg_p->data.uint)
* and returns the UINT result. If arg_p makes the result overflow, then zero
* is returned.
*/
-static int sample_conv_arith_mod(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_mod(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
if (arg_p->data.uint)
/* Takes an UINT on input, applies an arithmetic "neg" and returns the UINT
* result.
*/
-static int sample_conv_arith_neg(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_neg(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = -smp->data.uint;
/* Takes a UINT on input, returns true is the value is non-null, otherwise
* false. The output is a BOOL.
*/
-static int sample_conv_arith_bool(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_bool(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = !!smp->data.uint;
/* Takes a UINT on input, returns false is the value is non-null, otherwise
* truee. The output is a BOOL.
*/
-static int sample_conv_arith_not(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_not(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = !smp->data.uint;
/* Takes a UINT on input, returns true is the value is odd, otherwise false.
* The output is a BOOL.
*/
-static int sample_conv_arith_odd(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_odd(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = smp->data.uint & 1;
/* Takes a UINT on input, returns true is the value is even, otherwise false.
* The output is a BOOL.
*/
-static int sample_conv_arith_even(struct session *session, const struct arg *arg_p,
+static int sample_conv_arith_even(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
smp->data.uint = !(smp->data.uint & 1);
/* force TRUE to be returned at the fetch level */
static int
-smp_fetch_true(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_true(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_BOOL;
/* force FALSE to be returned at the fetch level */
static int
-smp_fetch_false(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_false(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_BOOL;
/* retrieve environment variable $1 as a string */
static int
-smp_fetch_env(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_env(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
char *env;
* of args[0] seconds.
*/
static int
-smp_fetch_date(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_date(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->data.uint = date.tv_sec;
/* returns the number of processes */
static int
-smp_fetch_nbproc(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_nbproc(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_UINT;
/* returns the number of the current process (between 1 and nbproc */
static int
-smp_fetch_proc(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_proc(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_UINT;
* range specified in argument.
*/
static int
-smp_fetch_rand(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_rand(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->data.uint = random();
/* returns true if the current process is stopping */
static int
-smp_fetch_stopping(struct proxy *px, struct session *s, void *l7, unsigned int opt,
+smp_fetch_stopping(struct proxy *px, struct stream *s, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->type = SMP_T_BOOL;
#include <proto/queue.h>
#include <proto/raw_sock.h>
#include <proto/server.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/task.h>
* code in <why>, which must be one of SN_ERR_* indicating the reason for the
* shutdown.
*/
-void srv_shutdown_sessions(struct server *srv, int why)
+void srv_shutdown_streams(struct server *srv, int why)
{
- struct session *session, *session_bck;
+ struct stream *stream, *stream_bck;
- list_for_each_entry_safe(session, session_bck, &srv->actconns, by_srv)
- if (session->srv_conn == srv)
- session_shutdown(session, why);
+ list_for_each_entry_safe(stream, stream_bck, &srv->actconns, by_srv)
+ if (stream->srv_conn == srv)
+ stream_shutdown(stream, why);
}
/* Shutdown all connections of all backup servers of a proxy. The caller must
* pass a termination code in <why>, which must be one of SN_ERR_* indicating
* the reason for the shutdown.
*/
-void srv_shutdown_backup_sessions(struct proxy *px, int why)
+void srv_shutdown_backup_streams(struct proxy *px, int why)
{
struct server *srv;
for (srv = px->srv; srv != NULL; srv = srv->next)
if (srv->flags & SRV_F_BACKUP)
- srv_shutdown_sessions(srv, why);
+ srv_shutdown_streams(srv, why);
}
/* Appends some information to a message string related to a server going UP or
* one, a "via" information will be provided to know where the status came from.
* If <reason> is non-null, the entire string will be appended after a comma and
* a space (eg: to report some information from the check that changed the state).
- * If <xferred> is non-negative, some information about requeued sessions are
+ * If <xferred> is non-negative, some information about requeued streams are
* provided.
*/
void srv_append_status(struct chunk *msg, struct server *s, const char *reason, int xferred, int forced)
/* Marks server <s> down, regardless of its checks' statuses, notifies by all
* available means, recounts the remaining servers on the proxy and transfers
- * queued sessions whenever possible to other servers. It automatically
+ * queued streams whenever possible to other servers. It automatically
* recomputes the number of servers, but not the map. Maintenance servers are
* ignored. It reports <reason> if non-null as the reason for going down. Note
* that it makes use of the trash to build the log strings, so <reason> must
s->proxy->lbprm.set_server_status_down(s);
if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS)
- srv_shutdown_sessions(s, SN_ERR_DOWN);
+ srv_shutdown_streams(s, SN_ERR_DOWN);
- /* we might have sessions queued on this server and waiting for
+ /* we might have streams queued on this server and waiting for
* a connection. Those which are redispatchable will be queued
* to another server or to the proxy itself.
*/
/* If the server is set with "on-marked-up shutdown-backup-sessions",
* and it's not a backup server and its effective weight is > 0,
- * then it can accept new connections, so we shut down all sessions
+ * then it can accept new connections, so we shut down all streams
* on all backup servers.
*/
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
!(s->flags & SRV_F_BACKUP) && s->eweight)
- srv_shutdown_backup_sessions(s->proxy, SN_ERR_UP);
+ srv_shutdown_backup_streams(s->proxy, SN_ERR_UP);
/* check if we can handle some connections queued at the proxy. We
* will take as many as we can handle.
if (s->proxy->lbprm.set_server_status_down)
s->proxy->lbprm.set_server_status_down(s);
- /* we might have sessions queued on this server and waiting for
+ /* we might have streams queued on this server and waiting for
* a connection. Those which are redispatchable will be queued
* to another server or to the proxy itself.
*/
s->proxy->lbprm.set_server_status_down(s);
if (s->onmarkeddown & HANA_ONMARKEDDOWN_SHUTDOWNSESSIONS)
- srv_shutdown_sessions(s, SN_ERR_DOWN);
+ srv_shutdown_streams(s, SN_ERR_DOWN);
- /* we might have sessions queued on this server and waiting for
+ /* we might have streams queued on this server and waiting for
* a connection. Those which are redispatchable will be queued
* to another server or to the proxy itself.
*/
if (s->proxy->lbprm.set_server_status_down)
s->proxy->lbprm.set_server_status_down(s);
- /* we might have sessions queued on this server and waiting for
+ /* we might have streams queued on this server and waiting for
* a connection. Those which are redispatchable will be queued
* to another server or to the proxy itself.
*/
/* If the server is set with "on-marked-up shutdown-backup-sessions",
* and it's not a backup server and its effective weight is > 0,
- * then it can accept new connections, so we shut down all sessions
+ * then it can accept new connections, so we shut down all streams
* on all backup servers.
*/
if ((s->onmarkedup & HANA_ONMARKEDUP_SHUTDOWNBACKUPSESSIONS) &&
!(s->flags & SRV_F_BACKUP) && s->eweight)
- srv_shutdown_backup_sessions(s->proxy, SN_ERR_UP);
+ srv_shutdown_backup_streams(s->proxy, SN_ERR_UP);
/* check if we can handle some connections queued at the proxy. We
* will take as many as we can handle.
/* boolean, returns true if client cert was present */
static int
-smp_fetch_ssl_fc_has_crt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_has_crt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
* should be use.
*/
static int
-smp_fetch_ssl_x_der(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_der(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_serial(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_serial(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_sha1(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_sha1(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_notafter(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_notafter(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_i_dn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_i_dn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_notbefore(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_notbefore(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_s_dn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_s_dn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
/* integer, returns true if current session use a client certificate */
static int
-smp_fetch_ssl_c_used(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_c_used(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
X509 *crt;
* should be use.
*/
static int
-smp_fetch_ssl_x_version(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_version(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_sig_alg(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_sig_alg(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* should be use.
*/
static int
-smp_fetch_ssl_x_key_alg(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_x_key_alg(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int cert_peer = (kw[4] == 'c') ? 1 : 0;
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int back_conn = (kw[4] == 'b') ? 1 : 0;
/* boolean, returns true if client present a SNI */
static int
-smp_fetch_ssl_fc_has_sni(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_has_sni(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc_cipher(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_cipher(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int back_conn = (kw[4] == 'b') ? 1 : 0;
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc_alg_keysize(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_alg_keysize(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int back_conn = (kw[4] == 'b') ? 1 : 0;
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc_use_keysize(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_use_keysize(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int back_conn = (kw[4] == 'b') ? 1 : 0;
#ifdef OPENSSL_NPN_NEGOTIATED
static int
-smp_fetch_ssl_fc_npn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_npn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
static int
-smp_fetch_ssl_fc_alpn(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_alpn(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc_protocol(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_protocol(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
int back_conn = (kw[4] == 'b') ? 1 : 0;
return 1;
}
-/* binary, returns the SSL session id if front conn. transport layer is SSL.
+/* binary, returns the SSL stream id if front conn. transport layer is SSL.
* This function is also usable on backend conn if the fetch keyword 5th
* char is 'b'.
*/
static int
-smp_fetch_ssl_fc_session_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_session_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
#if OPENSSL_VERSION_NUMBER > 0x0090800fL
}
static int
-smp_fetch_ssl_fc_sni(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_sni(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
}
static int
-smp_fetch_ssl_fc_unique_id(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_fc_unique_id(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
#if OPENSSL_VERSION_NUMBER > 0x0090800fL
/* integer, returns the first verify error in CA chain of client certificate chain. */
static int
-smp_fetch_ssl_c_ca_err(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_c_ca_err(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
/* integer, returns the depth of the first verify error in CA chain of client certificate chain. */
static int
-smp_fetch_ssl_c_ca_err_depth(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_c_ca_err_depth(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
/* integer, returns the first verify error on client certificate */
static int
-smp_fetch_ssl_c_err(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_c_err(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
/* integer, returns the verify result on client cert */
static int
-smp_fetch_ssl_c_verify(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_ssl_c_verify(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn;
#include <proto/arg.h>
#include <proto/proxy.h>
#include <proto/sample.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stick_table.h>
#include <proto/task.h>
#include <proto/peers.h>
* smp 1 0 not possible
* smp 1 1 Present, last known value (eg: request length)
*/
-struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7,
+struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct stream *l4, void *l7,
unsigned int opt, struct sample_expr *expr, struct sample *smp)
{
if (smp)
* the table's type. This is a double conversion, but in the future we might
* support automatic input types to perform the cast on the fly.
*/
-static int sample_conv_in_table(struct session *session, const struct arg *arg_p,
+static int sample_conv_in_table(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_bytes_in_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_bytes_in_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_conn_cnt(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_conn_cnt(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
-static int sample_conv_table_conn_cur(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_conn_cur(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_conn_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_conn_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_bytes_out_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_bytes_out_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_gpc0(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_gpc0(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_gpc0_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_gpc0_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* comparisons can be easily performed. If the inspected parameter is not stored
* in the table, <not found> is returned.
*/
-static int sample_conv_table_http_err_cnt(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_http_err_cnt(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_http_err_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_http_err_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
-static int sample_conv_table_http_req_cnt(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_http_req_cnt(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* performed. If the inspected parameter is not stored in the table, <not found>
* is returned.
*/
-static int sample_conv_table_http_req_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_http_req_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_kbytes_in(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_kbytes_in(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* be easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_kbytes_out(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_kbytes_out(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* easily performed. If the inspected parameter is not stored in the table,
* <not found> is returned.
*/
-static int sample_conv_table_server_id(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_server_id(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* can be easily performed. If the inspected parameter is not stored in the
* table, <not found> is returned.
*/
-static int sample_conv_table_sess_cnt(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_sess_cnt(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* performed. If the inspected parameter is not stored in the table, <not found>
* is returned.
*/
-static int sample_conv_table_sess_rate(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_sess_rate(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
* comparisons can be easily performed. If the inspected parameter is not
* stored in the table, <not found> is returned.
*/
-static int sample_conv_table_trackers(struct session *session, const struct arg *arg_p,
+static int sample_conv_table_trackers(struct stream *stream, const struct arg *arg_p,
struct sample *smp, void *private)
{
struct stktable *t;
/*
- * Session management functions.
+ * Stream management functions.
*
* Copyright 2000-2012 Willy Tarreau <w@1wt.eu>
*
#include <proto/listener.h>
#include <proto/log.h>
#include <proto/raw_sock.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/pipe.h>
#include <proto/proto_http.h>
#include <proto/proto_tcp.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
-struct pool_head *pool2_session;
-struct list sessions;
+struct pool_head *pool2_stream;
+struct list streams;
-/* list of sessions waiting for at least one buffer */
+/* list of streams waiting for at least one buffer */
struct list buffer_wq = LIST_HEAD_INIT(buffer_wq);
-static int conn_session_complete(struct connection *conn);
-static int conn_session_update(struct connection *conn);
+static int conn_stream_complete(struct connection *conn);
+static int conn_stream_update(struct connection *conn);
static struct task *expire_mini_session(struct task *t);
-int session_complete(struct session *s);
+int stream_complete(struct stream *s);
-/* data layer callbacks for an embryonic session */
+/* data layer callbacks for an embryonic stream */
struct data_cb sess_conn_cb = {
.recv = NULL,
.send = NULL,
- .wake = conn_session_update,
- .init = conn_session_complete,
+ .wake = conn_stream_update,
+ .init = conn_stream_complete,
};
/* This function is called from the protocol layer accept() in order to
- * instanciate a new embryonic session on behalf of a given listener and
+ * instanciate a new embryonic stream on behalf of a given listener and
* frontend. It returns a positive value upon success, 0 if the connection
* can be ignored, or a negative value upon critical failure. The accepted
* file descriptor is closed if we return <= 0.
*/
-int session_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
+int stream_accept(struct listener *l, int cfd, struct sockaddr_storage *addr)
{
struct connection *cli_conn;
struct proxy *p = l->frontend;
- struct session *s;
+ struct stream *s;
struct task *t;
int ret;
cli_conn->target = &l->obj_type;
cli_conn->proxy_netns = l->netns;
- if (unlikely((s = pool_alloc2(pool2_session)) == NULL))
+ if (unlikely((s = pool_alloc2(pool2_stream)) == NULL))
goto out_free_conn;
- /* minimum session initialization required for an embryonic session is
+ /* minimum stream initialization required for an embryonic stream is
* fairly low. We need very little to execute L4 ACLs, then we need a
* task to make the client-side connection live on its own.
* - flags
s->si[1].flags = SI_FL_ISBACK;
/* On a mini-session, the connection is directly attached to the
- * session's target so that we don't need to initialize the stream
+ * stream's target so that we don't need to initialize the stream
* interfaces. Another benefit is that it's easy to detect a mini-
- * session in dumps using this : it's the only one which has a
+ * stream in dumps using this : it's the only one which has a
* connection in s->target.
*/
s->target = &cli_conn->obj_type;
s->logs.tv_accept = now; /* corrected date for internal use */
s->uniq_id = global.req_count++;
p->feconn++;
- /* This session was accepted, count it now */
+ /* This stream was accepted, count it now */
if (p->feconn > p->fe_counters.conn_max)
p->fe_counters.conn_max = p->feconn;
/* OK, now either we have a pending handshake to execute with and
* then we must return to the I/O layer, or we can proceed with the
- * end of the session initialization. In case of handshake, we also
+ * end of the stream initialization. In case of handshake, we also
* set the I/O timeout to the frontend's client timeout.
*/
return 1;
}
- /* OK let's complete session initialization since there is no handshake */
+ /* OK let's complete stream initialization since there is no handshake */
cli_conn->flags |= CO_FL_CONNECTED;
- ret = session_complete(s);
+ ret = stream_complete(s);
if (ret > 0)
return ret;
task_free(t);
out_free_session:
p->feconn--;
- session_store_counters(s);
- pool_free2(pool2_session, s);
+ stream_store_counters(s);
+ pool_free2(pool2_stream, s);
out_free_conn:
cli_conn->flags &= ~CO_FL_XPRT_TRACKED;
conn_xprt_close(cli_conn);
}
-/* prepare the trash with a log prefix for session <s>. It only works with
- * embryonic sessions based on a real connection. This function requires that
+/* prepare the trash with a log prefix for stream <s>. It only works with
+ * embryonic streams based on a real connection. This function requires that
* at s->target still points to the incoming connection.
*/
-static void prepare_mini_sess_log_prefix(struct session *s)
+static void prepare_mini_sess_log_prefix(struct stream *s)
{
struct tm tm;
char pn[INET6_ADDRSTRLEN];
chunk_appendf(&trash, "] %s/%d", s->fe->id, s->listener->luid);
}
-/* This function kills an existing embryonic session. It stops the connection's
+/* This function kills an existing embryonic stream. It stops the connection's
* transport layer, releases assigned resources, resumes the listener if it was
* disabled and finally kills the file descriptor. This function requires that
* at s->target still points to the incoming connection.
*/
-static void kill_mini_session(struct session *s)
+static void kill_mini_session(struct stream *s)
{
int level = LOG_INFO;
struct connection *conn = __objt_conn(s->target);
conn_free(conn);
s->fe->feconn--;
- session_store_counters(s);
+ stream_store_counters(s);
if (!(s->listener->options & LI_O_UNLIMITED))
actconn--;
task_delete(s->task);
task_free(s->task);
- pool_free2(pool2_session, s);
+ pool_free2(pool2_stream, s);
}
-/* Finish initializing a session from a connection, or kills it if the
+/* Finish initializing a stream from a connection, or kills it if the
* connection shows and error. Returns <0 if the connection was killed.
*/
-static int conn_session_complete(struct connection *conn)
+static int conn_stream_complete(struct connection *conn)
{
- struct session *s = conn->owner;
+ struct stream *s = conn->owner;
- if (!(conn->flags & CO_FL_ERROR) && (session_complete(s) > 0)) {
+ if (!(conn->flags & CO_FL_ERROR) && (stream_complete(s) > 0)) {
conn->flags &= ~CO_FL_INIT_DATA;
return 0;
}
return -1;
}
-/* Update an embryonic session status. The connection is killed in case of
+/* Update an embryonic stream status. The connection is killed in case of
* error, and <0 will be returned. Otherwise it does nothing.
*/
-static int conn_session_update(struct connection *conn)
+static int conn_stream_update(struct connection *conn)
{
if (conn->flags & CO_FL_ERROR) {
kill_mini_session(conn->owner);
return 0;
}
-/* Manages embryonic sessions timeout. It is only called when the timeout
+/* Manages embryonic streams timeout. It is only called when the timeout
* strikes and performs the required cleanup.
*/
static struct task *expire_mini_session(struct task *t)
{
- struct session *s = t->context;
+ struct stream *s = t->context;
if (!(t->state & TASK_WOKEN_TIMER))
return t;
}
/* This function is called from the I/O handler which detects the end of
- * handshake, in order to complete initialization of a valid session. It must
- * be called with an embryonic session. It returns a positive value upon
+ * handshake, in order to complete initialization of a valid stream. It must
+ * be called with an embryonic stream. It returns a positive value upon
* success, 0 if the connection can be ignored, or a negative value upon
* critical failure. The accepted file descriptor is closed if we return <= 0.
* The client-side end point is assumed to be a connection, whose pointer is
* taken from s->target which is assumed to be valid. If the function fails,
* it restores s->target.
*/
-int session_complete(struct session *s)
+int stream_complete(struct stream *s)
{
struct listener *l = s->listener;
struct proxy *p = s->fe;
ret = -1; /* assume unrecoverable error by default */
- /* OK, we're keeping the session, so let's properly initialize the session */
- LIST_ADDQ(&sessions, &s->list);
+ /* OK, we're keeping the stream, so let's properly initialize the stream */
+ LIST_ADDQ(&streams, &s->list);
LIST_INIT(&s->back_refs);
LIST_INIT(&s->buffer_wait);
t->context = s;
t->expire = TICK_ETERNITY;
- /* Note: initially, the session's backend points to the frontend.
+ /* Note: initially, the stream's backend points to the frontend.
* This changes later when switching rules are executed or
* when the default backend is assigned.
*/
s->comp_algo = NULL;
s->req.buf = s->res.buf = NULL;
- /* Let's count a session now */
+ /* Let's count a stream now */
proxy_inc_fe_sess_ctr(l, p);
for (i = 0; i < MAX_SESS_STKCTR; i++) {
if (likely(s->fe->options2 & PR_O2_INDEPSTR))
s->si[1].flags |= SI_FL_INDEP_STR;
- session_init_srv_conn(s);
+ stream_init_srv_conn(s);
s->target = l->default_target; /* used by peers and CLI */
s->pend_pos = NULL;
txn = &s->txn;
/* Those variables will be checked and freed if non-NULL in
- * session.c:session_free(). It is important that they are
+ * stream.c:stream_free(). It is important that they are
* properly initialized.
*/
txn->sessid = NULL;
}
/*
- * frees the context associated to a session. It must have been removed first.
+ * frees the context associated to a stream. It must have been removed first.
*/
-static void session_free(struct session *s)
+static void stream_free(struct stream *s)
{
struct http_txn *txn = &s->txn;
struct proxy *fe = s->fe;
}
if (unlikely(s->srv_conn)) {
- /* the session still has a reserved slot on a server, but
+ /* the stream still has a reserved slot on a server, but
* it should normally be only the same as the one above,
* so this should not happen in fact.
*/
b_drop(&s->req.buf);
b_drop(&s->res.buf);
if (!LIST_ISEMPTY(&buffer_wq))
- session_offer_buffers();
+ stream_offer_buffers();
hlua_ctx_destroy(&s->hlua);
http_end_txn(s);
pool_free2(fe->req_cap_pool, txn->req.cap);
}
- session_store_counters(s);
+ stream_store_counters(s);
list_for_each_entry_safe(bref, back, &s->back_refs, users) {
/* we have to unlink all watchers. We must not relink them if
- * this session was the last one in the list.
+ * this stream was the last one in the list.
*/
LIST_DEL(&bref->users);
LIST_INIT(&bref->users);
- if (s->list.n != &sessions)
- LIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);
+ if (s->list.n != &streams)
+ LIST_ADDQ(&LIST_ELEM(s->list.n, struct stream *, list)->back_refs, &bref->users);
bref->ref = s->list.n;
}
LIST_DEL(&s->list);
si_release_endpoint(&s->si[1]);
si_release_endpoint(&s->si[0]);
- pool_free2(pool2_session, s);
+ pool_free2(pool2_stream, s);
/* We may want to free the maximum amount of pools if the proxy is stopping */
if (fe && unlikely(fe->state == PR_STSTOPPED)) {
pool_flush2(pool2_hdr_idx);
pool_flush2(pool2_requri);
pool_flush2(pool2_capture);
- pool_flush2(pool2_session);
+ pool_flush2(pool2_stream);
pool_flush2(pool2_connection);
pool_flush2(pool2_pendconn);
pool_flush2(fe->req_cap_pool);
* buffers are properly allocated. Returns 0 in case of failure, non-zero
* otherwise.
*/
-int session_alloc_recv_buffer(struct channel *chn)
+int stream_alloc_recv_buffer(struct channel *chn)
{
- struct session *s;
+ struct stream *s;
struct buffer *b;
int margin = 0;
return 0;
}
-/* Allocates a work buffer for session <s>. It is meant to be called inside
- * process_session(). It will only allocate the side needed for the function
+/* Allocates a work buffer for stream <s>. It is meant to be called inside
+ * process_stream(). It will only allocate the side needed for the function
* to work fine. For a regular connection, only the response is needed so that
* an error message may be built and returned. In case where the initiator is
* an applet (eg: peers), then we need to allocate the request buffer for the
* a response may always flow and will never block a server from releasing a
* connection. Returns 0 in case of failure, non-zero otherwise.
*/
-int session_alloc_work_buffer(struct session *s)
+int stream_alloc_work_buffer(struct stream *s)
{
int margin;
struct buffer **buf;
/* releases unused buffers after processing. Typically used at the end of the
* update() functions. It will try to wake up as many tasks as the number of
- * buffers that it releases. In practice, most often sessions are blocked on
+ * buffers that it releases. In practice, most often streams are blocked on
* a single buffer, so it makes sense to try to wake two up when two buffers
* are released at once.
*/
-void session_release_buffers(struct session *s)
+void stream_release_buffers(struct stream *s)
{
if (s->req.buf->size && buffer_empty(s->req.buf))
b_free(&s->req.buf);
* someone waiting, we can wake up a waiter and offer them.
*/
if (!LIST_ISEMPTY(&buffer_wq))
- session_offer_buffers();
+ stream_offer_buffers();
}
-/* Runs across the list of pending sessions waiting for a buffer and wakes one
+/* Runs across the list of pending streams waiting for a buffer and wakes one
* up if buffers are available. Will stop when the run queue reaches <rqlimit>.
- * Should not be called directly, use session_offer_buffers() instead.
+ * Should not be called directly, use stream_offer_buffers() instead.
*/
-void __session_offer_buffers(int rqlimit)
+void __stream_offer_buffers(int rqlimit)
{
- struct session *sess, *bak;
+ struct stream *sess, *bak;
list_for_each_entry_safe(sess, bak, &buffer_wq, buffer_wait) {
if (rqlimit <= run_queue)
}
/* perform minimal intializations, report 0 in case of error, 1 if OK. */
-int init_session()
+int init_stream()
{
- LIST_INIT(&sessions);
- pool2_session = create_pool("session", sizeof(struct session), MEM_F_SHARED);
- return pool2_session != NULL;
+ LIST_INIT(&streams);
+ pool2_stream = create_pool("stream", sizeof(struct stream), MEM_F_SHARED);
+ return pool2_stream != NULL;
}
-void session_process_counters(struct session *s)
+void stream_process_counters(struct stream *s)
{
unsigned long long bytes;
void *ptr;
* We must check for establishment, error and abort. Possible output states
* are SI_ST_EST (established), SI_ST_CER (error), SI_ST_DIS (abort), and
* SI_ST_CON (no change). The function returns 0 if it switches to SI_ST_CER,
- * otherwise 1. This only works with connection-based sessions.
+ * otherwise 1. This only works with connection-based streams.
*/
-static int sess_update_st_con_tcp(struct session *s)
+static int sess_update_st_con_tcp(struct stream *s)
{
struct stream_interface *si = &s->si[1];
struct channel *req = &s->req;
* and SI_ST_REQ when an immediate redispatch is wanted. The buffers are
* marked as in error state. It returns 0.
*/
-static int sess_update_st_cer(struct session *s)
+static int sess_update_st_cer(struct stream *s)
{
struct stream_interface *si = &s->si[1];
- /* we probably have to release last session from the server */
+ /* we probably have to release last stream from the server */
if (objt_server(s->target)) {
health_adjust(objt_server(s->target), HANA_STATUS_L4_ERR);
/* If the "redispatch" option is set on the backend, we are allowed to
* retry on another server for the last retry. In order to achieve this,
- * we must mark the session unassigned, and eventually clear the DIRECT
+ * 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
* SI_ST_EST state. It must only be called after switching from SI_ST_CON (or
* SI_ST_INI) to SI_ST_EST, but only when a ->proto is defined.
*/
-static void sess_establish(struct session *s)
+static void sess_establish(struct stream *s)
{
struct stream_interface *si = &s->si[1];
struct channel *req = &s->req;
* and SI_ST_EST. Flags must have previously been updated for timeouts and other
* conditions.
*/
-static void sess_update_stream_int(struct session *s)
+static void sess_update_stream_int(struct stream *s)
{
struct server *srv = objt_server(s->target);
struct stream_interface *si = &s->si[1];
srv->counters.failed_conns++;
s->be->be_counters.failed_conns++;
- /* release other sessions waiting for this server */
+ /* release other streams waiting for this server */
sess_change_server(s, NULL);
if (may_dequeue_tasks(srv, s->be))
process_srv_queue(srv);
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
- /* no session was ever accounted for this server */
+ /* no stream was ever accounted for this server */
si->state = SI_ST_CLO;
if (s->srv_error)
s->srv_error(s, si);
si->exp = TICK_ETERNITY;
- /* we keep trying on the same server as long as the session is
+ /* we keep trying on the same server as long as the stream is
* marked "assigned".
* FIXME: Should we force a redispatch attempt when the server is down ?
*/
}
}
-/* Set correct session termination flags in case no analyser has done it. It
+/* Set correct stream termination flags in case no analyser has done it. It
* also counts a failed request if the server state has not reached the request
* stage.
*/
-static void sess_set_term_flags(struct session *s)
+static void sess_set_term_flags(struct stream *s)
{
if (!(s->flags & SN_FINST_MASK)) {
if (s->si[1].state < SI_ST_REQ) {
* or SI_ST_EST for a successful connection to an applet. It may also return
* SI_ST_QUE, or SI_ST_CLO upon error.
*/
-static void sess_prepare_conn_req(struct session *s)
+static void sess_prepare_conn_req(struct stream *s)
{
struct stream_interface *si = &s->si[1];
* It returns 1 if the processing can continue on next analysers, or zero if it
* either needs more data or wants to immediately abort the request.
*/
-static int process_switching_rules(struct session *s, struct channel *req, int an_bit)
+static int process_switching_rules(struct stream *s, struct channel *req, int an_bit)
{
struct persist_rule *prst_rule;
req->analysers &= ~an_bit;
req->analyse_exp = TICK_ETERNITY;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
else
backend = rule->be.backend;
- if (!session_set_backend(s, backend))
+ if (!stream_set_backend(s, backend))
goto sw_failed;
break;
}
* backend if any.
*/
if (!(s->flags & SN_BE_ASSIGNED))
- if (!session_set_backend(s, s->fe->defbe.be ? s->fe->defbe.be : s->be))
+ if (!stream_set_backend(s, s->fe->defbe.be ? s->fe->defbe.be : s->be))
goto sw_failed;
}
}
/* as soon as we know the backend, we must check if we have a matching forced or ignored
- * persistence rule, and report that in the session.
+ * persistence rule, and report that in the stream.
*/
list_for_each_entry(prst_rule, &s->be->persist_rules, list) {
int ret = 1;
* it then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_server_rules(struct session *s, struct channel *req, int an_bit)
+static int process_server_rules(struct stream *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
struct server_rule *rule;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
* it then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_sticking_rules(struct session *s, struct channel *req, int an_bit)
+static int process_sticking_rules(struct stream *s, struct channel *req, int an_bit)
{
struct proxy *px = s->be;
struct sticking_rule *rule;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
req,
* then returns 1. The data must already be present in the buffer otherwise
* they won't match. It always returns 1.
*/
-static int process_store_rules(struct session *s, struct channel *rep, int an_bit)
+static int process_store_rules(struct stream *s, struct channel *rep, int an_bit)
{
struct proxy *px = s->be;
struct sticking_rule *rule;
int i;
int nbreq = s->store_count;
- DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
+ DPRINTF(stderr,"[%u] %s: stream=%p b=%p, exp(r,w)=%u,%u bf=%08x bh=%d analysers=%02x\n",
now_ms, __FUNCTION__,
s,
rep,
}
/* This macro is very specific to the function below. See the comments in
- * process_session() below to understand the logic and the tests.
+ * process_stream() below to understand the logic and the tests.
*/
#define UPDATE_ANALYSERS(real, list, back, flag) { \
list = (((list) & ~(flag)) | ~(back)) & (real); \
continue; \
}
-/* Processes the client, server, request and response jobs of a session task,
+/* Processes the client, server, request and response jobs of a stream task,
* then puts it back to the wait queue in a clean state, or cleans up its
* resources if it must be deleted. Returns in <next> the date the task wants
* to be woken up, or TICK_ETERNITY. In order not to call all functions for
* and each function is called only if at least another function has changed at
* least one flag it is interested in.
*/
-struct task *process_session(struct task *t)
+struct task *process_stream(struct task *t)
{
struct server *srv;
- struct session *s = t->context;
+ struct stream *s = t->context;
unsigned int rqf_last, rpf_last;
unsigned int rq_prod_last, rq_cons_last;
unsigned int rp_cons_last, rp_prod_last;
/* Once in a while we're woken up because the task expires. But
* this does not necessarily mean that a timeout has been reached.
- * So let's not run a whole session processing if only an expiration
+ * So let's not run a whole stream processing if only an expiration
* timeout needs to be refreshed.
*/
if (!((req->flags | res->flags) &
/* below we may emit error messages so we have to ensure that we have
* our buffers properly allocated.
*/
- if (!session_alloc_work_buffer(s)) {
+ if (!stream_alloc_work_buffer(s)) {
/* No buffer available, we've been subscribed to the list of
* buffer waiters, let's wait for our turn.
*/
* the list when not needed. Any analyser may return 0
* to break out of the loop, either because of missing
* data to take a decision, or because it decides to
- * kill the session. We loop at least once through each
+ * kill the stream. We loop at least once through each
* analyser, and we may loop again if other analysers
* are added in the middle.
*
* the list when not needed. Any analyser may return 0
* to break out of the loop, either because of missing
* data to take a decision, or because it decides to
- * kill the session. We loop at least once through each
+ * kill the stream. We loop at least once through each
* analyser, and we may loop again if other analysers
* are added in the middle.
*/
/*
- * Now we propagate unhandled errors to the session. Normally
+ * Now we propagate unhandled errors to the stream. Normally
* we're just in a data phase here since it means we have not
* seen any analyser who could set an error status.
*/
(si_b->state > SI_ST_INI && si_b->state < SI_ST_CLO))) {
if ((s->fe->options & PR_O_CONTSTATS) && (s->flags & SN_BE_ASSIGNED))
- session_process_counters(s);
+ stream_process_counters(s);
if (si_f->state == SI_ST_EST && obj_type(si_f->end) != OBJ_TYPE_APPCTX)
si_update(si_f);
if ((si_applet_call(si_b) | si_applet_call(si_f)) != 0) {
if (task_in_rq(t)) {
t->expire = TICK_ETERNITY;
- session_release_buffers(s);
+ stream_release_buffers(s);
return t;
}
}
if (!tick_isset(t->expire))
ABORT_NOW();
#endif
- session_release_buffers(s);
+ stream_release_buffers(s);
return t; /* nothing more to do */
}
}
s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);
- session_process_counters(s);
+ stream_process_counters(s);
if (s->txn.status) {
int n;
s->do_log(s);
}
- /* update time stats for this session */
- session_update_time_stats(s);
+ /* update time stats for this stream */
+ stream_update_time_stats(s);
/* the task MUST not be in the run queue anymore */
- session_free(s);
+ stream_free(s);
task_delete(t);
task_free(t);
return NULL;
}
-/* Update the session's backend and server time stats */
-void session_update_time_stats(struct session *s)
+/* Update the stream's backend and server time stats */
+void stream_update_time_stats(struct stream *s)
{
int t_request;
int t_queue;
/*
* This function adjusts sess->srv_conn and maintains the previous and new
- * server's served session counts. Setting newsrv to NULL is enough to release
+ * server's served stream counts. Setting newsrv to NULL is enough to release
* current connection slot. This function also notifies any LB algo which might
- * expect to be informed about any change in the number of active sessions on a
+ * expect to be informed about any change in the number of active streams on a
* server.
*/
-void sess_change_server(struct session *sess, struct server *newsrv)
+void sess_change_server(struct stream *sess, struct server *newsrv)
{
if (sess->srv_conn == newsrv)
return;
sess->srv_conn->served--;
if (sess->srv_conn->proxy->lbprm.server_drop_conn)
sess->srv_conn->proxy->lbprm.server_drop_conn(sess->srv_conn);
- session_del_srv_conn(sess);
+ stream_del_srv_conn(sess);
}
if (newsrv) {
newsrv->served++;
if (newsrv->proxy->lbprm.server_take_conn)
newsrv->proxy->lbprm.server_take_conn(newsrv);
- session_add_srv_conn(sess, newsrv);
+ stream_add_srv_conn(sess, newsrv);
}
}
/* Handle server-side errors for default protocols. It is called whenever a a
* connection setup is aborted or a request is aborted in queue. It sets the
- * session termination flags so that the caller does not have to worry about
+ * stream termination flags so that the caller does not have to worry about
* them. It's installed as ->srv_error for the server-side stream_interface.
*/
-void default_srv_error(struct session *s, struct stream_interface *si)
+void default_srv_error(struct stream *s, struct stream_interface *si)
{
int err_type = si->err_type;
int err = 0, fin = 0;
s->flags |= fin;
}
-/* kill a session and set the termination flags to <why> (one of SN_ERR_*) */
-void session_shutdown(struct session *session, int why)
+/* kill a stream and set the termination flags to <why> (one of SN_ERR_*) */
+void stream_shutdown(struct stream *stream, int why)
{
- if (session->req.flags & (CF_SHUTW|CF_SHUTW_NOW))
+ if (stream->req.flags & (CF_SHUTW|CF_SHUTW_NOW))
return;
- channel_shutw_now(&session->req);
- channel_shutr_now(&session->res);
- session->task->nice = 1024;
- if (!(session->flags & SN_ERR_MASK))
- session->flags |= why;
- task_wakeup(session->task, TASK_WOKEN_OTHER);
+ channel_shutw_now(&stream->req);
+ channel_shutr_now(&stream->res);
+ stream->task->nice = 1024;
+ if (!(stream->flags & SN_ERR_MASK))
+ stream->flags |= why;
+ task_wakeup(stream->task, TASK_WOKEN_OTHER);
}
/************************************************************************/
/* Returns a pointer to a stkctr depending on the fetch keyword name.
* It is designed to be called as sc[0-9]_* sc_* or src_* exclusively.
* sc[0-9]_* will return a pointer to the respective field in the
- * session <l4>. sc_* requires an UINT argument specifying the stick
+ * stream <l4>. sc_* requires an UINT argument specifying the stick
* counter number. src_* will fill a locally allocated structure with
* the table and entry corresponding to what is specified with src_*.
* NULL may be returned if the designated stkctr is not tracked. For
* multiple tables).
*/
struct stkctr *
-smp_fetch_sc_stkctr(struct session *l4, const struct arg *args, const char *kw)
+smp_fetch_sc_stkctr(struct stream *l4, const struct arg *args, const char *kw)
{
static struct stkctr stkctr;
struct stksess *stksess;
return &l4->stkctr[num];
}
-/* set return a boolean indicating if the requested session counter is
+/* set return a boolean indicating if the requested stream counter is
* currently being tracked or not.
* Supports being called as "sc[0-9]_tracked" only.
*/
static int
-smp_fetch_sc_tracked(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_tracked(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
return 1;
}
-/* set <smp> to the General Purpose Counter 0 value from the session's tracked
+/* set <smp> to the General Purpose Counter 0 value from the stream's tracked
* frontend counters or from the src.
* Supports being called as "sc[0-9]_get_gpc0" or "src_get_gpc0" only. Value
* zero is returned if the key is new.
*/
static int
-smp_fetch_sc_get_gpc0(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_get_gpc0(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the General Purpose Counter 0's event rate from the session's
+/* set <smp> to the General Purpose Counter 0's event rate from the stream's
* tracked frontend counters or from the src.
* Supports being called as "sc[0-9]_gpc0_rate" or "src_gpc0_rate" only.
* Value zero is returned if the key is new.
*/
static int
-smp_fetch_sc_gpc0_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_gpc0_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* Increment the General Purpose Counter 0 value from the session's tracked
+/* Increment the General Purpose Counter 0 value from the stream's tracked
* frontend counters and return it into temp integer.
* Supports being called as "sc[0-9]_inc_gpc0" or "src_inc_gpc0" only.
*/
static int
-smp_fetch_sc_inc_gpc0(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_inc_gpc0(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* Clear the General Purpose Counter 0 value from the session's tracked
+/* Clear the General Purpose Counter 0 value from the stream's tracked
* frontend counters and return its previous value into temp integer.
* Supports being called as "sc[0-9]_clr_gpc0" or "src_clr_gpc0" only.
*/
static int
-smp_fetch_sc_clr_gpc0(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_clr_gpc0(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the cumulated number of connections from the session's tracked
+/* set <smp> to the cumulated number of connections from the stream's tracked
* frontend counters. Supports being called as "sc[0-9]_conn_cnt" or
* "src_conn_cnt" only.
*/
static int
-smp_fetch_sc_conn_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_conn_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the connection rate from the session's tracked frontend
+/* set <smp> to the connection rate from the stream's tracked frontend
* counters. Supports being called as "sc[0-9]_conn_rate" or "src_conn_rate"
* only.
*/
static int
-smp_fetch_sc_conn_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_conn_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set temp integer to the number of connections from the session's source address
+/* set temp integer to the number of connections from the stream's source address
* in the table pointed to by expr, after updating it.
* Accepts exactly 1 argument of type table.
*/
static int
-smp_fetch_src_updt_conn_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_src_updt_conn_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct connection *conn = objt_conn(l4->si[0].end);
return 1;
}
-/* set <smp> to the number of concurrent connections from the session's tracked
+/* set <smp> to the number of concurrent connections from the stream's tracked
* frontend counters. Supports being called as "sc[0-9]_conn_cur" or
* "src_conn_cur" only.
*/
static int
-smp_fetch_sc_conn_cur(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_conn_cur(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the cumulated number of sessions from the session's tracked
+/* set <smp> to the cumulated number of streams from the stream's tracked
* frontend counters. Supports being called as "sc[0-9]_sess_cnt" or
* "src_sess_cnt" only.
*/
static int
-smp_fetch_sc_sess_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_sess_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the session rate from the session's tracked frontend counters.
+/* set <smp> to the stream rate from the stream's tracked frontend counters.
* Supports being called as "sc[0-9]_sess_rate" or "src_sess_rate" only.
*/
static int
-smp_fetch_sc_sess_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_sess_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the cumulated number of HTTP requests from the session's tracked
+/* set <smp> to the cumulated number of HTTP requests from the stream's tracked
* frontend counters. Supports being called as "sc[0-9]_http_req_cnt" or
* "src_http_req_cnt" only.
*/
static int
-smp_fetch_sc_http_req_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_http_req_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the HTTP request rate from the session's tracked frontend
+/* set <smp> to the HTTP request rate from the stream's tracked frontend
* counters. Supports being called as "sc[0-9]_http_req_rate" or
* "src_http_req_rate" only.
*/
static int
-smp_fetch_sc_http_req_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_http_req_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the cumulated number of HTTP requests errors from the session's
+/* set <smp> to the cumulated number of HTTP requests errors from the stream's
* tracked frontend counters. Supports being called as "sc[0-9]_http_err_cnt" or
* "src_http_err_cnt" only.
*/
static int
-smp_fetch_sc_http_err_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_http_err_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the HTTP request error rate from the session's tracked frontend
+/* set <smp> to the HTTP request error rate from the stream's tracked frontend
* counters. Supports being called as "sc[0-9]_http_err_rate" or
* "src_http_err_rate" only.
*/
static int
-smp_fetch_sc_http_err_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_http_err_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
}
/* set <smp> to the number of kbytes received from clients, as found in the
- * session's tracked frontend counters. Supports being called as
+ * stream's tracked frontend counters. Supports being called as
* "sc[0-9]_kbytes_in" or "src_kbytes_in" only.
*/
static int
-smp_fetch_sc_kbytes_in(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_kbytes_in(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
}
/* set <smp> to the data rate received from clients in bytes/s, as found
- * in the session's tracked frontend counters. Supports being called as
+ * in the stream's tracked frontend counters. Supports being called as
* "sc[0-9]_bytes_in_rate" or "src_bytes_in_rate" only.
*/
static int
-smp_fetch_sc_bytes_in_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_bytes_in_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
}
/* set <smp> to the number of kbytes sent to clients, as found in the
- * session's tracked frontend counters. Supports being called as
+ * stream's tracked frontend counters. Supports being called as
* "sc[0-9]_kbytes_out" or "src_kbytes_out" only.
*/
static int
-smp_fetch_sc_kbytes_out(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_kbytes_out(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
}
/* set <smp> to the data rate sent to clients in bytes/s, as found in the
- * session's tracked frontend counters. Supports being called as
+ * stream's tracked frontend counters. Supports being called as
* "sc[0-9]_bytes_out_rate" or "src_bytes_out_rate" only.
*/
static int
-smp_fetch_sc_bytes_out_rate(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_bytes_out_rate(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
return 1;
}
-/* set <smp> to the number of active trackers on the SC entry in the session's
+/* set <smp> to the number of active trackers on the SC entry in the stream's
* tracked frontend counters. Supports being called as "sc[0-9]_trackers" only.
*/
static int
-smp_fetch_sc_trackers(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_sc_trackers(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
struct stkctr *stkctr = smp_fetch_sc_stkctr(l4, args, kw);
* Accepts exactly 1 argument of type table.
*/
static int
-smp_fetch_table_cnt(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_table_cnt(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
smp->flags = SMP_F_VOL_TEST;
* Accepts exactly 1 argument of type table.
*/
static int
-smp_fetch_table_avl(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
+smp_fetch_table_avl(struct proxy *px, struct stream *l4, void *l7, unsigned int opt,
const struct arg *args, struct sample *smp, const char *kw, void *private)
{
px = args->data.prx;
}};
__attribute__((constructor))
-static void __session_init(void)
+static void __stream_init(void)
{
sample_register_fetches(&smp_fetch_keywords);
acl_register_keywords(&acl_kws);
#include <proto/channel.h>
#include <proto/connection.h>
#include <proto/pipe.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/stream_interface.h>
#include <proto/task.h>
if (ic->flags & CF_READ_ACTIVITY)
ic->flags &= ~CF_READ_DONTWAIT;
- session_release_buffers(si_sess(si));
+ stream_release_buffers(si_strm(si));
return 0;
}
}
/* now we'll need a buffer */
- if (!session_alloc_recv_buffer(ic)) {
+ if (!stream_alloc_recv_buffer(ic)) {
si->flags |= SI_FL_WAIT_ROOM;
goto end_recv;
}
if (si->flags & SI_FL_NOHALF) {
/* we want to immediately forward this close to the write side */
- /* force flag on ssl to keep session in cache */
+ /* force flag on ssl to keep stream in cache */
conn_data_shutw_hard(conn);
goto do_close;
}
#include <eb32tree.h>
#include <proto/proxy.h>
-#include <proto/session.h>
+#include <proto/stream.h>
#include <proto/task.h>
struct pool_head *pool2_task;
* predictor take this most common call.
*/
t->calls++;
- if (likely(t->process == process_session))
- t = process_session(t);
+ if (likely(t->process == process_stream))
+ t = process_stream(t);
else
t = t->process(t);