viced-dotted-quad-logging-without-malloc-20010601
authorNathan Neulinger <nneul@umr.edu>
Mon, 4 Jun 2001 22:08:19 +0000 (22:08 +0000)
committerDerrick Brashear <shadow@dementia.org>
Mon, 4 Jun 2001 22:08:19 +0000 (22:08 +0000)
based on suggestion from rees@umich.edu

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

update for solaris cc joy

src/util/afsutil.h
src/util/hostparse.c
src/viced/host.c
src/viced/viced.c

index 35fb5c4..2363ecf 100644 (file)
@@ -58,7 +58,7 @@ extern char *vctime(const time_t *atime);
 
 /* Convert a 4 byte integer to a text string. */
 extern char*   afs_inet_ntoa(afs_uint32 addr);
-extern char*    afs_inet_ntoa_r(afs_uint32 addr);
+extern char*    afs_inet_ntoa_r(afs_uint32 addr, char *buf);
 
 /* copy strings, converting case along the way. */
 extern char *lcstring(char *d, char *s, int n);
index a49f9b1..b9b8e2f 100644 (file)
@@ -232,15 +232,11 @@ char* afs_inet_ntoa(afs_uint32 addr)
 }
 
 /* same as above, but to a non-static buffer, must be freed by called */
-char* afs_inet_ntoa_r(afs_uint32 addr)
+char* afs_inet_ntoa_r(afs_uint32 addr, char *buf)
 {
-    char *buf;
     int temp;
 
     temp = ntohl(addr);
-    buf = (char *) malloc(16); /* length of xxx.xxx.xxx.xxx\0 */
-    buf[15] = 0;
-
     sprintf(buf, "%d.%d.%d.%d", 
            (temp >> 24 ) & 0xff,
            (temp >> 16 ) & 0xff, 
index bba7bbc..2d2233b 100644 (file)
@@ -986,11 +986,11 @@ retry:
                    goto retry;
                }
        } else {
-               char *hoststr = afs_inet_ntoa_r(host->host);
-               ViceLog(0,("CB: WhoAreYou failed for %s:%d, error %d\n", 
-                       hoststr, ntohs(host->port), code));
-               host->hostFlags |= VENUSDOWN;
-               free(hoststr);
+           char hoststr[16];
+           afs_inet_ntoa_r(host->host, hoststr);
+           ViceLog(0,("CB: WhoAreYou failed for %s:%d, error %d\n", 
+                      hoststr, ntohs(host->port), code));
+           host->hostFlags |= VENUSDOWN;
        }
        host->hostFlags |= ALTADDR;
        h_Unlock_r(host);
@@ -1087,11 +1087,11 @@ retry:
                }
           }
           if (code) {
-               char *hoststr = afs_inet_ntoa_r(host->host);
-               ViceLog(0,("CB: RCallBackConnectBack failed for %s:%d\n", 
-                       hoststr, ntohs(host->port)));
-               host->hostFlags |= VENUSDOWN;
-               free(hoststr);
+               char hoststr[16];
+               afs_inet_ntoa_r(host->host, hoststr);
+               ViceLog(0,("CB: RCallBackConnectBack failed for %s:%d\n", 
+                         hoststr, ntohs(host->port)));
+              host->hostFlags |= VENUSDOWN;
            }
            else
                host->hostFlags |= RESETDONE;
@@ -1909,13 +1909,13 @@ int CheckHost(host, held)
                    host->hostFlags |= ALTADDR; /* alternate addresses valid */
                    if ( code )
                    {
-                       char *hoststr = afs_inet_ntoa_r(host->host);
-                       ViceLog(0,
-                           ("CB: RCallBackConnectBack (host.c) failed for host %s:%d\n",
-                           hoststr, ntohs(host->port)));
-                       host->hostFlags |= VENUSDOWN;
-                       free(hoststr);
-                    }
+                       char hoststr[16];
+                       afs_inet_ntoa_r(host->host, hoststr);
+                        ViceLog(0,
+                               ("CB: RCallBackConnectBack (host.c) failed for host %s:%d\n",
+                                hoststr, ntohs(host->port)));
+                        host->hostFlags |= VENUSDOWN;
+                   }
                    /* Note:  it's safe to delete hosts even if they have call
                     * back state, because break delayed callbacks (called when a
                     * message is received from the workstation) will always send a 
@@ -1933,12 +1933,12 @@ int CheckHost(host, held)
                        H_LOCK
                        if(code) {
                            if ( MultiProbeAlternateAddress_r(host) ) {
-                               char *hoststr = afs_inet_ntoa_r(host->host);
-                               ViceLog(0,
+                               char hoststr[16];
+                               afs_inet_ntoa_r(host->host, hoststr);
+                                ViceLog(0,
                                        ("ProbeUuid failed for host %s:%d\n",
                                         hoststr, ntohs(host->port)));
-                               host->hostFlags |= VENUSDOWN;
-                               free(hoststr);
+                                host->hostFlags |= VENUSDOWN;
                            }
                        }
                    } else {
@@ -1946,11 +1946,11 @@ int CheckHost(host, held)
                        code = RXAFSCB_Probe(host->callback_rxcon);
                        H_LOCK
                        if (code) {
-                           char *hoststr = afs_inet_ntoa_r(host->host);
-                           ViceLog(0, ("ProbeUuid failed for host %s:%d\n",
-                                   hoststr, ntohs(host->port)));
-                           host->hostFlags |= VENUSDOWN;
-                           free(hoststr);
+                           char hoststr[16];
+                           afs_inet_ntoa_r(host->host, hoststr);
+                           ViceLog(0, ("ProbeUuid failed for host %s:%d\n",
+                                       hoststr, ntohs(host->port)));
+                           host->hostFlags |= VENUSDOWN;
                        }
                    }
                }
index 221f516..b24d1a8 100644 (file)
@@ -599,13 +599,12 @@ main(argc, argv)
        ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
     }
     else {
-      char *hoststr;
-      bcopy(he->h_addr, &FS_HostAddr_NBO, 4);
-      hoststr = afs_inet_ntoa_r(FS_HostAddr_NBO);
-      FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
-      ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
-                FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
-      free(hoststr);
+       char hoststr[16];
+       bcopy(he->h_addr, &FS_HostAddr_NBO, 4);
+       afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
+       FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
+       ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
+                  FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
     }
 
     /* Install handler to catch the shutdown signal */