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/src/queue.c b/src/queue.c
index 74fa659..14e4be6 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -16,7 +16,7 @@
 
 #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>
 
@@ -63,7 +63,7 @@
 
 /*
  * 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)
 {
@@ -76,15 +76,16 @@
 
 	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.
@@ -93,13 +94,13 @@
  * 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;
@@ -114,30 +115,30 @@
 			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;
@@ -146,24 +147,24 @@
 	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;
 }
 
@@ -176,19 +177,19 @@
 	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++;
 		}
 	}
@@ -208,16 +209,16 @@
 		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;
 }
@@ -225,17 +226,17 @@
 /*
  * 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);
 }