REORG/MAJOR: session: rename the "session" entity to "stream"

With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.

In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.

The files stream.{c,h} were added and session.{c,h} removed.

The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.

Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.

Once all changes are completed, we should see approximately this :

   L7 - http_txn
   L6 - stream
   L5 - session
   L4 - connection | applet

There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.

Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
diff --git a/include/proto/acl.h b/include/proto/acl.h
index 1a7c1f4..ee5b14b 100644
--- a/include/proto/acl.h
+++ b/include/proto/acl.h
@@ -99,7 +99,7 @@
  * 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
diff --git a/include/proto/backend.h b/include/proto/backend.h
index 56df516..105807b 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -28,16 +28,16 @@
 #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);
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 9907a51..b1c313c 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -33,7 +33,7 @@
 
 #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. */
@@ -54,31 +54,31 @@
 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. */
diff --git a/include/proto/compression.h b/include/proto/compression.h
index e5ae8b6..5c7c8cb 100644
--- a/include/proto/compression.h
+++ b/include/proto/compression.h
@@ -31,9 +31,9 @@
 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;
diff --git a/include/proto/frontend.h b/include/proto/frontend.h
index 77d3206..61d0409 100644
--- a/include/proto/frontend.h
+++ b/include/proto/frontend.h
@@ -23,9 +23,9 @@
 #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 */
diff --git a/include/proto/log.h b/include/proto/log.h
index 54c51d1..0967ae8 100644
--- a/include/proto/log.h
+++ b/include/proto/log.h
@@ -30,7 +30,7 @@
 #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;
@@ -42,13 +42,13 @@
 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
diff --git a/include/proto/payload.h b/include/proto/payload.h
index fd89c88..9674832 100644
--- a/include/proto/payload.h
+++ b/include/proto/payload.h
@@ -24,9 +24,9 @@
 
 #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 */
diff --git a/include/proto/peers.h b/include/proto/peers.h
index 39835ff..27b3875 100644
--- a/include/proto/peers.h
+++ b/include/proto/peers.h
@@ -25,7 +25,7 @@
 #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);
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 36e6eb8..477b9b0 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -24,7 +24,7 @@
 
 #include <common/config.h>
 #include <types/proto_http.h>
-#include <types/session.h>
+#include <types/stream.h>
 #include <types/task.h>
 
 /*
@@ -63,30 +63,30 @@
 #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,
@@ -100,37 +100,36 @@
 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);
diff --git a/include/proto/proto_tcp.h b/include/proto/proto_tcp.h
index a28c531..96488f1 100644
--- a/include/proto/proto_tcp.h
+++ b/include/proto/proto_tcp.h
@@ -36,9 +36,9 @@
 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);
diff --git a/include/proto/proto_uxst.h b/include/proto/proto_uxst.h
index 8e796ec..d7bcaa6 100644
--- a/include/proto/proto_uxst.h
+++ b/include/proto/proto_uxst.h
@@ -23,7 +23,7 @@
 #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);
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 116c00a..139791f 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -43,7 +43,7 @@
 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);
diff --git a/include/proto/queue.h b/include/proto/queue.h
index c7243bd..934e29d 100644
--- a/include/proto/queue.h
+++ b/include/proto/queue.h
@@ -28,7 +28,7 @@
 
 #include <types/proxy.h>
 #include <types/queue.h>
-#include <types/session.h>
+#include <types/stream.h>
 #include <types/server.h>
 #include <types/task.h>
 
@@ -37,8 +37,8 @@
 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);
diff --git a/include/proto/sample.h b/include/proto/sample.h
index 91f4513..e9f9e25 100644
--- a/include/proto/sample.h
+++ b/include/proto/sample.h
@@ -30,10 +30,10 @@
 
 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);
diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index a5e7520..9320430 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -48,7 +48,7 @@
 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);
diff --git a/include/proto/session.h b/include/proto/stream.h
similarity index 75%
rename from include/proto/session.h
rename to include/proto/stream.h
index 2dc3d83..c73ad20 100644
--- a/include/proto/session.h
+++ b/include/proto/stream.h
@@ -1,6 +1,6 @@
 /*
- * 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
  *
@@ -19,48 +19,48 @@
  * 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)
@@ -92,11 +92,11 @@
 	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;
@@ -113,11 +113,11 @@
 	}
 }
 
-/* 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;
@@ -142,7 +142,7 @@
  * <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;
 
@@ -162,11 +162,11 @@
 		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;
@@ -174,11 +174,11 @@
 	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;
@@ -199,7 +199,7 @@
 }
 
 /* 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;
@@ -228,7 +228,7 @@
  * 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;
@@ -248,13 +248,13 @@
 	}
 }
 
-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;
@@ -263,22 +263,22 @@
 	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
@@ -287,10 +287,10 @@
 	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:
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 70b2ac8..f96d81c 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -25,7 +25,7 @@
 #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>
@@ -50,18 +50,18 @@
 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) */
@@ -76,31 +76,31 @@
 	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