Browse code

multi_io_init: simplify

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
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>

Frank Lichtenheld authored on 2025/09/24 01:04:53
Showing 3 changed files
... ...
@@ -411,7 +411,7 @@ multi_init(struct context *t)
411 411
     /*
412 412
      * Initialize multi-socket I/O wait object
413 413
      */
414
-    m->multi_io = multi_io_init(t->options.max_clients, &m->max_clients);
414
+    m->multi_io = multi_io_init(m->max_clients);
415 415
     m->tcp_queue_limit = t->options.tcp_queue_limit;
416 416
 
417 417
     /*
... ...
@@ -113,21 +113,18 @@ multi_get_context(struct multi_context *m, struct multi_instance *mi)
113 113
 }
114 114
 
115 115
 struct multi_io *
116
-multi_io_init(int maxevents, int *maxclients)
116
+multi_io_init(const int maxclients)
117 117
 {
118 118
     struct multi_io *multi_io;
119
-    const int extra_events = BASE_N_EVENTS;
120 119
 
121
-    ASSERT(maxevents >= 1);
122
-    ASSERT(maxclients);
120
+    ASSERT(maxclients >= 1);
123 121
 
124 122
     ALLOC_OBJ_CLEAR(multi_io, struct multi_io);
125
-    multi_io->maxevents = maxevents + extra_events;
123
+    multi_io->maxevents = maxclients + BASE_N_EVENTS;
126 124
     multi_io->es = event_set_init(&multi_io->maxevents, 0);
127 125
     wait_signal(multi_io->es, MULTI_IO_SIG);
128 126
     ALLOC_ARRAY(multi_io->esr, struct event_set_return, multi_io->maxevents);
129
-    *maxclients = max_int(min_int(multi_io->maxevents - extra_events, *maxclients), 1);
130
-    msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", *maxclients,
127
+    msg(D_MULTI_LOW, "MULTI IO: MULTI_IO INIT maxclients=%d maxevents=%d", maxclients,
131 128
         multi_io->maxevents);
132 129
     return multi_io;
133 130
 }
... ...
@@ -61,7 +61,7 @@ struct multi_io
61 61
 #endif
62 62
 };
63 63
 
64
-struct multi_io *multi_io_init(int maxevents, int *maxclients);
64
+struct multi_io *multi_io_init(int maxclients);
65 65
 
66 66
 void multi_io_free(struct multi_io *multi_io);
67 67