diff -urN haproxy-1.2.7/haproxy.c haproxy-1.2.7.1/haproxy.c --- haproxy-1.2.7/haproxy.c Sun Nov 13 09:43:57 2005 +++ haproxy-1.2.7.1/haproxy.c Sun Dec 4 09:39:01 2005 @@ -2281,6 +2281,20 @@ if (fdtab[fd].state != FD_STERROR) { if (max == 0) { /* may be we have received a connection acknowledgement in TCP mode without data */ + if (s->srv_state == SV_STCONN) { + int skerr; + socklen_t lskerr = sizeof(skerr); + getsockopt(fd, SOL_SOCKET, SO_ERROR, &skerr, &lskerr); + if (skerr) { + s->res_sw = RES_ERROR; + fdtab[fd].state = FD_STERROR; + task_wakeup(&rq, t); + tv_eternity(&s->swexpire); + FD_CLR(fd, StaticWriteEvent); + return 0; + } + } + s->res_sw = RES_NULL; task_wakeup(&rq, t); fdtab[fd].state = FD_STREADY; @@ -2835,7 +2849,8 @@ /* in case of TCP only, this tells us if the connection succeeded */ if (skerr) s->result = -1; - else { + else if (s->result != -1) { + /* we don't want to mark 'UP' a server on which we detected an error earlier */ if (s->proxy->options & PR_O_HTTP_CHK) { int ret; /* we want to check if this host replies to "OPTIONS / HTTP/1.0" @@ -2872,11 +2887,11 @@ */ int event_srv_chk_r(int fd) { char reply[64]; - int len; + int len, result; struct task *t = fdtab[fd].owner; struct server *s = t->context; - s->result = len = -1; + result = len = -1; #ifndef MSG_NOSIGNAL { int skerr; @@ -2896,7 +2911,10 @@ if ((len >= sizeof("HTTP/1.0 000")) && !memcmp(reply, "HTTP/1.", 7) && (reply[9] == '2' || reply[9] == '3')) /* 2xx or 3xx */ - s->result = 1; + result = 1; + + if (s->result != -1) + s->result = result; FD_CLR(fd, StaticReadEvent); task_wakeup(&rq, t);