MEDIUM: tree-wide: Stop to set SE_FL_ERROR from upper layer
We can now fully rely on SC_FL_ERROR flag from the stream. The first step is
to stop to set the SE_FL_ERROR flag. Only endpoints are responsible to set
this flag. It was a design limitation. It is now fixed.
diff --git a/src/backend.c b/src/backend.c
index 9b7e9e1..2d4ea4b 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -1822,10 +1822,8 @@
* sockets, socket pairs, andoccasionally TCP connections on the
* loopback on a heavily loaded system.
*/
- if (srv_conn->flags & CO_FL_ERROR) {
- sc_ep_set(s->scb, SE_FL_ERROR);
+ if (srv_conn->flags & CO_FL_ERROR)
s->scb->flags |= SC_FL_ERROR;
- }
/* If we had early data, and the handshake ended, then
* we can remove the flag, and attempt to wake the task up,
@@ -2026,7 +2024,6 @@
/* Failed and not retryable. */
sc_abort(sc);
sc_shutdown(sc);
- sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
sc->flags |= SC_FL_ERROR;
s->logs.t_queue = tv_ms_elapsed(&s->logs.tv_accept, &now);
@@ -2047,7 +2044,6 @@
* allocation problem, so we want to retry now.
*/
sc->state = SC_ST_CER;
- sc_ep_clr(sc, SE_FL_ERROR);
sc->flags &= ~SC_FL_ERROR;
back_handle_st_cer(s);
@@ -2188,7 +2184,6 @@
sc_abort(sc);
sc_shutdown(sc);
- sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
sc->flags |= SC_FL_ERROR;
s->conn_err_type = STRM_ET_CONN_RES;
sc->state = SC_ST_CLO;
@@ -2215,7 +2210,6 @@
/* we did not get any server, let's check the cause */
sc_abort(sc);
sc_shutdown(sc);
- sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
sc->flags |= SC_FL_ERROR;
if (!s->conn_err_type)
s->conn_err_type = STRM_ET_CONN_OTHER;
@@ -2350,7 +2344,6 @@
/* shutw is enough to stop a connecting socket */
sc_shutdown(sc);
- sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
sc->flags |= SC_FL_ERROR;
sc->state = SC_ST_CLO;
@@ -2369,7 +2362,7 @@
* layers in an unexpected state (i.e < ST_CONN).
*
* Note: the stream connector will be switched to ST_REQ, ST_ASS or
- * ST_TAR and SE_FL_ERROR and SF_CONN_EXP flags will be unset.
+ * ST_TAR and SC_FL_ERROR and SF_CONN_EXP flags will be unset.
*/
if (sc_reset_endp(sc) < 0) {
if (!s->conn_err_type)
@@ -2384,7 +2377,6 @@
/* shutw is enough to stop a connecting socket */
sc_shutdown(sc);
- sc_ep_set(sc, SE_FL_ERROR|SE_FL_EOS);
sc->flags |= SC_FL_ERROR;
sc->state = SC_ST_CLO;
diff --git a/src/stconn.c b/src/stconn.c
index 6b2397c..f4d54a7 100644
--- a/src/stconn.c
+++ b/src/stconn.c
@@ -1725,11 +1725,11 @@
/* First step, report to the stream connector what was detected at the
* connection layer : errors and connection establishment.
- * Only add SE_FL_ERROR if we're connected, or we're attempting to
+ * Only add SC_FL_ERROR if we're connected, or we're attempting to
* connect, we may get there because we got woken up, but only run
* after process_stream() noticed there were an error, and decided
* to retry to connect, the connection may still have CO_FL_ERROR,
- * and we don't want to add SE_FL_ERROR back
+ * and we don't want to add SC_FL_ERROR back
*
* Note: This test is only required because sc_conn_process is also the SI
* wake callback. Otherwise sc_conn_recv()/sc_conn_send() already take
@@ -1737,10 +1737,8 @@
*/
if (sc->state >= SC_ST_CON) {
- if (sc_is_conn_error(sc)) {
- sc_ep_set(sc, SE_FL_ERROR);
+ if (sc_is_conn_error(sc))
sc->flags |= SC_FL_ERROR;
- }
}
/* If we had early data, and the handshake ended, then
diff --git a/src/stream.c b/src/stream.c
index 36af89f..238b49c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -1805,11 +1805,9 @@
* must be be reviewed too.
*/
if (!stream_alloc_work_buffer(s)) {
- sc_ep_set(s->scf, SE_FL_ERROR);
scf->flags |= SC_FL_ERROR;
s->conn_err_type = STRM_ET_CONN_RES;
- sc_ep_set(s->scb, SE_FL_ERROR);
scb->flags |= SC_FL_ERROR;
s->conn_err_type = STRM_ET_CONN_RES;