afs: Remove osi_GetuTime
[openafs.git] / src / afs / afs_server.c
index 79b4704..24ec053 100644 (file)
@@ -129,7 +129,7 @@ afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown)
 {
     struct server *a_serverP = sa->server;
     struct srvAddr *sap;
-    osi_timeval_t currTime, *currTimeP;        /*Current time */
+    osi_timeval32_t currTime, *currTimeP;      /*Current time */
     afs_int32 downTime;                /*Computed downtime, in seconds */
     struct afs_stats_SrvUpDownInfo *upDownP;   /*Ptr to up/down info record */
 
@@ -172,7 +172,7 @@ afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown)
      * updated; we'll need them one way or another.
      */
     currTimeP = &currTime;
-    osi_GetuTime(currTimeP);
+    osi_GetTime(currTimeP);
 
     upDownP = GetUpDownStats(a_serverP);
 
@@ -354,8 +354,8 @@ afs_CountServers(void)
     int currIdx;               /*Curr idx into srv table */
     struct server *currSrvP;   /*Ptr to curr server record */
     afs_int32 currChainLen;    /*Length of curr hash chain */
-    osi_timeval_t currTime;    /*Current time */
-    osi_timeval_t *currTimeP;  /*Ptr to above */
+    osi_timeval32_t currTime;  /*Current time */
+    osi_timeval32_t *currTimeP;        /*Ptr to above */
     afs_int32 srvRecordAge;    /*Age of server record, in secs */
     struct afs_stats_SrvUpDownInfo *upDownP;   /*Ptr to current up/down
                                                 * info being manipulated */
@@ -400,7 +400,7 @@ afs_CountServers(void)
      * Compute the current time, used to figure out server record ages.
      */
     currTimeP = &currTime;
-    osi_GetuTime(currTimeP);
+    osi_GetTime(currTimeP);
 
     /*
      * Sweep the server hash table, tallying all we need to know.
@@ -515,6 +515,8 @@ ForceAllNewConnections(void)
         sa = addrs[i];
        ForceNewConnections(sa);
     }
+
+    afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs));
 }
 
 static void
@@ -821,13 +823,15 @@ afs_random(void)
 
     AFS_STATCNT(afs_random);
     if (!state) {
-       osi_timeval_t t;
+       osi_timeval32_t t;
        osi_GetTime(&t);
        /*
-        * 0xfffffff0 was changed to (~0 << 4) since it works no matter how many
-        * bits are in a tv_usec
+        * Clear the low nybble of tv_usec in a size-independent manner before adding
+        * in the rest of the state.
         */
-       state = (t.tv_usec & (~0 << 4)) + (rxi_getaddr() & 0xff);
+       state = t.tv_usec;
+       state ^= (state & 0x0f);
+       state += rxi_getaddr() & 0xff;
        state += (t.tv_sec & 0xff);
        for (i = 0; i < 30; i++) {
            ranstage(state);
@@ -1353,13 +1357,12 @@ afs_SetServerPrefs(struct srvAddr *const sa)
 #elif defined(AFS_FBSD_ENV)
     {
        struct in_ifaddr *ifa;
-#if defined(AFS_FBSD80_ENV)
-         TAILQ_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
-#else
-         TAILQ_FOREACH(ifa, &in_ifaddrhead, ia_link) {
-#endif
+       CURVNET_SET(rx_socket->so_vnet);
+       TAILQ_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
            afsi_SetServerIPRank(sa, &ifa->ia_ifa);
-    }}
+       }
+       CURVNET_RESTORE();
+    }
 #elif defined(AFS_OBSD_ENV)
     {
        extern struct in_ifaddrhead in_ifaddr;
@@ -1517,7 +1520,9 @@ afs_GetCapabilities(struct server *ts)
     }
     /* InitCallBackStateN, triggered by our RPC, may need this */
     ReleaseWriteLock(&afs_xserver);
+    AFS_GUNLOCK();
     code = RXAFS_GetCapabilities(rxconn, &caps);
+    AFS_GLOCK();
     ObtainWriteLock(&afs_xserver, 723);
     /* we forced a conn above; important we mark it down if needed */
     if ((code < 0) && (code != RXGEN_OPCODE)) {
@@ -1810,8 +1815,8 @@ afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, afs_int32 acell,
 void
 afs_ActivateServer(struct srvAddr *sap)
 {
-    osi_timeval_t currTime;    /*Filled with current time */
-    osi_timeval_t *currTimeP;  /*Ptr to above */
+    osi_timeval32_t currTime;  /*Filled with current time */
+    osi_timeval32_t *currTimeP;        /*Ptr to above */
     struct afs_stats_SrvUpDownInfo *upDownP;   /*Ptr to up/down info record */
     struct server *aserver = sap->server;
 
@@ -1822,7 +1827,7 @@ afs_ActivateServer(struct srvAddr *sap)
         */
        aserver->flags |= AFS_SERVER_FLAG_ACTIVATED;
        currTimeP = &currTime;
-       osi_GetuTime(currTimeP);
+       osi_GetTime(currTimeP);
        aserver->activationTime = currTime.tv_sec;
        upDownP = GetUpDownStats(aserver);
        if (aserver->flags & SRVR_ISDOWN) {