MEDIUM: proto: Change the prototype of the connect() method.
The connect() method had 2 arguments, "data", that tells if there's pending
data to be sent, and "delack" that tells if we have to use a delayed ack
inconditionally, or if the backend is configured with tcp-smart-connect.
Turn that into one argument, "flags".
That way it'll be easier to provide more informations to connect() without
adding extra arguments.
diff --git a/include/proto/proto_tcp.h b/include/proto/proto_tcp.h
index d4e09c7..76f89b1 100644
--- a/include/proto/proto_tcp.h
+++ b/include/proto/proto_tcp.h
@@ -29,7 +29,7 @@
int tcp_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote);
int tcp_pause_listener(struct listener *l);
-int tcp_connect_server(struct connection *conn, int data, int delack);
+int tcp_connect_server(struct connection *conn, int flags);
int tcp_connect_probe(struct connection *conn);
int tcp_get_src(int fd, struct sockaddr *sa, socklen_t salen, int dir);
int tcp_get_dst(int fd, struct sockaddr *sa, socklen_t salen, int dir);
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 3cccc8f..8a4b77a 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -489,7 +489,8 @@
return SF_ERR_INTERNAL;
if (!conn_ctrl_ready(conn) || !conn_xprt_ready(conn)) {
- ret = conn->ctrl->connect(conn, !channel_is_empty(si_oc(si)), 0);
+ ret = conn->ctrl->connect(conn, channel_is_empty(si_oc(si)) ?
+ CONNECT_HAS_DATA : 0);
if (ret != SF_ERR_NONE)
return ret;
diff --git a/include/types/protocol.h b/include/types/protocol.h
index 378e2b0..a33d129 100644
--- a/include/types/protocol.h
+++ b/include/types/protocol.h
@@ -73,7 +73,7 @@
int (*unbind_all)(struct protocol *proto); /* unbind all bound listeners */
int (*enable_all)(struct protocol *proto); /* enable all bound listeners */
int (*disable_all)(struct protocol *proto); /* disable all bound listeners */
- int (*connect)(struct connection *, int data, int delack); /* connect function if any */
+ int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */
int (*get_src)(int fd, struct sockaddr *, socklen_t, int dir); /* syscall used to retrieve src addr */
int (*get_dst)(int fd, struct sockaddr *, socklen_t, int dir); /* syscall used to retrieve dst addr */
int (*drain)(int fd); /* indicates whether we can safely close the fd */
@@ -85,6 +85,9 @@
struct list list; /* list of registered protocols */
};
+#define CONNECT_HAS_DATA 0x00000001 /* There's data available to be sent */
+#define CONNECT_DELACK_SMART_CONNECT 0x00000002 /* Use a delayed ACK if the backend has tcp-smart-connect */
+#define CONNECT_DELACK_ALWAYS 0x00000004 /* Use a delayed ACK */
#endif /* _TYPES_PROTOCOL_H */
/*