vlserver: use the logging function to log
authorMichael Meffie <mmeffie@sinenomine.net>
Sat, 28 Jul 2012 17:17:55 +0000 (13:17 -0400)
committerDerrick Brashear <shadow@dementix.org>
Tue, 14 Aug 2012 20:29:11 +0000 (13:29 -0700)
Use the logging function to log instead of printf.

Change-Id: I377474881830152c93122bd3112e355ab5fd56ad
Reviewed-on: http://gerrit.openafs.org/7895
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/vlserver/vlserver.c
src/vlserver/vlutils.c

index cbe4d5f..5b1c370 100644 (file)
@@ -121,7 +121,7 @@ vldb_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
 
     code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
     if (code) {
-       ViceLog(0,
+       VLog(0,
                ("Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n",
                 code, name, inst, cell));
     }
@@ -341,9 +341,9 @@ main(int argc, char **argv)
 
     tdir = afsconf_Open(configDir);
     if (!tdir) {
-       printf
+       VLog(0,
            ("vlserver: can't open configuration files in dir %s, giving up.\n",
-            configDir);
+            configDir));
        exit(1);
     }
 
@@ -354,7 +354,7 @@ main(int argc, char **argv)
     /* initialize winsock */
     if (afs_winsockInit() < 0) {
        ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
-       fprintf(stderr, "vlserver: couldn't initialize winsock. \n");
+       VLog(0, ("vlserver: couldn't initialize winsock. \n"));
        exit(1);
     }
 #endif
@@ -362,8 +362,8 @@ main(int argc, char **argv)
     gethostname(hostname, sizeof(hostname));
     th = gethostbyname(hostname);
     if (!th) {
-       printf("vlserver: couldn't get address of this host (%s).\n",
-              hostname);
+       VLog(0, ("vlserver: couldn't get address of this host (%s).\n",
+              hostname));
        exit(1);
     }
     memcpy(&myHost, th->h_addr, sizeof(afs_uint32));
@@ -413,7 +413,7 @@ main(int argc, char **argv)
     }
     if (rxMaxMTU != -1) {
        if (rx_SetMaxMTU(rxMaxMTU) != 0) {
-           printf("rxMaxMTU %d invalid\n", rxMaxMTU);
+           VLog(0, ("rxMaxMTU %d invalid\n", rxMaxMTU));
            return -1;
        }
     }
@@ -428,7 +428,7 @@ main(int argc, char **argv)
        ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
                              vl_dbaseName, &VL_dbase);
     if (code) {
-       printf("vlserver: Ubik init failed: %s\n", afs_error_message(code));
+       VLog(0, ("vlserver: Ubik init failed: %s\n", afs_error_message(code)));
        exit(2);
     }
     rx_SetRxDeadTime(50);
@@ -444,7 +444,7 @@ main(int argc, char **argv)
                          securityClasses, numClasses,
                          VL_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
-       printf("vlserver: Could not create VLDB_SERVICE rx service\n");
+       VLog(0, ("vlserver: Could not create VLDB_SERVICE rx service\n"));
        exit(3);
     }
     rx_SetMinProcs(tservice, 2);
@@ -462,14 +462,14 @@ main(int argc, char **argv)
                          securityClasses, numClasses,
                          RXSTATS_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
-       printf("vlserver: Could not create rpc stats rx service\n");
+       VLog(0, ("vlserver: Could not create rpc stats rx service\n"));
        exit(3);
     }
     rx_SetMinProcs(tservice, 2);
     rx_SetMaxProcs(tservice, 4);
 
     LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
-    printf("%s\n", cml_version_number);        /* Goes to the log */
+    VLog(0, ("%s\n", cml_version_number));
 
     /* allow super users to manage RX statistics */
     rx_SetRxStatUserOk(vldb_rxstat_userok);
index 44b1fe0..06ad04b 100644 (file)
@@ -325,7 +325,7 @@ UpdateCache(struct ubik_trans *trans, void *rock)
     /* now, if can't read, or header is wrong, write a new header */
     if (ubcode || vldbversion == 0) {
        if (builddb) {
-           printf("Can't read VLDB header, re-initialising...\n");
+           VLog(0, ("Can't read VLDB header, re-initialising...\n"));
 
            /* try to write a good header */
            /* The read cache will be sync'ed to this new header
@@ -342,21 +342,22 @@ UpdateCache(struct ubik_trans *trans, void *rock)
            }
            code = vlwrite(trans, 0, (char *)&wr_cheader, sizeof(wr_cheader));
            if (code) {
-               printf("Can't write VLDB header (error = %d)\n", code);
+               VLog(0, ("Can't write VLDB header (error = %d)\n", code));
                ERROR_EXIT(VL_IO);
            }
            vldbversion = ntohl(wr_cheader.vital_header.vldbversion);
        } else {
+           VLog(1, ("Unable to read VLDB header.\n"));
            ERROR_EXIT(VL_EMPTY);
        }
     }
 
     if ((vldbversion != VLDBVERSION) && (vldbversion != OVLDBVERSION)
         && (vldbversion != VLDBVERSION_4)) {
-       printf
+       VLog(0,
            ("VLDB version %d doesn't match this software version(%d, %d or %d), quitting!\n",
-            vldbversion, VLDBVERSION_4, VLDBVERSION, OVLDBVERSION);
-       return VL_BADVERSION;
+            vldbversion, VLDBVERSION_4, VLDBVERSION, OVLDBVERSION));
+       ERROR_EXIT(VL_BADVERSION);
     }
 
     maxnservers = ((vldbversion == 3 || vldbversion == 4) ? 13 : 8);