]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Automated refactoring for additional callback types in fr_event_fd_insert
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 8 Nov 2016 17:03:59 +0000 (12:03 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 8 Nov 2016 17:03:59 +0000 (12:03 -0500)
src/include/event.h
src/lib/event.c
src/main/interpreter.c
src/main/process.c
src/main/radsniff.c
src/main/threads.c
src/modules/proto_bfd/proto_bfd.c
src/modules/rlm_radius_client/rlm_radius_client.c
src/modules/rlm_unbound/rlm_unbound.c

index 1c2d2db5e9bc5cd031f9670cfa90376a1d95eb23..3140c0029b2943ce103c72c22462ce7f443a354a 100644 (file)
@@ -51,7 +51,8 @@ int fr_event_run(fr_event_list_t *el, struct timeval *when);
 
 int fr_event_now(fr_event_list_t *el, struct timeval *when);
 
-int fr_event_fd_insert(fr_event_list_t *el, int fd, fr_event_fd_handler_t handler, void *ctx);
+int fr_event_fd_insert(fr_event_list_t *el, int fd, fr_event_fd_handler_t handler, fr_event_fd_handler_t write,
+                      fr_event_fd_handler_t error, void *ctx);
 
 int fr_event_fd_delete(fr_event_list_t *el, int fd);
 
index 23954c4cbac0be29012ed2b0e4544f14f5e2e738..12de052107ce70d248935147f3892ce8b74d681f 100644 (file)
@@ -317,10 +317,14 @@ int fr_event_now(fr_event_list_t *el, struct timeval *when)
  *
  * @param[in] el       to insert FD callback into.
  * @param[in] fd       to read from.
- * @param[in] read     to call when fd is readable.
+ * @param[in] read     function to call when fd is readable.
+ * @param[in] write    function to call when fd is writable.
+ * @param[in] error    function to call when an error occurs on the fd.
  * @param[in] ctx      to pass to handler.
  */
-int fr_event_fd_insert(fr_event_list_t *el, int fd, fr_event_fd_handler_t read, void *ctx)
+int fr_event_fd_insert(fr_event_list_t *el, int fd,
+                      fr_event_fd_handler_t read, UNUSED fr_event_fd_handler_t write, UNUSED fr_event_fd_handler_t error,
+                      void *ctx)
 {
        int i;
        fr_event_fd_t *ef;
index a0c11b19cc19389b8f2dc3ad0c46047b2f30a2a6..0f2da5d17c9977e3b8c6aabf811be464b4cade66 100644 (file)
@@ -1395,7 +1395,7 @@ int unlang_event_fd_readable_add(REQUEST *request, fr_unlang_fd_callback_t callb
        ev->inst = module_instance;
        ev->ctx = ctx;
 
-       if (fr_event_fd_insert(request->el, fd, unlang_event_fd_handler, ev) < 0) {
+       if (fr_event_fd_insert(request->el, fd, unlang_event_fd_handler, NULL, NULL, ev) < 0) {
                talloc_free(ev);
                return -1;
        }
index 7caa23edabc6fa9af4357a76325b6e896e577644..04481563ecee5e71a02d024fc7380f8bfc89cca0 100644 (file)
@@ -4886,7 +4886,7 @@ static int event_new_fd(rad_listen_t *this)
                /*
                 *      All sockets: add the FD to the event handler.
                 */
-               if (fr_event_fd_insert(el, this->fd, event_socket_handler, this) < 0) {
+               if (fr_event_fd_insert(el, this->fd, event_socket_handler, NULL, NULL, this) < 0) {
                        ERROR("Failed adding event handler for socket: %s", fr_strerror());
                        fr_exit(1);
                }
@@ -5391,7 +5391,7 @@ int radius_event_start(bool have_children)
        }
        DEBUG4("Created signal pipe.  Read end FD %i, write end FD %i", self_pipe[0], self_pipe[1]);
 
-       if (fr_event_fd_insert(el, self_pipe[0], event_signal_handler, el) < 0) {
+       if (fr_event_fd_insert(el, self_pipe[0], event_signal_handler, NULL, NULL, el) < 0) {
                ERROR("Failed creating signal pipe handler: %s", fr_strerror());
                return -1;
        }
index f7680023ee61360f857de9ced1af0da14b8750ac..0ccf9cc39b7de90b6fb3f868c838c26f7b0e23b0 100644 (file)
@@ -2800,7 +2800,7 @@ int main(int argc, char *argv[])
                        exit(EXIT_FAILURE);
                }
 
-               if (fr_event_fd_insert(events, self_pipe[0], rs_signal_action, events) < 0) {
+               if (fr_event_fd_insert(events, self_pipe[0], rs_signal_action, NULL, NULL, events) < 0) {
                        ERROR("Failed inserting signal pipe descriptor: %s", fr_strerror());
                        goto finish;
                }
@@ -2819,7 +2819,7 @@ int main(int argc, char *argv[])
                        event->out = out;
                        event->stats = stats;
 
-                       if (fr_event_fd_insert(events, in_p->fd, rs_got_packet, event) < 0) {
+                       if (fr_event_fd_insert(events, in_p->fd, rs_got_packet, NULL, NULL, event) < 0) {
                                ERROR("Failed inserting file descriptor");
                                goto finish;
                        }
index 8f3f89b3ab3916ff5049049d926ec0d4627f3201..8296a879b3867565b2f4bcb91122ef133564f2e4 100644 (file)
@@ -461,7 +461,7 @@ static void *thread_handler(void *arg)
        local_backlog = fr_heap_create(timestamp_cmp, offsetof(REQUEST, heap_id));
        rad_assert(local_backlog != NULL);
 
-       if (fr_event_fd_insert(el, thread->pipe_fd[0], thread_fd_handler, thread) < 0) {
+       if (fr_event_fd_insert(el, thread->pipe_fd[0], thread_fd_handler, NULL, NULL, thread) < 0) {
                ERROR("Failed inserting event for self");
                goto done;
        }
index dc99a525269e0cc465de0157ee9b50d2c567420e..5e870668cdf9b3731033d8cc03302b03300ef5cc 100644 (file)
@@ -332,7 +332,7 @@ static int bfd_pthread_create(bfd_state_t *session)
        fcntl(session->pipefd[1], F_SETFL, O_NONBLOCK | FD_CLOEXEC);
 #endif
 
-       if (fr_event_fd_insert(session->el, session->pipefd[0], bfd_pipe_recv, session) < 0) {
+       if (fr_event_fd_insert(session->el, session->pipefd[0], bfd_pipe_recv, NULL, NULL, session) < 0) {
                ERROR("Failed inserting file descriptor into event list: %s", fr_strerror());
                goto close_pipes;
        }
index 9c3ca3df7f0dcece5ad12971eb1bfd341896fb3f..6c1cb2f88a4e1421662cf88efebc3950d1f94a8a 100644 (file)
@@ -367,7 +367,7 @@ static int mod_fd_add(fr_event_list_t *el, rlm_radius_client_conn_t *conn, rlm_r
                return -1;
        }
 
-       if (fr_event_fd_insert(el, sockfd, mod_event_fd, conn) < 0) {
+       if (fr_event_fd_insert(el, sockfd, mod_event_fd, NULL, NULL, conn) < 0) {
                DEBUG("Failed adding event for socket: %s", fr_strerror());
                close(sockfd);
                return -1;
index 580045d3ef69c701121aa62e088fed05fa1c714a..c121593fad2e903ed596cc750fe9c2093d3bdee3 100644 (file)
@@ -625,7 +625,7 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance)
 
        inst->log_fd = ub_fd(inst->ub);
        if (inst->log_fd >= 0) {
-               if (fr_event_fd_insert(inst->el, inst->log_fd, ub_fd_handler, inst) < 0) {
+               if (fr_event_fd_insert(inst->el, inst->log_fd, ub_fd_handler, NULL, NULL, inst) < 0) {
                        cf_log_err_cs(conf, "could not insert async fd");
                        inst->log_fd = -1;
                        goto error_nores;