]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] process shutw during connection attempt
authorWilly Tarreau <w@1wt.eu>
Thu, 27 Nov 2008 08:25:45 +0000 (09:25 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 27 Nov 2008 08:25:45 +0000 (09:25 +0100)
It sometimes happens that a connection is aborted at the exact same moment
it establishes. We have to close the socket and not only to shut it down
for writes.

Some corner cases remain. We have to handle the shutr/shutw at the stream
interface and only report the status to the buffer, not the opposite.

src/proto_http.c
src/stream_sock.c

index f73964a3c59b6ae1ddc1ca5d07ed82f8bab9d87b..b3b46ef708cedd121f89e3ffc8bec8abc880b5eb 100644 (file)
@@ -1298,7 +1298,7 @@ void process_session(struct task *t, int *next)
        }
 
        if (likely((s->rep->cons->state != SI_ST_CLO) ||
-                  (s->req->cons->state != SI_ST_CLO && s->req->cons->state != SI_ST_INI))) {
+                  (s->req->cons->state > SI_ST_INI && s->req->cons->state < SI_ST_CLO))) {
 
                if ((s->fe->options & PR_O_CONTSTATS) && (s->flags & SN_BE_ASSIGNED))
                        session_process_counters(s);
index 584a1cd878feb422f9684d137efc029ca36bd557..8d531ed15c00522d1f904054276754eef8d60f03 100644 (file)
@@ -486,9 +486,6 @@ int stream_sock_write(int fd) {
 void stream_sock_shutw(struct stream_interface *si)
 {
        switch (si->state) {
-       case SI_ST_INI:
-               si->state = SI_ST_CLO;
-               return;
        case SI_ST_EST:
                if (!(si->ib->flags & BF_SHUTR)) {
                        EV_FD_CLR(si->fd, DIR_WR);
@@ -497,7 +494,11 @@ void stream_sock_shutw(struct stream_interface *si)
                }
                /* fall through */
        case SI_ST_CON:
+               /* we may have to close a pending connection, and mark the
+                * response buffer as shutr
+                */
                fd_delete(si->fd);
+               buffer_shutr(si->ib);
                si->state = SI_ST_DIS;
                return;
        }
@@ -513,11 +514,8 @@ void stream_sock_shutw(struct stream_interface *si)
  */
 void stream_sock_shutr(struct stream_interface *si)
 {
-       if (si->state != SI_ST_EST && si->state != SI_ST_CON) {
-               if (likely(si->state == SI_ST_INI))
-                       si->state = SI_ST_CLO;
+       if (si->state != SI_ST_EST && si->state != SI_ST_CON)
                return;
-       }
 
        if (si->ob->flags & BF_SHUTW) {
                fd_delete(si->fd);