]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move pasue / resume callbacks to client config structure
authorAlan T. DeKok <aland@freeradius.org>
Thu, 16 May 2024 13:13:26 +0000 (09:13 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 16 May 2024 13:13:41 +0000 (09:13 -0400)
src/bin/radclient-ng.c
src/protocols/radius/client.c
src/protocols/radius/client.h

index 384a71fa8649862b9e0fe9622498d504dd9138e5..ff8ab2b3de2335a14cfb9cdb9ed559012caa9de9 100644 (file)
@@ -1686,6 +1686,15 @@ int main(int argc, char **argv)
                fr_exit_now(1);
        }
 
+       /*
+        *      Set callbacks so that the socket is automatically
+        *      paused or resumed when the socket becomes writeable.
+        */
+       client_config.pause_resume_cfg = (fr_bio_packet_cb_funcs_t) {
+               .write_blocked = client_bio_write_pause,
+               .write_resume = client_bio_write_resume,
+       };
+
        /*
         *      Open the RADIUS client bio, and then get the information associated with it.
         */
@@ -1695,15 +1704,6 @@ int main(int argc, char **argv)
                fr_exit_now(1);
        }
 
-       /*
-        *      Set callbacks so that the socket is automatically
-        *      paused or resumed when the socket becomes writeable.
-        */
-       (void) fr_radius_client_bio_cb_set(client_bio, &(fr_bio_packet_cb_funcs_t) {
-                       .write_blocked = client_bio_write_pause,
-                       .write_resume = client_bio_write_resume,
-               });
-
        client_info = fr_radius_client_bio_info(client_bio);
        fr_assert(client_info != NULL);
 
index 3e22b799eba178b99282b42c6341531b38eb1e79..f48cb6cdcc4b78827d6fa997322861e38b3ecbf9 100644 (file)
@@ -90,6 +90,13 @@ fr_radius_client_fd_bio_t *fr_radius_client_fd_bio_alloc(TALLOC_CTX *ctx, size_t
         */
        my->fd->uctx = my;
 
+       /*
+        *      Set up read / write blocked / resume callbacks.
+        */
+       if (cfg->pause_resume_cfg.write_blocked || cfg->pause_resume_cfg.read_blocked) {
+               fr_radius_client_bio_cb_set((fr_bio_packet_t *) my, &cfg->pause_resume_cfg);
+       }
+
        my->info.fd_info = fr_bio_fd_info(my->fd);
        fr_assert(my->info.fd_info != NULL);
 
@@ -551,6 +558,12 @@ int fr_radius_client_bio_cb_set(fr_bio_packet_t *bio, fr_bio_packet_cb_funcs_t c
        fr_radius_client_fd_bio_t *my = talloc_get_type_abort(bio, fr_radius_client_fd_bio_t);
        fr_bio_cb_funcs_t bio_cb = {};
 
+       /*
+        *      If we have a "blocked" function, we must have a "resume" function, and vice versa.
+        */
+       fr_assert((cb->write_blocked != NULL) == (cb->write_resume != NULL));
+       fr_assert((cb->read_blocked != NULL) == (cb->read_resume != NULL));
+
 #undef SET
 #define SET(_x) if (cb->_x) bio_cb._x = fr_bio_ ## _x
 
index 7c0671444702df2067b19ca49bd9384de3c63b2b..a995ca8fc1a32b008c63001cc243913ad443df16 100644 (file)
@@ -38,6 +38,8 @@ typedef struct {
 
        fr_bio_retry_config_t   retry_cfg;
 
+       fr_bio_packet_cb_funcs_t pause_resume_cfg;
+
        bool                    outgoing[FR_RADIUS_CODE_MAX];   //!< allowed outgoing packet types
 
        fr_retry_config_t       retry[FR_RADIUS_CODE_MAX];      //!< default retry configuration for each packet type