BUG/MEDIUM: stconn: Only reset connect expiration when processing backend side

Since commit ae024ced0 ("MEDIUM: stream-int/stream: Use connect expiration
instead of SI expiration"), the connect expiration date is per-stream. So
there is only one expiration date instead of one per side, front and
back. So when a stream-connector is processed, we must test if it is a
frontend or a backend stconn before updating the connect expiration
date. Indeed, the frontend stconn must not reset the connect expiration
date.

This bug may have several side effect. One known bug is about peer sessions
blocked because the frontend peer applet is in ST_CLO state and its backend
connection is in ST_TAR state but without connect expiration date.

This patch should fix the issue #1791 and #1792. It must be backported to
2.6.
diff --git a/src/stconn.c b/src/stconn.c
index d69e68e..ca36e49 100644
--- a/src/stconn.c
+++ b/src/stconn.c
@@ -512,7 +512,8 @@
 
 	if (sc_oc(sc)->flags & CF_SHUTW) {
 		sc->state = SC_ST_DIS;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 	else if (sc->flags & SC_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
@@ -572,7 +573,8 @@
 		sc->flags &= ~SC_FL_NOLINGER;
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 
 	/* note that if the task exists, it must unregister itself once it runs */
@@ -654,7 +656,8 @@
 	if (sc_oc(sc)->flags & CF_SHUTW) {
 		sc_conn_shut(sc);
 		sc->state = SC_ST_DIS;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 	else if (sc->flags & SC_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
@@ -738,7 +741,8 @@
 		sc->flags &= ~SC_FL_NOLINGER;
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 }
 
@@ -880,7 +884,8 @@
 	if (sc_oc(sc)->flags & CF_SHUTW) {
 		appctx_shut(__sc_appctx(sc));
 		sc->state = SC_ST_DIS;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 	else if (sc->flags & SC_FL_NOHALF) {
 		/* we want to immediately forward this close to the write side */
@@ -942,7 +947,8 @@
 		sc->flags &= ~SC_FL_NOLINGER;
 		ic->flags |= CF_SHUTR;
 		ic->rex = TICK_ETERNITY;
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	}
 }
 
@@ -1259,7 +1265,8 @@
 	oc->wex = TICK_ETERNITY;
 
 	sc->state = SC_ST_DIS;
-	__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+	if (sc->flags & SC_FL_ISBACK)
+		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 	return;
 }
 
@@ -1838,7 +1845,8 @@
 
 	if (!sc_state_in(sc->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) &&
 	    (conn->flags & CO_FL_WAIT_XPRT) == 0) {
-		__sc_strm(sc)->conn_exp = TICK_ETERNITY;
+		if (sc->flags & SC_FL_ISBACK)
+			__sc_strm(sc)->conn_exp = TICK_ETERNITY;
 		oc->flags |= CF_WRITE_NULL;
 		if (sc->state == SC_ST_CON)
 			sc->state = SC_ST_RDY;