Call rx_InitHost once during daemon startup 71/13271/4
authorAndrew Deason <adeason@sinenomine.net>
Tue, 7 Aug 2018 16:17:43 +0000 (11:17 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 24 Sep 2018 02:09:15 +0000 (22:09 -0400)
Currently, a few daemons calls rx_InitHost in different places, and
under different conditions. For example, vlserver calls rx_InitHost
only when we -rxbind to a specific ip address, and then also makes an
additional rx_Init call. Other daemons always call rx_InitHost, or
just call rx_InitHost sometimes and don't make an extra rx_Init call.

To try to make the various daemons behave a little more consistently,
change the startup code to always call rx_InitHost, and to only call
it once. Note that rx_InitHost is the same as calling rx_Init with
INADDR_ANY as the ip address, and calling rx_Init* after a previous
rx_Init* call is effectively a no-op.

Change-Id: Ifd15175349a7b4695e684ca82deb8a8af5063073
Reviewed-on: https://gerrit.openafs.org/13271
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/bozo/bosserver.c
src/budb/server.c
src/kauth/kaserver.c
src/ptserver/ptserver.c
src/vlserver/vlserver.c

index 547a3af..df38bd4 100644 (file)
@@ -1153,11 +1153,7 @@ main(int argc, char **argv, char **envp)
        host = GetRxBindAddress();
     }
     for (i = 0; i < 10; i++) {
-       if (rxBind) {
-           code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
-       } else {
-           code = rx_Init(htons(AFSCONF_NANNYPORT));
-       }
+       code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
        if (code) {
            bozo_Log("can't initialize rx: code=%d\n", code);
            sleep(3);
index 3a80918..99b8a57 100644 (file)
@@ -531,10 +531,16 @@ main(int argc, char **argv)
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-           rx_InitHost(host, htons(AFSCONF_BUDBPORT));
        }
     }
 
+    code = rx_InitHost(host, htons(AFSCONF_BUDBPORT));
+    if (code) {
+       LogError(code, "rx init failed\n");
+       afs_com_err(whoami, code, "rx init failed");
+       ERROR(code);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
index da824bc..d28c736 100644 (file)
@@ -410,10 +410,15 @@ main(int argc, char *argv[])
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-           rx_InitHost(host, htons(AFSCONF_KAUTHPORT));
        }
     }
 
+    code = rx_InitHost(host, htons(AFSCONF_KAUTHPORT));
+    if (code) {
+       afs_com_err(whoami, code, "rx init failed");
+       exit(2);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
index 2ab437d..63ed325 100644 (file)
@@ -541,14 +541,15 @@ main(int argc, char **argv)
        }
        if (ccode == 1) {
            host = SHostAddrs[0];
-           /* the following call is idempotent so if/when it gets called
-            * again by the ubik init stuff, it doesn't really matter
-            * -- klm
-            */
-           rx_InitHost(host, htons(AFSCONF_PROTPORT));
        }
     }
 
+    code = rx_InitHost(host, htons(AFSCONF_PROTPORT));
+    if (code < 0) {
+       ViceLog(0, ("ptserver: Rx init failed: %d\n", code));
+       PT_EXIT(1);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
index 08ecab9..ac6ef09 100644 (file)
@@ -463,7 +463,6 @@ main(int argc, char **argv)
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-           rx_InitHost(host, htons(AFSCONF_VLDBPORT));
        }
     }
 
@@ -477,7 +476,7 @@ main(int argc, char **argv)
        }
     }
 
-    code = rx_Init(htons(AFSCONF_VLDBPORT));
+    code = rx_InitHost(host, htons(AFSCONF_VLDBPORT));
     if (code < 0) {
         VLog(0, ("vlserver: Rx init failed: %d\n", code));
         exit(1);