* at the transport layer, which can be a connection opening/close, or any
* data movement. The <init> callback may be called by the connection handler
* at the end of a transport handshake, when it is about to transfer data and
- * the data layer is not ready yet.
+ * the data layer is not ready yet. Both <wake> and <init> may abort a connection
+ * by returning < 0.
*/
struct data_cb {
void (*recv)(struct connection *conn); /* data-layer recv callback */
void (*send)(struct connection *conn); /* data-layer send callback */
- void (*wake)(struct connection *conn); /* data-layer callback to report activity */
+ int (*wake)(struct connection *conn); /* data-layer callback to report activity */
int (*init)(struct connection *conn); /* data-layer initialization */
};
return 0;
}
- if ((conn->flags & CO_FL_WAKE_DATA) && ((conn->flags ^ flags) & CO_FL_CONN_STATE))
- conn->data->wake(conn);
+ /* The wake callback may be used to process a critical error and abort the
+ * connection. If so, we don't want to go further as the connection will
+ * have been released and the FD destroyed.
+ */
+ if ((conn->flags & CO_FL_WAKE_DATA) &&
+ ((conn->flags ^ flags) & CO_FL_CONN_STATE) &&
+ conn->data->wake(conn) < 0)
+ return 0;
/* Last check, verify if the connection just established */
if (unlikely(!(conn->flags & (CO_FL_WAIT_L4_CONN | CO_FL_WAIT_L6_CONN | CO_FL_CONNECTED))))
static void stream_int_chk_snd_conn(struct stream_interface *si);
static void si_conn_recv_cb(struct connection *conn);
static void si_conn_send_cb(struct connection *conn);
-static void si_conn_wake_cb(struct connection *conn);
+static int si_conn_wake_cb(struct connection *conn);
/* stream-interface operations for embedded tasks */
struct si_ops si_embedded_ops = {
* the update function in that it is designed to be called by lower layers after I/O
* events have been completed. It will also try to wake the associated task up if
* an important event requires special handling. It relies on the connection handler
- * to commit any polling updates.
+ * to commit any polling updates. The function always returns 0.
*/
-static void si_conn_wake_cb(struct connection *conn)
+static int si_conn_wake_cb(struct connection *conn)
{
struct stream_interface *si = conn->owner;
}
if (si->ib->flags & CF_READ_ACTIVITY)
si->ib->flags &= ~CF_READ_DONTWAIT;
+ return 0;
}
/*