* [PATCH gwproxy v2] epoll: Improve log readability and efficiency
@ 2025-08-17 5:05 Ahmad Gani
2025-08-17 5:12 ` Ammar Faizi
2025-08-17 5:13 ` Ammar Faizi
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Gani @ 2025-08-17 5:05 UTC (permalink / raw)
To: Ammar Faizi; +Cc: Ahmad Gani, Alviro Iskandar Setiawan, GNU/Weeb Mailing List
I noticed from the info log that the connection is reported as closed
twice, even though I only tested with a single curl. After investigating,
I realized it's not an error, just a misleading log message.
This change fixes the confusing log and also improves efficiency:
by moving the accept4 syscall to the top of __handle_ev_accept, we can
eliminate an unnecessary allocation.
Signed-off-by: Ahmad Gani <reyuki@gnuweeb.org>
---
src/gwproxy/ev/epoll.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/src/gwproxy/ev/epoll.c b/src/gwproxy/ev/epoll.c
index 5cf7910888d7..89508204f7d2 100644
--- a/src/gwproxy/ev/epoll.c
+++ b/src/gwproxy/ev/epoll.c
@@ -325,24 +325,23 @@ static int __handle_ev_accept(struct gwp_wrk *w)
static const int flags = SOCK_NONBLOCK | SOCK_CLOEXEC;
struct gwp_ctx *ctx = w->ctx;
struct gwp_conn_pair *gcp;
- struct sockaddr *addr;
+ struct gwp_sockaddr addr;
socklen_t addr_len;
int fd, r;
+ addr_len = sizeof(addr);
+ fd = __sys_accept4(w->tcp_fd, &addr.sa, &addr_len, flags);
+ if (fd < 0)
+ return handle_accept_error(w, fd);
+
gcp = gwp_alloc_conn_pair(w);
if (unlikely(!gcp)) {
pr_err(&ctx->lh, "Failed to allocate connection pair on accept");
+ __sys_close(fd);
return handle_accept_error(w, -ENOMEM);
}
- addr = &gcp->client_addr.sa;
- addr_len = sizeof(gcp->client_addr);
- fd = __sys_accept4(w->tcp_fd, addr, &addr_len, flags);
- if (fd < 0) {
- r = handle_accept_error(w, fd);
- goto out_err;
- }
-
+ gcp->client_addr = addr;
gwp_setup_cli_sock_options(w, fd);
gcp->client.fd = fd;
pr_dbg(&ctx->lh, "New connection from %s (fd=%d)",
--
Ahmad Gani
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH gwproxy v2] epoll: Improve log readability and efficiency
2025-08-17 5:05 [PATCH gwproxy v2] epoll: Improve log readability and efficiency Ahmad Gani
@ 2025-08-17 5:12 ` Ammar Faizi
2025-08-17 5:13 ` Ammar Faizi
1 sibling, 0 replies; 3+ messages in thread
From: Ammar Faizi @ 2025-08-17 5:12 UTC (permalink / raw)
To: Ahmad Gani; +Cc: Alviro Iskandar Setiawan, GNU/Weeb Mailing List
On Sun, Aug 17, 2025 at 12:05:23PM +0700, Ahmad Gani wrote:
> I noticed from the info log that the connection is reported as closed
> twice, even though I only tested with a single curl. After investigating,
> I realized it's not an error, just a misleading log message.
>
> This change fixes the confusing log and also improves efficiency:
> by moving the accept4 syscall to the top of __handle_ev_accept, we can
> eliminate an unnecessary allocation.
>
> Signed-off-by: Ahmad Gani <reyuki@gnuweeb.org>
> ---
> src/gwproxy/ev/epoll.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
When sending a revision without a cover letter, add a changelog after
'---' mark explaining why the revision is needed.
Allow the readers to know the reason quickly without digging through
mailing list history.
Something like this:
https://lore.kernel.org/lkml/20250806003105.15172-1-ammarfaizi2@gnuweeb.org/T/
--
Ammar Faizi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH gwproxy v2] epoll: Improve log readability and efficiency
2025-08-17 5:05 [PATCH gwproxy v2] epoll: Improve log readability and efficiency Ahmad Gani
2025-08-17 5:12 ` Ammar Faizi
@ 2025-08-17 5:13 ` Ammar Faizi
1 sibling, 0 replies; 3+ messages in thread
From: Ammar Faizi @ 2025-08-17 5:13 UTC (permalink / raw)
To: Ahmad Gani; +Cc: Ammar Faizi, Alviro Iskandar Setiawan, GNU/Weeb Mailing List
On Sun, 17 Aug 2025 12:05:23 +0700, Ahmad Gani wrote:
> I noticed from the info log that the connection is reported as closed
> twice, even though I only tested with a single curl. After investigating,
> I realized it's not an error, just a misleading log message.
>
> This change fixes the confusing log and also improves efficiency:
> by moving the accept4 syscall to the top of __handle_ev_accept, we can
> eliminate an unnecessary allocation.
>
> [...]
Applied, thanks!
[1/1] epoll: Improve log readability and efficiency
commit: d29a94483527f623a25df8ffa95f1c7c9958932c
Best regards,
--
Ammar Faizi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-17 5:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-17 5:05 [PATCH gwproxy v2] epoll: Improve log readability and efficiency Ahmad Gani
2025-08-17 5:12 ` Ammar Faizi
2025-08-17 5:13 ` Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox