[Openvpn-devel,v1] multi_io_init: simplify
Commit Message
From: Frank Lichtenheld <frank@lichtenheld.com>
We take two values and try to massage them in various
ways. But this function only has one caller and that
puts exactly the same value into both of them. So
simplify the code.
Change-Id: I9cb8aa6ef01445cb99758583aba8ae8f9ded0862
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1209
---
This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1209
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <gert@greenie.muc.de>
Comments
A particular way to do extra-complicated nothing really... I have stared
at the code for a bit, the flow of "t->options.max_clients" into
"m->max_clients" (assigned exactly once), etc. - and also compared the
logging before/after.
old: MULTI IO: MULTI_IO INIT maxclients=1024 maxevents=1029
new: MULTI IO: MULTI_IO INIT maxclients=1024 maxevents=1029
same numbers ;-)
Your patch has been applied to the master branch.
commit 945db23ef49c3e8c36c6bef8857058544caa77f6
Author: Frank Lichtenheld
Date: Tue Sep 23 18:04:53 2025 +0200
multi_io_init: simplify
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1209
Message-Id: <20250923160459.32273-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg33176.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
@@ -411,7 +411,7 @@
/*
* Initialize multi-socket I/O wait object
*/
- m->multi_io = multi_io_init(t->options.max_clients, &m->max_clients);
+ m->multi_io = multi_io_init(m->max_clients);
m->tcp_queue_limit = t->options.tcp_queue_limit;
/*
@@ -113,21 +113,18 @@
}
struct multi_io *
-multi_io_init(int maxevents, int *maxclients)
+multi_io_init(const int maxclients)
{
struct multi_io *multi_io;
- const int extra_events = BASE_N_EVENTS;
- ASSERT(maxevents >= 1);
- ASSERT(maxclients);
+ ASSERT(maxclients >= 1);
ALLOC_OBJ_CLEAR(multi_io, struct multi_io);
- multi_io->maxevents = maxevents + extra_events;
+ multi_io->maxevents = maxclients + BASE_N_EVENTS;
multi_io->es = event_set_init(&multi_io->maxevents, 0);
wait_signal(multi_io->es, MULTI_IO_SIG);
ALLOC_ARRAY(multi_io->esr, struct event_set_return, multi_io->maxevents);
- *maxclients = max_int(min_int(multi_io->maxevents - extra_events, *maxclients), 1);
- msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", *maxclients,
+ msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", maxclients,
multi_io->maxevents);
return multi_io;
}
@@ -61,7 +61,7 @@
#endif
};
-struct multi_io *multi_io_init(int maxevents, int *maxclients);
+struct multi_io *multi_io_init(int maxclients);
void multi_io_free(struct multi_io *multi_io);