]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move commonly used functions to the trunk code
authorAlan T. DeKok <aland@freeradius.org>
Sat, 7 Jan 2023 13:58:35 +0000 (08:58 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 13 Jan 2023 14:02:07 +0000 (09:02 -0500)
There's no need to reproduce these in multiple client IO modules.

src/lib/server/trunk.c
src/lib/server/trunk.h
src/modules/rlm_radius/rlm_radius_udp.c

index 1b9b3fffa0cd1ad92868e409b432afb7cd835310..97ab792c662516bc197a4c2c2f10360be355ed62 100644 (file)
@@ -3872,6 +3872,41 @@ void fr_trunk_connection_signal_reconnect(fr_trunk_connection_t *tconn, fr_conne
        fr_connection_signal_reconnect(tconn->pub.conn, reason);
 }
 
+/** Standard I/O read function
+ *
+ * Underlying FD in now readable, so call the trunk to read any pending requests
+ * from this connection.
+ *
+ * @param[in] el       The event list signalling.
+ * @param[in] fd       that's now readable.
+ * @param[in] flags    describing the read event.
+ * @param[in] uctx     The trunk connection handle (tconn).
+ */
+void fr_trunk_connection_callback_readable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
+{
+       fr_trunk_connection_t   *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
+
+       fr_trunk_connection_signal_readable(tconn);
+}
+
+/** Standard I/O write function
+ *
+ * Underlying FD is now writable, so call the trunk to write any pending requests
+ * to this connection.
+ *
+ * @param[in] el       The event list signalling.
+ * @param[in] fd       that's now writable.
+ * @param[in] flags    describing the write event.
+ * @param[in] uctx     The trunk connection handle (tcon).
+ */
+void fr_trunk_connection_callback_writable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
+{
+       fr_trunk_connection_t   *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
+
+       fr_trunk_connection_signal_writable(tconn);
+}
+
+
 /** Returns true if the trunk connection is in one of the specified states
  *
  * @param[in] tconn    To check state for.
index 575a00c8fde9187168b3c761a8aea8392b5c3721..8ca9df92f056785c4b342b1559fd339f233a7cb1 100644 (file)
@@ -846,6 +846,14 @@ void               fr_trunk_connection_signal_reconnect(fr_trunk_connection_t *tconn, fr_conn
 bool           fr_trunk_connection_in_state(fr_trunk_connection_t *tconn, int state);
 /** @} */
 
+/** @name Connection Callbacks
+ * @{
+ */
+void           fr_trunk_connection_callback_writable(fr_event_list_t *el, int fd, int flags, void *uctx);
+
+void           fr_trunk_connection_callback_readable(fr_event_list_t *el, int fd, int flags, void *uctx);
+/** @} */
+
 /** @name Connection management
  * @{
  */
index 0ff4be86107aa62b609625c5ca604db0c8195c16..7b1b247d57819f6c6e6e3a8ac6eacea595e6d3a7 100644 (file)
@@ -981,40 +981,6 @@ static void conn_discard(UNUSED fr_event_list_t *el, int fd, UNUSED int flags, v
        }
 }
 
-/** Standard I/O read function
- *
- * Underlying FD in now readable, so call the trunk to read any pending requests
- * from this connection.
- *
- * @param[in] el       The event list signalling.
- * @param[in] fd       that's now readable.
- * @param[in] flags    describing the read event.
- * @param[in] uctx     The trunk connection handle (tconn).
- */
-static void conn_readable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
-{
-       fr_trunk_connection_t   *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
-
-       fr_trunk_connection_signal_readable(tconn);
-}
-
-/** Standard I/O write function
- *
- * Underlying FD is now writable, so call the trunk to write any pending requests
- * to this connection.
- *
- * @param[in] el       The event list signalling.
- * @param[in] fd       that's now writable.
- * @param[in] flags    describing the write event.
- * @param[in] uctx     The trunk connection handle (tcon).
- */
-static void conn_writable(UNUSED fr_event_list_t *el, UNUSED int fd, UNUSED int flags, void *uctx)
-{
-       fr_trunk_connection_t   *tconn = talloc_get_type_abort(uctx, fr_trunk_connection_t);
-
-       fr_trunk_connection_signal_writable(tconn);
-}
-
 /** Connection errored
  *
  * We were signalled by the event loop that a fatal error occurred on this connection.
@@ -1057,16 +1023,16 @@ static void thread_conn_notify(fr_trunk_connection_t *tconn, fr_connection_t *co
                break;
 
        case FR_TRUNK_CONN_EVENT_READ:
-               read_fn = conn_readable;
+               read_fn = fr_trunk_connection_callback_readable;
                break;
 
        case FR_TRUNK_CONN_EVENT_WRITE:
-               write_fn = conn_writable;
+               write_fn = fr_trunk_connection_callback_writable;
                break;
 
        case FR_TRUNK_CONN_EVENT_BOTH:
-               read_fn = conn_readable;
-               write_fn = conn_writable;
+               read_fn = fr_trunk_connection_callback_readable;
+               write_fn = fr_trunk_connection_callback_writable;
                break;
 
        }
@@ -1109,7 +1075,7 @@ static void thread_conn_notify_replicate(fr_trunk_connection_t *tconn, fr_connec
        case FR_TRUNK_CONN_EVENT_BOTH:
        case FR_TRUNK_CONN_EVENT_WRITE:
                read_fn = conn_discard;
-               write_fn = conn_writable;
+               write_fn = fr_trunk_connection_callback_writable;
                break;
        }