/*
* State transition functions
*/
-static void connection_state_closed_enter(fr_connection_t *conn);
-static void connection_state_failed_enter(fr_connection_t *conn);
-static void connection_state_timeout_enter(fr_connection_t *conn);
-static void connection_state_connected_enter(fr_connection_t *conn);
-static void connection_state_shutdown_enter(fr_connection_t *conn);
-static void connection_state_connecting_enter(fr_connection_t *conn);
-static void connection_state_halted_enter(fr_connection_t *conn);
-static void connection_state_init_enter(fr_connection_t *conn);
+static void connection_state_enter_closed(fr_connection_t *conn);
+static void connection_state_enter_failed(fr_connection_t *conn);
+static void connection_state_enter_timeout(fr_connection_t *conn);
+static void connection_state_enter_connected(fr_connection_t *conn);
+static void connection_state_enter_shutdown(fr_connection_t *conn);
+static void connection_state_enter_connecting(fr_connection_t *conn);
+static void connection_state_enter_halted(fr_connection_t *conn);
+static void connection_state_enter_init(fr_connection_t *conn);
/** Add a deferred signal to the signal list
*
switch (conn->pub.state) {
case FR_CONNECTION_STATE_FAILED:
case FR_CONNECTION_STATE_CLOSED:
- connection_state_init_enter(conn);
+ connection_state_enter_init(conn);
break;
default:
/** Close the connection, then wait for another state change
*
*/
-static void connection_state_closed_enter(fr_connection_t *conn)
+static void connection_state_enter_closed(fr_connection_t *conn)
{
switch (conn->pub.state) {
case FR_CONNECTION_STATE_CONNECTING:
{
fr_connection_t *conn = talloc_get_type_abort(uctx, fr_connection_t);
- connection_state_timeout_enter(conn);
+ connection_state_enter_timeout(conn);
}
/** Gracefully shutdown the handle
*
*/
-static void connection_state_shutdown_enter(fr_connection_t *conn)
+static void connection_state_enter_shutdown(fr_connection_t *conn)
{
fr_connection_state_t ret;
break;
default:
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
return;
}
WATCH_POST(conn);
* Can happen when the event loop is exiting
*/
PERROR("Failed setting connection_timeout timer, closing connection");
- connection_state_closed_enter(conn);
+ connection_state_enter_closed(conn);
}
}
}
*
* @param[in] conn that failed.
*/
-static void connection_state_failed_enter(fr_connection_t *conn)
+static void connection_state_enter_failed(fr_connection_t *conn)
{
fr_connection_state_t prev;
fr_connection_state_t ret = FR_CONNECTION_STATE_INIT;
case FR_CONNECTION_STATE_CONNECTING:
case FR_CONNECTION_STATE_TIMEOUT: /* Timeout means the connection progress past init */
case FR_CONNECTION_STATE_SHUTDOWN: /* Shutdown means the connection failed whilst shutting down */
- connection_state_closed_enter(conn);
+ connection_state_enter_closed(conn);
break;
default:
*/
case FR_CONNECTION_STATE_HALTED:
default:
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
return;
}
}
* Can happen when the event loop is exiting
*/
PERROR("Failed inserting reconnection_delay timer event, halting connection");
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
}
return;
}
* reconnect, and wait to be
* signalled.
*/
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
case FR_CONNECTION_STATE_TIMEOUT: /* Failed during connecting due to timeout */
- connection_state_init_enter(conn);
+ connection_state_enter_init(conn);
break;
default:
* The connection took took long to open. Timeout the attempt and transition
* to the failed state.
*/
-static void connection_state_timeout_enter(fr_connection_t *conn)
+static void connection_state_enter_timeout(fr_connection_t *conn)
{
switch (conn->pub.state) {
case FR_CONNECTION_STATE_CONNECTING:
conn->pub.timed_out++;
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
}
/** Enter the halted state
*
* Here we wait, until signalled by fr_connection_signal_reconnect.
*/
-static void connection_state_halted_enter(fr_connection_t *conn)
+static void connection_state_enter_halted(fr_connection_t *conn)
{
rad_assert(conn->is_closed);
*
* @param[in] conn Entering the connecting state.
*/
-static void connection_state_connected_enter(fr_connection_t *conn)
+static void connection_state_enter_connected(fr_connection_t *conn)
{
int ret;
case FR_CONNECTION_STATE_FAILED:
default:
PERROR("Connection failed");
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
return;
}
}
*
* @param[in] conn Entering the connecting state.
*/
-static void connection_state_connecting_enter(fr_connection_t *conn)
+static void connection_state_enter_connecting(fr_connection_t *conn)
{
switch (conn->pub.state) {
case FR_CONNECTION_STATE_INIT:
* will be halted and sit idle until its
* freed.
*/
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
}
}
}
*
* @param[in] conn To initialise.
*/
-static void connection_state_init_enter(fr_connection_t *conn)
+static void connection_state_enter_init(fr_connection_t *conn)
{
fr_connection_state_t ret;
case FR_CONNECTION_STATE_CONNECTING:
conn->is_closed = false; /* We now have a handle */
WATCH_POST(conn); /* Only call if we successfully initialised the handle */
- connection_state_connecting_enter(conn);
+ connection_state_enter_connecting(conn);
return;
/*
case FR_CONNECTION_STATE_FAILED:
default:
PERROR("Connection initialisation failed");
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
break;
}
}
switch (conn->pub.state) {
case FR_CONNECTION_STATE_HALTED:
- connection_state_init_enter(conn);
+ connection_state_enter_init(conn);
break;
default:
switch (conn->pub.state) {
case FR_CONNECTION_STATE_CONNECTING:
- connection_state_connected_enter(conn);
+ connection_state_enter_connected(conn);
break;
default:
break;
case FR_CONNECTION_STATE_INIT:
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
case FR_CONNECTION_STATE_CONNECTED:
case FR_CONNECTION_STATE_CONNECTING:
if (conn->shutdown) {
- connection_state_shutdown_enter(conn);
+ connection_state_enter_shutdown(conn);
break;
}
connection_state_closed_enter(conn);
/* FALL-THROUGH */
case FR_CONNECTION_STATE_FAILED:
+ connection_state_enter_closed(conn);
rad_assert(conn->is_closed);
- connection_state_halted_enter(conn);
break;
case FR_CONNECTION_STATE_TIMEOUT:
case FR_CONNECTION_STATE_CLOSED:
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
case FR_CONNECTION_STATE_MAX:
case FR_CONNECTION_STATE_SHUTDOWN:
case FR_CONNECTION_STATE_TIMEOUT:
case FR_CONNECTION_STATE_CLOSED:
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
case FR_CONNECTION_STATE_CONNECTED:
/* FALL-THROUGH */
case FR_CONNECTION_STATE_FAILED:
rad_assert(conn->is_closed);
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
case FR_CONNECTION_STATE_MAX:
fr_connection_t *conn = talloc_get_type_abort(uctx, fr_connection_t);
ERROR("Connection failed for fd (%u): %s", fd, fr_syserror(fd_errno));
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
}
/** Receive a write notification after a socket is connected
fr_connection_t *conn = talloc_get_type_abort(uctx, fr_connection_t);
fr_event_fd_delete(el, fd, FR_EVENT_FILTER_IO);
- connection_state_connected_enter(conn);
+ connection_state_enter_connected(conn);
}
/** Remove the FD we were watching for connection open/fail from the event loop
conn) < 0) {
PERROR("Failed inserting fd (%u) into event loop %p",
fd, conn->pub.el);
- connection_state_failed_enter(conn);
+ connection_state_enter_failed(conn);
return -1;
}
*/
case FR_CONNECTION_STATE_CONNECTING:
case FR_CONNECTION_STATE_CONNECTED:
- connection_state_closed_enter(conn);
+ connection_state_enter_closed(conn);
/* FALL-THROUGH */
default:
- connection_state_halted_enter(conn);
+ connection_state_enter_halted(conn);
break;
}
return 0;