[MAJOR] buffers: fix the BF_EMPTY flag's meaning

The BF_EMPTY flag was once used to indicate an empty buffer. However,
it was used half the time as meaning the buffer is empty for the reader,
and half the time as meaning there is nothing left to send.

"nothing to send" is only indicated by "->send_max=0 && !pipe". Once
we fix this, we discover that the flag is not used anymore. So the
flags has been renamed BF_OUT_EMPTY and means exactly the condition
above, ie, there is nothing to send.

Doing so has allowed us to remove some unused tests for emptiness,
but also to uncover a certain amount of situations where the flag
was not correctly set or tested.
diff --git a/src/session.c b/src/session.c
index 6c9390d..01ce306 100644
--- a/src/session.c
+++ b/src/session.c
@@ -200,7 +200,7 @@
 	/* OK, maybe we want to abort */
 	if (unlikely((rep->flags & BF_SHUTW) ||
 		     ((req->flags & BF_SHUTW_NOW) && /* FIXME: this should not prevent a connection from establishing */
-		      (((req->flags & (BF_EMPTY|BF_WRITE_ACTIVITY)) == BF_EMPTY) ||
+		      (((req->flags & (BF_OUT_EMPTY|BF_WRITE_ACTIVITY)) == BF_OUT_EMPTY) ||
 		       s->be->options & PR_O_ABRT_CLOSE)))) {
 		/* give up */
 		si->shutw(si);
@@ -452,7 +452,7 @@
 		/* Connection remains in queue, check if we have to abort it */
 		if ((si->ob->flags & (BF_READ_ERROR)) ||
 		    ((si->ob->flags & BF_SHUTW_NOW) &&   /* empty and client aborted */
-		     (si->ob->flags & BF_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
+		     (si->ob->flags & BF_OUT_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
 			/* give up */
 			si->exp = TICK_ETERNITY;
 			s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@@ -472,7 +472,7 @@
 		/* Connection request might be aborted */
 		if ((si->ob->flags & (BF_READ_ERROR)) ||
 		    ((si->ob->flags & BF_SHUTW_NOW) &&  /* empty and client aborted */
-		     (si->ob->flags & BF_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
+		     (si->ob->flags & BF_OUT_EMPTY || s->be->options & PR_O_ABRT_CLOSE))) {
 			/* give up */
 			si->exp = TICK_ETERNITY;
 			si->shutr(si);
@@ -992,11 +992,11 @@
 			     ((s->req->cons->state == SI_ST_EST) &&
 			      (s->be->options & PR_O_FORCE_CLO) &&
 			      (s->rep->flags & BF_READ_ACTIVITY))))
-		buffer_shutw_now(s->req);
+			buffer_shutw_now(s->req);
 	}
 
 	/* shutdown(write) pending */
-	if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_EMPTY)) == (BF_SHUTW_NOW|BF_EMPTY)))
+	if (unlikely((s->req->flags & (BF_SHUTW|BF_SHUTW_NOW|BF_OUT_EMPTY)) == (BF_SHUTW_NOW|BF_OUT_EMPTY)))
 		s->req->cons->shutw(s->req->cons);
 
 	/* shutdown(write) done on server side, we must stop the client too */
@@ -1015,8 +1015,7 @@
 	 */
 	if (s->req->cons->state == SI_ST_INI) {
 		if (!(s->req->flags & (BF_SHUTW|BF_SHUTW_NOW))) {
-			if ((s->req->flags & BF_AUTO_CONNECT) ||
-			    (s->req->send_max || s->req->pipe)) {
+			if ((s->req->flags & (BF_AUTO_CONNECT|BF_OUT_EMPTY)) != BF_OUT_EMPTY) {
 				/* If we have a ->connect method, we need to perform a connection request,
 				 * otherwise we immediately switch to the connected state.
 				 */
@@ -1112,7 +1111,7 @@
 		buffer_shutw_now(s->rep);
 
 	/* shutdown(write) pending */
-	if (unlikely((s->rep->flags & (BF_SHUTW|BF_EMPTY|BF_SHUTW_NOW)) == (BF_EMPTY|BF_SHUTW_NOW)))
+	if (unlikely((s->rep->flags & (BF_SHUTW|BF_OUT_EMPTY|BF_SHUTW_NOW)) == (BF_OUT_EMPTY|BF_SHUTW_NOW)))
 		s->rep->cons->shutw(s->rep->cons);
 
 	/* shutdown(write) done on the client side, we must stop the server too */