MEDIUM: connection: make it possible for data->wake to return an error
Just like ->init(), ->wake() may now be used to return an error and
abort the connection. Currently this is not used but will be with
embryonic sessions.
diff --git a/src/connection.c b/src/connection.c
index 949e9cc..e156366 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -123,8 +123,14 @@
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))))