void (*ctrl_close)(struct connection *); /* completes release of the connection */
int (*connect)(struct connection *, int flags); /* connect function if any, see below for flags values */
int (*drain)(struct connection *); /* drain pending data; 0=failed, >0=success */
+ int (*check_events)(struct connection *conn, int event_type); /* subscribe to socket events */
+ void (*ignore_events)(struct connection *conn, int event_type); /* unsubscribe from socket events */
/* functions acting on the receiver */
int (*rx_suspend)(struct receiver *rx); /* temporarily suspend this receiver for a soft restart */
void sock_conn_iocb(int fd);
int sock_conn_check(struct connection *conn);
int sock_drain(struct connection *conn);
+int sock_check_events(struct connection *conn, int event_type);
+void sock_ignore_events(struct connection *conn, int event_type);
#endif /* _HAPROXY_SOCK_H */
.ctrl_close = sock_conn_ctrl_close,
.connect = sockpair_connect_server,
.drain = sock_drain,
+ .check_events = sock_check_events,
+ .ignore_events = sock_ignore_events,
/* binding layer */
/* Note: suspend/resume not supported */
.ctrl_close = sock_conn_ctrl_close,
.connect = tcp_connect_server,
.drain = sock_drain,
+ .check_events = sock_check_events,
+ .ignore_events = sock_ignore_events,
/* binding layer */
.rx_suspend = tcp_suspend_receiver,
.ctrl_close = sock_conn_ctrl_close,
.connect = tcp_connect_server,
.drain = sock_drain,
+ .check_events = sock_check_events,
+ .ignore_events = sock_ignore_events,
/* binding layer */
.rx_suspend = tcp_suspend_receiver,
.ctrl_close = sock_conn_ctrl_close,
.connect = uxst_connect_server,
.drain = sock_drain,
+ .check_events = sock_check_events,
+ .ignore_events = sock_ignore_events,
/* binding layer */
.rx_suspend = uxst_suspend_receiver,
return 1;
}
+/* Checks the connection's FD for readiness of events <event_type>, which may
+ * only be a combination of SUB_RETRY_RECV and SUB_RETRY_SEND. Those which are
+ * ready are returned. The ones that are not ready are enabled. The caller is
+ * expected to do what is needed to handle ready events and to deal with
+ * subsequent wakeups caused by the requested events' readiness.
+ */
+int sock_check_events(struct connection *conn, int event_type)
+{
+ int ret = 0;
+
+ if (event_type & SUB_RETRY_RECV) {
+ if (fd_recv_ready(conn->handle.fd))
+ ret |= SUB_RETRY_RECV;
+ else
+ fd_want_recv(conn->handle.fd);
+ }
+
+ if (event_type & SUB_RETRY_SEND) {
+ if (fd_send_ready(conn->handle.fd))
+ ret |= SUB_RETRY_SEND;
+ else
+ fd_want_send(conn->handle.fd);
+ }
+
+ return ret;
+}
+
+/* Ignore readiness events from connection's FD for events of types <event_type>
+ * which may only be a combination of SUB_RETRY_RECV and SUB_RETRY_SEND.
+ */
+void sock_ignore_events(struct connection *conn, int event_type)
+{
+ if (event_type & SUB_RETRY_RECV)
+ fd_stop_recv(conn->handle.fd);
+
+ if (event_type & SUB_RETRY_SEND)
+ fd_stop_send(conn->handle.fd);
+}
+
/*
* Local variables:
* c-indent-level: 8