]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Move print_poll_failure()s to fddb_poll()
authorAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 7 Jul 2026 23:01:16 +0000 (17:01 -0600)
committerAlberto Leiva Popper <ydahhrk@gmail.com>
Tue, 7 Jul 2026 23:01:16 +0000 (17:01 -0600)
They need to be closer to the poll(), otherwise they might print
nonsense.

src/rtr/rtr.c

index d0e3b79998c7d628d253e1add182db96879e5f2e..0d28744915f6e5a844fa6985def2a43c51acbe37 100644 (file)
@@ -570,32 +570,27 @@ delete_dead_clients(void)
 static void
 apply_pollfds(struct pollfd *pollfds, size_t nclients)
 {
-       struct pollfd *pfd;
        struct rtr_server *server;
        struct pdu_stream *client;
        size_t i;
 
        for (i = 0; i < servers.len; i++) {
-               pfd = &pollfds[i];
                server = &servers.array[i];
 
                /* PR_DEBUG_MSG("pfd:%d server:%d", pfd->fd, server->fd); */
 
-               if ((pfd->fd == -1) && (server->fd != -1)) {
-                       print_poll_failure(pfd, "Server", server->addr);
+               if ((pollfds[i].fd == -1) && (server->fd != -1)) {
                        close(server->fd);
                        server->fd = -1;
                }
        }
 
        for (i = 0; i < nclients; i++) {
-               pfd = &pollfds[servers.len + i];
                client = clients.array[i];
 
                /* PR_DEBUG_MSG("pfd:%d client:%d", pfd->fd, client->fd); */
 
                if (client->eos && TAILQ_EMPTY(&client->requests)) {
-                       print_poll_failure(pfd, "Client", client->addr);
                        pdustream_destroy(client);
                        clients.array[i] = NULL;
                }
@@ -619,6 +614,7 @@ fddb_poll(void)
 {
        struct pollfd *pollfds; /* array */
        struct pollfd *fd;
+       struct pdu_stream *client;
        size_t nclients;
        size_t i;
        bool wakeup;
@@ -673,6 +669,7 @@ fddb_poll(void)
                        continue;
 
                if (fd->revents & (POLLHUP | POLLERR | POLLNVAL)) {
+                       print_poll_failure(fd, "Server", servers.array[i].addr);
                        fd->fd = -1;
 
                } else if (fd->revents & POLLIN) {
@@ -693,6 +690,7 @@ fddb_poll(void)
        for (i = 0; i < nclients; i++) {
                /* This fd is a client handler socket. */
                fd = &pollfds[servers.len + i];
+               client = clients.array[i];
 
                /* PR_DEBUG_MSG("Client %u: fd:%d revents:%x", i, fd->fd,
                    fd->revents); */
@@ -701,11 +699,12 @@ fddb_poll(void)
                        continue;
 
                if (fd->revents & (POLLHUP | POLLERR | POLLNVAL)) {
-                       disable_read(clients.array[i]);
+                       print_poll_failure(fd, "Client", client->addr);
+                       disable_read(client);
 
                } else if (fd->revents & POLLIN) {
-                       if (!pdustream_parse(clients.array[i], &wakeup))
-                               disable_read(clients.array[i]);
+                       if (!pdustream_parse(client, &wakeup))
+                               disable_read(client);
                }
        }