properly mark servers down for rx errors except OPCODE
[openafs.git] / src / afs / afs_server.c
index 0017049..49dc24e 100644 (file)
@@ -313,7 +313,7 @@ CheckVLServer(struct srvAddr *sa, struct vrequest *areq)
      * with old vlsevers), then we treat this server as running again
      */
     if (code == 0 || (code <= -450 && code >= -470)) {
-       if (tc->srvr == sa) {
+       if (tc->parent->srvr == sa) {
            afs_MarkServerUpOrDown(sa, 0);
            print_internet_address("afs: volume location server ", sa,
                                   " is back up", 2);
@@ -635,7 +635,7 @@ afs_CheckServers(int adown, struct cell *acellp)
            continue;
 
        if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(sa->server)
-           || (tc->srvr->server == afs_setTimeHost)) {
+           || (tc->parent->srvr->server == afs_setTimeHost)) {
            conns[nconns]=tc;
            rxconns[nconns]=tc->id;
            if (sa->sa_flags & SRVADDR_ISDOWN) {
@@ -683,25 +683,24 @@ afs_CheckServers(int adown, struct cell *acellp)
        if ( afs_setTimeHost == NULL ) {
            multi_Rx(rxconns,nconns)
              {
-               tv.tv_sec = tv.tv_usec = 0;
-               multi_RXAFS_GetTime(
-                       (afs_uint32 *)&tv.tv_sec, (afs_uint32 *)&tv.tv_usec);
-               tc = conns[multi_i];
-               sa = tc->srvr;
-               if (conntimer[multi_i] == 1)
-                 rx_SetConnDeadTime(tc->id, afs_rx_deadtime);
-               end = osi_Time();
-               results[multi_i]=multi_error;
-               if ((start == end) && !multi_error)
-                 deltas[multi_i] = end - tv.tv_sec;
-
+                 tv.tv_sec = tv.tv_usec = 0;
+                 multi_RXAFS_GetTime(
+                     (afs_uint32 *)&tv.tv_sec, (afs_uint32 *)&tv.tv_usec);
+                 tc = conns[multi_i];
+                 sa = tc->parent->srvr;
+                 if (conntimer[multi_i] == 1)
+                     rx_SetConnDeadTime(tc->id, afs_rx_deadtime);
+                 end = osi_Time();
+                 results[multi_i]=multi_error;
+                 if ((start == end) && !multi_error)
+                     deltas[multi_i] = end - tv.tv_sec;
              } multi_End;
            }
        else {                  /* find and query setTimeHost only */
            for ( i = 0 ; i < j ; i++ ) {
-               if ( conns[i] == NULL || conns[i]->srvr == NULL )
+               if ( conns[i] == NULL || conns[i]->parent->srvr == NULL )
                    continue;
-               if ( conns[i]->srvr->server == afs_setTimeHost ) {
+               if ( conns[i]->parent->srvr->server == afs_setTimeHost ) {
                    tv.tv_sec = tv.tv_usec = 0;
                    results[i] = RXAFS_GetTime(rxconns[i],
                                (afs_uint32 *)&tv.tv_sec, (afs_uint32 *)&tv.tv_usec);
@@ -716,29 +715,29 @@ afs_CheckServers(int adown, struct cell *acellp)
     }
 
     for(i=0;i<nconns;i++){
-      tc = conns[i];
-      sa = tc->srvr;
+       tc = conns[i];
+       sa = tc->parent->srvr;
 
-      if (( results[i] >= 0 ) && (sa->sa_flags & SRVADDR_ISDOWN) && (tc->srvr == sa)) {
-       /* server back up */
-       print_internet_address("afs: file server ", sa, " is back up", 2);
+       if (( results[i] >= 0 ) && (sa->sa_flags & SRVADDR_ISDOWN) && (tc->parent->srvr == sa)) {
+           /* server back up */
+           print_internet_address("afs: file server ", sa, " is back up", 2);
 
-       ObtainWriteLock(&afs_xserver, 244);
-       ObtainWriteLock(&afs_xsrvAddr, 245);
-       afs_MarkServerUpOrDown(sa, 0);
-       ReleaseWriteLock(&afs_xsrvAddr);
-       ReleaseWriteLock(&afs_xserver);
+           ObtainWriteLock(&afs_xserver, 244);
+           ObtainWriteLock(&afs_xsrvAddr, 245);
+           afs_MarkServerUpOrDown(sa, 0);
+           ReleaseWriteLock(&afs_xsrvAddr);
+           ReleaseWriteLock(&afs_xserver);
 
-       if (afs_waitForeverCount) {
-         afs_osi_Wakeup(&afs_waitForever);
-       }
-      } else {
-       if (results[i] < 0) {
-         /* server crashed */
-         afs_ServerDown(sa);
-         ForceNewConnections(sa);  /* multi homed clients */
+           if (afs_waitForeverCount) {
+               afs_osi_Wakeup(&afs_waitForever);
+           }
+       } else {
+           if ((results[i] < 0) && (results[i] != RXGEN_OPCODE)) {
+               /* server crashed */
+               afs_ServerDown(sa);
+               ForceNewConnections(sa);  /* multi homed clients */
+           }
        }
-      }
     }
 
     /*
@@ -751,9 +750,9 @@ afs_CheckServers(int adown, struct cell *acellp)
        for (i=0; i<nconns; i++) {
            delta = deltas[i];
            tc = conns[i];
-           sa = tc->srvr;
+           sa = tc->parent->srvr;
 
-           if ((tc->srvr->server == afs_setTimeHost ||
+           if ((tc->parent->srvr->server == afs_setTimeHost ||
                 /* Sync only to a server in the local cell */
                 (afs_setTimeHost == (struct server *)0 &&
                  afs_IsPrimaryCell(sa->server->cell)))) {
@@ -761,7 +760,7 @@ afs_CheckServers(int adown, struct cell *acellp)
                char msgbuf[90];  /* strlen("afs: setting clock...") + slop */
                delta = end - tv.tv_sec;   /* how many secs fast we are */
 
-               afs_setTimeHost = tc->srvr->server;
+               afs_setTimeHost = tc->parent->srvr->server;
                /* see if clock has changed enough to make it worthwhile */
                if (delta >= AFS_MINCHANGE || delta <= -AFS_MINCHANGE) {
                    end = osi_Time();
@@ -1199,7 +1198,7 @@ afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr,
     return;
 }
 #else /* AFS_USERSPACE_IP_ADDR */
-#if (! defined(AFS_SUN5_ENV)) && !defined(AFS_DARWIN_ENV) && defined(USEIFADDR)
+#if (! defined(AFS_SUN5_ENV)) && (! defined(AFS_DARWIN_ENV)) && (! defined(AFS_OBSD47_ENV)) && defined(USEIFADDR)
 void
 afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa)
 {
@@ -1236,7 +1235,7 @@ afsi_SetServerIPRank(struct srvAddr *sa, struct in_ifaddr *ifa)
 #endif /* IFF_POINTTOPOINT */
 }
 #endif /*(!defined(AFS_SUN5_ENV)) && defined(USEIFADDR) */
-#if defined(AFS_DARWIN_ENV) && defined(USEIFADDR)
+#if (defined(AFS_DARWIN_ENV) || defined(AFS_OBSD47_ENV)) && defined(USEIFADDR)
 #ifndef afs_min
 #define afs_min(A,B) ((A)<(B)) ? (A) : (B)
 #endif
@@ -1722,6 +1721,11 @@ afs_GetCapabilities(struct server *ts)
     ReleaseWriteLock(&afs_xserver);
     code = RXAFS_GetCapabilities(tc->id, &caps);
     ObtainWriteLock(&afs_xserver, 723);
+    /* we forced a conn above; important we mark it down if needed */
+    if ((code < 0) && (code != RXGEN_OPCODE)) {
+       afs_ServerDown(tc->parent->srvr);
+       ForceNewConnections(tc->parent->srvr); /* multi homed clients */
+    }
     afs_PutConn(tc, SHARED_LOCK);
     if ( code && code != RXGEN_OPCODE ) {
        afs_warn("RXAFS_GetCapabilities failed with code %d\n", code);
@@ -1981,7 +1985,6 @@ afs_RemoveAllConns(void)
     int i;
     struct server *ts, *nts;
     struct srvAddr *sa;
-    struct afs_conn *tc, *ntc;
 
     ObtainReadLock(&afs_xserver);
     ObtainWriteLock(&afs_xconn, 1001);
@@ -1992,15 +1995,7 @@ afs_RemoveAllConns(void)
             nts = ts->next;
             for (sa = ts->addr; sa; sa = sa->next_sa) {
                 if (sa->conns) {
-                    tc = sa->conns;
-                    while (tc) {
-                        ntc = tc->next;
-                        AFS_GUNLOCK();
-                        rx_DestroyConnection(tc->id);
-                        AFS_GLOCK();
-                        afs_osi_Free(tc, sizeof(struct afs_conn));
-                        tc = ntc;
-                    }
+                    afs_ReleaseConns(sa->conns);
                     sa->conns = NULL;
                 }
             }