apps/ocsp.c etc.: rename 'multi' to 'n_responders' for clarity
authorDr. David von Oheimb <David.von.Oheimb@siemens.com>
Sat, 28 May 2022 16:50:18 +0000 (18:50 +0200)
committerDr. David von Oheimb <dev@ddvo.net>
Wed, 7 Sep 2022 21:04:25 +0000 (23:04 +0200)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: David von Oheimb <david.von.oheimb@siemens.com>
(Merged from https://github.com/openssl/openssl/pull/18434)

apps/include/http_server.h
apps/lib/http_server.c
apps/ocsp.c

index df4eba9238a7be0568a8360732ad40b4a6779b94..e80e29d8c5f5ca347a5efd3fb6f894e7a7d147aa 100644 (file)
@@ -125,7 +125,7 @@ int http_server_send_status(const char *prog, BIO *cbio,
 # endif
 
 # ifdef HTTP_DAEMON
-extern int multi;
+extern int n_responders;
 extern int acfd;
 
 void socket_timeout(int signum);
index ba72a6c14a826d087463ffaf5e620db1e89af591..4b18e8fea47184992c9d1c21f0dbd93d450e5e3a 100644 (file)
@@ -41,7 +41,7 @@ static int verbosity = LOG_INFO;
 
 #ifdef HTTP_DAEMON
 
-int multi = 0; /* run multiple responder processes, set by ocsp.c */
+int n_responders = 0; /* run multiple responder processes, set by ocsp.c */
 int acfd = (int) INVALID_SOCKET;
 
 static int print_syslog(const char *str, size_t len, void *levPtr)
@@ -91,7 +91,7 @@ void trace_log_message(int category,
         return;
     }
 #ifdef HTTP_DAEMON
-    if (multi != 0) {
+    if (n_responders != 0) {
         vsyslog(level, fmt, ap);
         if (level <= LOG_ERR)
             ERR_print_errors_cb(print_syslog, &level);
@@ -119,7 +119,7 @@ static void killall(int ret, pid_t *kidpids)
 {
     int i;
 
-    for (i = 0; i < multi; ++i)
+    for (i = 0; i < n_responders; ++i)
         if (kidpids[i] != 0)
             (void)kill(kidpids[i], SIGTERM);
     OPENSSL_free(kidpids);
@@ -153,8 +153,8 @@ void spawn_loop(const char *prog)
                strerror(errno));
         exit(1);
     }
-    kidpids = app_malloc(multi * sizeof(*kidpids), "child PID array");
-    for (i = 0; i < multi; ++i)
+    kidpids = app_malloc(n_responders * sizeof(*kidpids), "child PID array");
+    for (i = 0; i < n_responders; ++i)
         kidpids[i] = 0;
 
     signal(SIGINT, noteterm);
@@ -167,7 +167,7 @@ void spawn_loop(const char *prog)
          * Wait for a child to replace when we're at the limit.
          * Slow down if a child exited abnormally or waitpid() < 0
          */
-        while (termsig == 0 && procs >= multi) {
+        while (termsig == 0 && procs >= n_responders) {
             if ((fpid = waitpid(-1, &status, 0)) > 0) {
                 for (i = 0; i < procs; ++i) {
                     if (kidpids[i] == fpid) {
@@ -176,7 +176,7 @@ void spawn_loop(const char *prog)
                         break;
                     }
                 }
-                if (i >= multi) {
+                if (i >= n_responders) {
                     syslog(LOG_ERR, "fatal: internal error: "
                            "no matching child slot for pid: %ld",
                            (long)fpid);
@@ -221,14 +221,14 @@ void spawn_loop(const char *prog)
             }
             return;
         default:            /* parent */
-            for (i = 0; i < multi; ++i) {
+            for (i = 0; i < n_responders; ++i) {
                 if (kidpids[i] == 0) {
                     kidpids[i] = fpid;
                     procs++;
                     break;
                 }
             }
-            if (i >= multi) {
+            if (i >= n_responders) {
                 syslog(LOG_ERR, "fatal: internal error: no free child slots");
                 killall(1, kidpids);
             }
index 297b10c861dce1662c323c081376724b65108dde..380c6b325f332c0329f650bee91111e19261ed47 100644 (file)
@@ -529,7 +529,7 @@ int ocsp_main(int argc, char **argv)
             break;
         case OPT_MULTI:
 #ifdef HTTP_DAEMON
-            multi = atoi(opt_arg());
+            n_responders = atoi(opt_arg());
 #endif
             break;
         case OPT_PROV_CASES:
@@ -633,7 +633,7 @@ int ocsp_main(int argc, char **argv)
     }
 
 #ifdef HTTP_DAEMON
-    if (multi != 0 && acbio != NULL)
+    if (n_responders != 0 && acbio != NULL)
         spawn_loop(prog);
     if (acbio != NULL && req_timeout > 0)
         signal(SIGALRM, socket_timeout);