]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
make fd_set take listener
authorAlan T. DeKok <aland@freeradius.org>
Thu, 20 Sep 2018 13:51:37 +0000 (09:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 20 Sep 2018 17:06:00 +0000 (13:06 -0400)
src/lib/io/base.h
src/lib/io/master.c
src/modules/proto_control/proto_control_tcp.c
src/modules/proto_control/proto_control_unix.c
src/modules/proto_dhcpv4/proto_dhcpv4_udp.c
src/modules/proto_radius/proto_radius_tcp.c
src/modules/proto_radius/proto_radius_udp.c
src/modules/proto_vmps/proto_vmps_udp.c

index df31ae3489e7076a4604b6765b8b7c4b3f807516..28dfc925e7a30aecdd656c1b96f2a0516aeb72f6 100644 (file)
@@ -97,10 +97,10 @@ typedef int (*fr_io_get_fd_t)(fr_listen_t const *listen);
 /** Set a selectable file descriptor for this I/O path
  *
  *
- * @param[in] instance containing the configuration
+ * @param[in] listen   the listener for this socket
  * @param[in] fd       the FD to set
  */
-typedef int (*fr_io_set_fd_t)(void *instance, int fd);
+typedef int (*fr_io_set_fd_t)(fr_listen_t *listen, int fd);
 
 /** Decode a raw packet and convert it into a request.
  *
index 0f79ddc747f4d4967cf2e3a7dc13dd255efd0b3c..f4c5ae7115ddee44853699adf23b28d4fc9df343 100644 (file)
@@ -636,7 +636,7 @@ static fr_io_connection_t *fr_io_connection_alloc(fr_io_instance_t *inst, fr_io_
                /*
                 *      Set the new FD, and get the module to set it's connection name.
                 */
-               if (inst->app_io->fd_set(connection->child->app_io_instance, fd) < 0) {
+               if (inst->app_io->fd_set(connection->child, fd) < 0) {
                        DEBUG3("Failed setting FD to %s", inst->app_io->name);
                        close(fd);
                        return NULL;
index 756d428b41a3224f8058810d4250b10ff92a695e..8ca72ab4680179fb9dcc9a5dc01dd9294c1e6696 100644 (file)
@@ -288,12 +288,10 @@ static int mod_fd(fr_listen_t const *listen)
 
 /** Set the file descriptor for this socket.
  *
- * @param[in] instance of the RADIUS TCP I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_control_tcp_t *inst = talloc_get_type_abort(instance, proto_control_tcp_t);
+       proto_control_tcp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_control_tcp_t);
 
        inst->sockfd = fd;
 
index a6489c31595d078ba118905f4330076fb13a2779..b4f917e0b9dbaeb279318bffbbe4a3d3d4847b1f 100644 (file)
@@ -1024,12 +1024,10 @@ static int getpeereid(int s, uid_t *euid, gid_t *egid)
 
 /** Set the file descriptor for this socket.
  *
- * @param[in] instance of the RADIUS UNIX I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_control_unix_t *inst = talloc_get_type_abort(instance, proto_control_unix_t);
+       proto_control_unix_t *inst = talloc_get_type_abort(listen->thread_instance, proto_control_unix_t);
 #ifndef HAVE_FUNOPEN
        cookie_io_functions_t io;
 #endif
@@ -1091,13 +1089,13 @@ static int mod_fd_set(void *instance, int fd)
         *      Set up socket-specific callbacks
         */
 #ifdef HAVE_FUNOPEN
-       inst->stdout = funopen(instance, NULL, write_stdout, NULL, NULL);
+       inst->stdout = funopen(inst, NULL, write_stdout, NULL, NULL);
        rad_assert(inst->stdout != NULL);
 
-       inst->stderr = funopen(instance, NULL, write_stderr, NULL, NULL);
+       inst->stderr = funopen(inst, NULL, write_stderr, NULL, NULL);
        rad_assert(inst->stderr != NULL);
 
-       inst->misc = funopen(instance, NULL, write_misc, NULL, NULL);
+       inst->misc = funopen(inst, NULL, write_misc, NULL, NULL);
        rad_assert(inst->misc != NULL);
 #else
        /*
@@ -1108,13 +1106,13 @@ static int mod_fd_set(void *instance, int fd)
        io.close = NULL;
        io.write = write_stdout;
 
-       inst->stdout = fopencookie(instance, "w", io);
+       inst->stdout = fopencookie(inst, "w", io);
 
        io.write = write_stderr;
-       inst->stderr = fopencookie(instance, "w", io);
+       inst->stderr = fopencookie(inst, "w", io);
 
        io.write = write_misc;
-       inst->misc = fopencookie(instance, "w", io);
+       inst->misc = fopencookie(inst, "w", io);
 #endif
 
        /*
@@ -1127,8 +1125,8 @@ static int mod_fd_set(void *instance, int fd)
        (void) setvbuf(inst->stderr, NULL, _IOLBF, 0);
        (void) setvbuf(inst->misc, NULL, _IOLBF, 0);
 
-       inst->info = talloc_zero(instance, fr_cmd_info_t);
-       fr_command_info_init(instance, inst->info);
+       inst->info = talloc_zero(inst, fr_cmd_info_t);
+       fr_command_info_init(inst, inst->info);
 
        return 0;
 }
index 8e376ba27ac24984bfdf8f0b4903b3291af964d3..9b9d829e66fb3aa655f80a314aba7cc982cdb375 100644 (file)
@@ -556,12 +556,10 @@ static int mod_fd(fr_listen_t const *listen)
 
 /** Set the file descriptor for this socket.
  *
- * @param[in] instance of the UDP I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_dhcpv4_udp_t *inst = talloc_get_type_abort(instance, proto_dhcpv4_udp_t);
+       proto_dhcpv4_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_dhcpv4_udp_t);
 
        inst->sockfd = fd;
 
index 6adee5539bb0c11b25c5e49f90bc4cb954b9cdd2..2cb9b12f0b57ba6233894d1dfc33b0ee98b5248f 100644 (file)
@@ -370,13 +370,10 @@ static int mod_fd(fr_listen_t const *listen)
 }
 
 /** Set the file descriptor for this socket.
- *
- * @param[in] instance of the RADIUS TCP I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_radius_tcp_t *inst = talloc_get_type_abort(instance, proto_radius_tcp_t);
+       proto_radius_tcp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_radius_tcp_t);
 
        inst->sockfd = fd;
 
index e8716f7fc514e357908300d601e34339c58af631..0d5582151ece1d64c4458e17224eadbdf314e947 100644 (file)
@@ -406,12 +406,10 @@ static int mod_fd(fr_listen_t const *listen)
 
 /** Set the file descriptor for this socket.
  *
- * @param[in] instance of the RADIUS UDP I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_radius_udp_t *inst = talloc_get_type_abort(instance, proto_radius_udp_t);
+       proto_radius_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_radius_udp_t);
 
        inst->sockfd = fd;
 
index e14ff60db88a391a7523177b16ee3fb0f6a93fb4..7f7011a6243846a1f1eb9a968e57dda89cdec990 100644 (file)
@@ -384,12 +384,10 @@ static int mod_fd(fr_listen_t const *listen)
 
 /** Set the file descriptor for this socket.
  *
- * @param[in] instance of the UDP I/O path.
- * @param[in] fd the FD to set
  */
-static int mod_fd_set(void *instance, int fd)
+static int mod_fd_set(fr_listen_t *listen, int fd)
 {
-       proto_vmps_udp_t *inst = talloc_get_type_abort(instance, proto_vmps_udp_t);
+       proto_vmps_udp_t *inst = talloc_get_type_abort(listen->thread_instance, proto_vmps_udp_t);
 
        inst->sockfd = fd;