BUG/MEDIUM: checks: Don't blindly subscribe for receive if waiting for connect

When an health check is waiting for a connection establishment, it subscribe for
receive or send events, depending on the next rule to be evaluated. For
subscription for send events, there is no problem. It works as expected. For
subscription for receive events, It only works for HTTP checks because the
underlying multiplexer takes care to do a receive before subscribing again,
updating the fd state. For TCP checks, the PT multiplexer only forwards
subscriptions at the transport layer. So the check itself is woken up. This
leads to a subscribe/notify loop waiting the connection establishment or a
timeout, uselessly eating CPU.

Thus, when a check is waiting for a connect, instead of blindly resubscribe for
receive events when it is woken up, we now try to receive data.

This patch should fix the issue #635. No backport needed.
diff --git a/src/checks.c b/src/checks.c
index 8b85286..9b4e41c 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -2623,6 +2623,7 @@
 	struct connection *conn = cs_conn(cs);
 	int must_read = 1, last_read = 0;
 	int ret, retcode = 0;
+	enum tcpcheck_eval_ret eval_ret;
 
 	/* here, we know that the check is complete or that it failed */
 	if (check->result != CHK_RES_UNKNOWN)
@@ -2647,12 +2648,17 @@
 			if (next && next->action == TCPCHK_ACT_SEND) {
 				if (!(check->wait_list.events & SUB_RETRY_SEND))
 					conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
+				goto out;
 			}
 			else {
-				if (!(check->wait_list.events & SUB_RETRY_RECV))
-					conn->mux->subscribe(cs, SUB_RETRY_RECV, &check->wait_list);
+				eval_ret = tcpcheck_eval_recv(check, check->current_step);
+				if (eval_ret == TCPCHK_EVAL_STOP)
+					goto out_end_tcpcheck;
+				else if (eval_ret == TCPCHK_EVAL_WAIT)
+					goto out;
+				last_read = ((conn->flags & CO_FL_ERROR) || (cs->flags & (CS_FL_ERROR|CS_FL_EOS)));
+				must_read = 0;
 			}
-			goto out;
 		}
 		rule = LIST_NEXT(&check->current_step->list, typeof(rule), list);
 	}
@@ -2713,8 +2719,6 @@
 	/* Now evaluate the tcp-check rules */
 
 	list_for_each_entry_from(rule, check->tcpcheck_rules->list, list) {
-		enum tcpcheck_eval_ret eval_ret;
-
 		check->code = 0;
 		switch (rule->action) {
 		case TCPCHK_ACT_CONNECT: