From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684600703; x=1687192703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=f7EOe5N/gx5HHvV/INoAqOpk3wv0KfkFpT305HUo3DY=; b=MHNdmYKASElNjgao7djRSLybytiXGLxebHRI3c6DpJXkH9e1DtoavAstAYTnXGldrW jwm5w07ylrT4X+WTZKifNJf1X6A/Cv+YA6QpYHG73ZejE+W/9MVmz9YZOoV2krryhyOP mc20QOLEbSWszQc1tJYmBtdv0SC3ikLofxy9yrgpOW1whFXwm2Nh3Jdoq0rE4Bx/J1jv atqWA3txdlCIa5zXrnXaKRVzPhgiCduPPnXZGgQMd7rytZnNGaZxz2A/yCWH2cJe8YdL EBxnqYhoRs8UyIaBGjJo2lMu55tJh5s+rDnZ2shsYcpxx0AWr1h8sDBPC/PFn6/Cz+3I terQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684600703; x=1687192703; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f7EOe5N/gx5HHvV/INoAqOpk3wv0KfkFpT305HUo3DY=; b=LWbtPYa1U2pb8FGIxUiDlUMNZyB+orHhca+1t9Nhsn3zGKQDh4w1VRt8Sfm+Rvd0bd cWE7ZXHbRlqberWChzfTjyTHjkp8dft4wjlluEPS6iw3JTzEOrvev4UHSqBkKaoxjWJ1 f6Nh3TUtCAoUwB6WhCJwA7Y5niHrzFQLU7kKKwN+obn3tkAur29s4Il+CKCeD3/t4CZu M1HONBbVkND8bayAcRpgG2ShOPKQ7JoPpnl2NyEq6wu5AWP4QFPGuLQTRbkcPlmKrnNC 8EaPfTN3voX36LBToY/ciic8KNMLqD3r1enm//m4TnMsg24hWhsws3UI8V9ir7+2Jpxa iIzQ== X-Gm-Message-State: AC+VfDwz6mjozUnwAbpOdtQlYR68+ktDhUxkhG9PhzwtLQlsn+Sy8lOo vxVk9ucNc41aPBwMeENI5vlRVXZ0cwg= X-Google-Smtp-Source: ACHHUZ7x4aDD0FMUSlJIE6n1AU7n6T9VwtkGDDA8BFfj/J9Dc/nX9b7zt/FU+5u5YYXT+dkVr24bog== X-Received: by 2002:a1c:f30a:0:b0:3f4:f012:5cae with SMTP id q10-20020a1cf30a000000b003f4f0125caemr4302893wmq.20.1684600702685; Sat, 20 May 2023 09:38:22 -0700 (PDT) From: Alexey Gladkov To: make-initrd@lists.altlinux.org Date: Sat, 20 May 2023 18:37:46 +0200 Message-Id: <20230520163748.177260-1-gladkov.alexey@gmail.com> X-Mailer: git-send-email 2.33.8 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [make-initrd] [PATCH 1/3] ueventd: Simplify call of the queue handler X-BeenThere: make-initrd@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: make-initrd@lists.altlinux.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 May 2023 16:38:31 -0000 Archived-At: List-Archive: There is no need to iterate over fd_list[] on every event. Instead of a descriptor, we can use a pointer to the structure itself. Signed-off-by: Alexey Gladkov --- datasrc/ueventd/ueventd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/datasrc/ueventd/ueventd.c b/datasrc/ueventd/ueventd.c index 67bc3dda..9c20594f 100644 --- a/datasrc/ueventd/ueventd.c +++ b/datasrc/ueventd/ueventd.c @@ -401,7 +401,7 @@ int setup_epoll_fd(struct fd_handler list[FD_MAX]) rd_fatal("epoll_create1: %m"); for (int i = 0; i < FD_MAX; i++) { - ev.data.fd = list[i].fd; + ev.data.ptr = &list[i]; if (epoll_ctl(epollfd, EPOLL_CTL_ADD, list[i].fd, &ev) < 0) rd_fatal("epoll_ctl: %m"); @@ -531,12 +531,11 @@ int main(int argc, char **argv) for (i = 0; i < fdcount; i++) { if (!(ev[i].events & EPOLLIN)) continue; - for (int k = 0; k < FD_MAX; k++) { - if (ev[i].data.fd != fd_list[k].fd) - continue; - if (fd_list[k].fd_handler(fd_list[k].fd) != 0) - goto done; - } + + struct fd_handler *fde = ev[i].data.ptr; + + if (fde->fd_handler(fde->fd) != 0) + goto done; } for (e = watch_list; e; e = e->next) { -- 2.33.8