]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: checks: don't poll on recv when using plain TCP connects
authorWilly Tarreau <w@1wt.eu>
Thu, 5 Dec 2013 00:53:08 +0000 (01:53 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 5 Dec 2013 01:23:48 +0000 (02:23 +0100)
When pure TCP checks are used, we see a useless call to recvfrom()
in strace resulting from an inconditional poll on recv after the
connect() succeeds. Let's remove this one and properly report
connection success in the write events.

src/checks.c

index efe6979f26af339a76b9afd8c6289b12978b2a78..15e667eac7689fa24de5260c6235d8926033da27 100644 (file)
@@ -927,7 +927,12 @@ static void event_srv_chk_w(struct connection *conn)
                goto out_wakeup;
        }
 
-       /* here, we know that the connection is established */
+       /* here, we know that the connection is established. That's enough for
+        * a pure TCP check.
+        */
+       if (!check->type)
+               goto out_wakeup;
+
        if (check->bo->o) {
                conn->xprt->snd_buf(conn, check->bo, MSG_DONTWAIT | MSG_NOSIGNAL);
                if (conn->flags & CO_FL_ERROR) {
@@ -1336,8 +1341,7 @@ static void event_srv_chk_r(struct connection *conn)
                break;
 
        default:
-               /* other checks are valid if the connection succeeded anyway */
-               set_server_check_status(check, HCHK_STATUS_L4OK, NULL);
+               /* for other checks (eg: pure TCP), delegate to the main task */
                break;
        } /* switch */
 
@@ -1554,7 +1558,10 @@ static struct task *process_chk(struct task *t)
                                int t_con = tick_add(now_ms, s->proxy->timeout.connect);
                                t->expire = tick_first(t->expire, t_con);
                        }
-                       conn_data_poll_recv(conn);   /* prepare for reading a possible reply */
+
+                       if (check->type)
+                               conn_data_want_recv(conn);   /* prepare for reading a possible reply */
+
                        goto reschedule;
 
                case SN_ERR_SRVTO: /* ETIMEDOUT */