* - SN_ERR_RESOURCE if a system resource is lacking (eg: fd limits, ports, ...)
* - SN_ERR_INTERNAL for any other purely internal errors
* Additionnally, in the case of SN_ERR_RESOURCE, an emergency log will be emitted.
+ * Note that we try to prevent the network stack from sending the ACK during the
+ * connect() when a pure TCP check is used.
*/
- ret = s->check.proto->connect(conn, 1);
+ ret = s->check.proto->connect(conn, (s->proxy->options2 & PR_O2_CHK_ANY) ? 1 : 2);
__conn_data_want_recv(conn); /* prepare for reading a possible reply */
conn->flags |= CO_FL_WAKE_DATA;
if (s->check.send_proxy)
* bind addresses are still determined locally (due to the possible need of a
* source port). conn->target may point either to a valid server or to a backend,
* depending on conn->target. Only OBJ_TYPE_PROXY and OBJ_TYPE_SERVER are
- * supported. The <data> parameter is a boolean indicating whether there are data
- * waiting for being sent or not, in order to adjust data write polling and on
- * some platforms, the ability to avoid an empty initial ACK.
+ * supported. The <data> parameter indicates when non-zero that data will
+ * immediately follow the connection and will tune the ACK behaviour after
+ * the connect :
+ * - 0 = always send it
+ * - 1 = send it unless the backends has the tcp-smart-connect option
+ * - 2 = never send it
*
* It can return one of :
* - SN_ERR_NONE if everything's OK
#if defined(TCP_QUICKACK)
/* disabling tcp quick ack now allows the first request to leave the
* machine with the first ACK. We only do this if there are pending
- * data in the buffer.
+ * data in the buffer or if we plan to close after SYN/ACK (TCP checks).
*/
- if ((be->options2 & PR_O2_SMARTCON) && data)
+ if (data == 2 || (data && (be->options2 & PR_O2_SMARTCON)))
setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &zero, sizeof(zero));
#endif