]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: make h2s_wake_one_stream() not depend on temporary CS flags
authorWilly Tarreau <w@1wt.eu>
Tue, 7 May 2019 15:48:59 +0000 (17:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 14 May 2019 13:47:57 +0000 (15:47 +0200)
In h2s_wake_one_stream() we used to rely on the temporary flags used to
adjust the CS to determine the new h2s state. This really is not convenient
and creates far too many dependencies. This commit just moves the same
condition to the places where the temporary flags were set so that we
don't have to rely on these anymore. Whether these are relevant or not
was not the subject of the operation, what matters was to make sure the
conditions to adjust the stream's state and the CS's flags remain the
same. Later it could be studied if these conditions are correct or not.

src/mux_h2.c

index 6233fec4bab6cef131ed46cf65b42a464749706d..8dcf27855b144af45c1dfd3f2f5f1dc3ea17caf7 100644 (file)
@@ -1426,35 +1426,32 @@ static int h2_send_empty_data_es(struct h2s *h2s)
  */
 static void h2s_wake_one_stream(struct h2s *h2s)
 {
-       uint32_t flags = 0;
-
        if (!h2s->cs) {
                /* this stream was already orphaned */
                h2s_destroy(h2s);
                return;
        }
 
-       if (conn_xprt_read0_pending(h2s->h2c->conn))
-               flags |= CS_FL_REOS;
+       if (conn_xprt_read0_pending(h2s->h2c->conn)) {
+               h2s->cs->flags |= CS_FL_REOS;
 
-       if (h2s->h2c->st0 >= H2_CS_ERROR || h2s->h2c->conn->flags & CO_FL_ERROR)
-               flags |= CS_FL_ERR_PENDING;
+               if (h2s->st == H2_SS_OPEN)
+                       h2s->st = H2_SS_HREM;
+               else if (h2s->st == H2_SS_HLOC)
+                       h2s_close(h2s);
+       }
 
-       if (h2s->h2c->last_sid > 0 && (!h2s->id || h2s->id > h2s->h2c->last_sid))
-               flags |= CS_FL_ERR_PENDING;
+       if ((h2s->h2c->st0 >= H2_CS_ERROR || h2s->h2c->conn->flags & CO_FL_ERROR) ||
+           (h2s->h2c->last_sid > 0 && (!h2s->id || h2s->id > h2s->h2c->last_sid))) {
+               h2s->cs->flags |= CS_FL_ERR_PENDING;
+               if (h2s->cs->flags & CS_FL_EOS)
+                       h2s->cs->flags |= CS_FL_ERROR;
 
-       h2s->cs->flags |= flags;
-       if ((flags & CS_FL_ERR_PENDING) && (h2s->cs->flags & CS_FL_EOS))
-               h2s->cs->flags |= CS_FL_ERROR;
+               if (h2s->st < H2_SS_ERROR)
+                       h2s->st = H2_SS_ERROR;
+       }
 
        h2s_alert(h2s);
-
-       if (flags & CS_FL_ERR_PENDING && h2s->st < H2_SS_ERROR)
-               h2s->st = H2_SS_ERROR;
-       else if ((flags & (CS_FL_EOI|CS_FL_REOS)) && h2s->st == H2_SS_OPEN)
-               h2s->st = H2_SS_HREM;
-       else if ((flags & (CS_FL_EOI|CS_FL_REOS)) && h2s->st == H2_SS_HLOC)
-               h2s_close(h2s);
 }
 
 /* wake the streams attached to the connection, whose id is greater than <last>