4f56c2530a6290a53ed2dcf892b711492667769c
[openafs.git] / src / afs / afs_analyze.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /*
11  * Implements:
12  */
13 #include <afsconfig.h>
14 #include "afs/param.h"
15
16
17 #include "afs/stds.h"
18 #include "afs/sysincludes.h"    /* Standard vendor system headers */
19
20 #ifndef UKERNEL
21 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
22 #include <net/if.h>
23 #include <netinet/in.h>
24 #endif
25
26 #ifdef AFS_SGI62_ENV
27 #include "h/hashing.h"
28 #endif
29 #if !defined(AFS_HPUX110_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN60_ENV)
30 #include <netinet/in_var.h>
31 #endif
32 #endif /* !UKERNEL */
33
34 #include "afsincludes.h"        /* Afs-based standard headers */
35 #include "afs/afs_stats.h"      /* afs statistics */
36 #include "afs/afs_util.h"
37 #include "afs/unified_afs.h"
38
39 #if     defined(AFS_SUN56_ENV)
40 #include <inet/led.h>
41 #include <inet/common.h>
42 #if     defined(AFS_SUN58_ENV)
43 #include <netinet/ip6.h>
44 #endif
45 #include <inet/ip.h>
46 #endif
47
48
49 /* shouldn't do it this way, but for now will do */
50 #ifndef ERROR_TABLE_BASE_U
51 #define ERROR_TABLE_BASE_U      (5376L)
52 #endif /* ubik error base define */
53
54 /* shouldn't do it this way, but for now will do */
55 #ifndef ERROR_TABLE_BASE_uae
56 #define ERROR_TABLE_BASE_uae    (49733376L)
57 #endif /* unified afs error base define */
58
59 /* same hack for vlserver error base as for ubik error base */
60 #ifndef ERROR_TABLE_BASE_VL
61 #define ERROR_TABLE_BASE_VL     (363520L)
62 #define VL_NOENT                (363524L)
63 #endif /* vlserver error base define */
64
65
66 int afs_BusyWaitPeriod = 15;    /* poll every 15 seconds */
67
68 afs_int32 hm_retry_RO = 0;      /* don't wait */
69 afs_int32 hm_retry_RW = 0;      /* don't wait */
70 afs_int32 hm_retry_int = 0;     /* don't wait */
71
72 #define VSleep(at)      afs_osi_Wait((at)*1000, 0, 0)
73
74
75 int lastcode;
76 /* returns:
77  * 0   if the vldb record for a specific volume is different from what
78  *     we have cached -- perhaps the volume has moved.
79  * 1   if the vldb record is the same
80  * 2   if we can't tell if it's the same or not. 
81  *
82  * If 0, the caller will probably start over at the beginning of our
83  * list of servers for this volume and try to find one that is up.  If
84  * not 0, we will probably just keep plugging with what we have
85  * cached.   If we fail to contact the VL server, we  should just keep
86  * trying with the information we have, rather than failing. */
87 #define DIFFERENT 0
88 #define SAME 1
89 #define DUNNO 2
90 static int
91 VLDB_Same(struct VenusFid *afid, struct vrequest *areq)
92 {
93     struct vrequest treq;
94     struct afs_conn *tconn;
95     int i, type = 0;
96     union {
97         struct vldbentry tve;
98         struct nvldbentry ntve;
99         struct uvldbentry utve;
100     } *v;
101     struct volume *tvp;
102     struct cell *tcell;
103     char *bp, tbuf[CVBS];       /* biggest volume id is 2^32, ~ 4*10^9 */
104     unsigned int changed;
105     struct server *(oldhosts[NMAXNSERVERS]);
106
107     AFS_STATCNT(CheckVLDB);
108     afs_FinalizeReq(areq);
109
110     if ((i = afs_InitReq(&treq, afs_osi_credp)))
111         return DUNNO;
112     v = afs_osi_Alloc(sizeof(*v));
113     tcell = afs_GetCell(afid->Cell, READ_LOCK);
114     bp = afs_cv2string(&tbuf[CVBS], afid->Fid.Volume);
115     do {
116         VSleep(2);              /* Better safe than sorry. */
117         tconn =
118             afs_ConnByMHosts(tcell->cellHosts, tcell->vlport, tcell->cellNum,
119                              &treq, SHARED_LOCK);
120         if (tconn) {
121             if (tconn->srvr->server->flags & SNO_LHOSTS) {
122                 type = 0;
123                 RX_AFS_GUNLOCK();
124                 i = VL_GetEntryByNameO(tconn->id, bp, &v->tve);
125                 RX_AFS_GLOCK();
126             } else if (tconn->srvr->server->flags & SYES_LHOSTS) {
127                 type = 1;
128                 RX_AFS_GUNLOCK();
129                 i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve);
130                 RX_AFS_GLOCK();
131             } else {
132                 type = 2;
133                 RX_AFS_GUNLOCK();
134                 i = VL_GetEntryByNameU(tconn->id, bp, &v->utve);
135                 RX_AFS_GLOCK();
136                 if (!(tconn->srvr->server->flags & SVLSRV_UUID)) {
137                     if (i == RXGEN_OPCODE) {
138                         type = 1;
139                         RX_AFS_GUNLOCK();
140                         i = VL_GetEntryByNameN(tconn->id, bp, &v->ntve);
141                         RX_AFS_GLOCK();
142                         if (i == RXGEN_OPCODE) {
143                             type = 0;
144                             tconn->srvr->server->flags |= SNO_LHOSTS;
145                             RX_AFS_GUNLOCK();
146                             i = VL_GetEntryByNameO(tconn->id, bp, &v->tve);
147                             RX_AFS_GLOCK();
148                         } else if (!i)
149                             tconn->srvr->server->flags |= SYES_LHOSTS;
150                     } else if (!i)
151                         tconn->srvr->server->flags |= SVLSRV_UUID;
152                 }
153                 lastcode = i;
154             }
155         } else
156             i = -1;
157     } while (afs_Analyze(tconn, i, NULL, &treq, -1,     /* no op code for this */
158                          SHARED_LOCK, tcell));
159
160     afs_PutCell(tcell, READ_LOCK);
161     afs_Trace2(afs_iclSetp, CM_TRACE_CHECKVLDB, ICL_TYPE_FID, &afid,
162                ICL_TYPE_INT32, i);
163
164     if (i) {
165         afs_osi_Free(v, sizeof(*v));
166         return DUNNO;
167     }
168     /* have info, copy into serverHost array */
169     changed = 0;
170     tvp = afs_FindVolume(afid, WRITE_LOCK);
171     if (tvp) {
172         ObtainWriteLock(&tvp->lock, 107);
173         for (i = 0; i < NMAXNSERVERS && tvp->serverHost[i]; i++) {
174             oldhosts[i] = tvp->serverHost[i];
175         }
176
177         if (type == 2) {
178             InstallUVolumeEntry(tvp, &v->utve, afid->Cell, tcell, &treq);
179         } else if (type == 1) {
180             InstallNVolumeEntry(tvp, &v->ntve, afid->Cell);
181         } else {
182             InstallVolumeEntry(tvp, &v->tve, afid->Cell);
183         }
184
185         if (i < NMAXNSERVERS && tvp->serverHost[i]) {
186             changed = 1;
187         }
188         for (--i; !changed && i >= 0; i--) {
189             if (tvp->serverHost[i] != oldhosts[i]) {
190                 changed = 1;    /* also happens if prefs change.  big deal. */
191             }
192         }
193
194         ReleaseWriteLock(&tvp->lock);
195         afs_PutVolume(tvp, WRITE_LOCK);
196     } else {                    /* can't find volume */
197         tvp = afs_GetVolume(afid, &treq, WRITE_LOCK);
198         if (tvp) {
199             afs_PutVolume(tvp, WRITE_LOCK);
200             afs_osi_Free(v, sizeof(*v));
201             return DIFFERENT;
202         } else {
203             afs_osi_Free(v, sizeof(*v));
204             return DUNNO;
205         }
206     }
207
208     afs_osi_Free(v, sizeof(*v));
209     return (changed ? DIFFERENT : SAME);
210 }                               /*VLDB_Same */
211
212 /*------------------------------------------------------------------------
213  * afs_BlackListOnce
214  *
215  * Description:
216  *      Mark a server as invalid for further attempts of this request only.
217  *
218  * Arguments:
219  *      areq  : The request record associated with this operation.
220  *      afid  : The FID of the file involved in the action.  This argument
221  *              may be null if none was involved.
222  *      tsp   : pointer to a server struct for the server we wish to 
223  *              blacklist. 
224  *
225  * Returns:
226  *      Non-zero value if further servers are available to try,
227  *      zero otherwise.
228  *
229  * Environment:
230  *      This routine is typically called in situations where we believe
231  *      one server out of a pool may have an error condition.
232  *
233  * Side Effects:
234  *      As advertised.
235  *
236  * NOTE:
237  *      The afs_Conn* routines use the list of invalidated servers to 
238  *      avoid reusing a server marked as invalid for this request.
239  *------------------------------------------------------------------------*/
240 static afs_int32 
241 afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid, 
242                   struct server *tsp)
243 {
244     struct volume *tvp;
245     afs_int32 i;
246     afs_int32 serversleft = 0;
247
248     if (afid) {
249         tvp = afs_FindVolume(afid, READ_LOCK);
250         if (tvp) {
251             for (i = 0; i < MAXHOSTS; i++) {
252                 if (tvp->serverHost[i] == tsp) {
253                     areq->skipserver[i] = 1;
254                 }
255                 if (tvp->serverHost[i] &&
256                     (tvp->serverHost[i]->addr->sa_flags & 
257                       SRVR_ISDOWN)) {
258                     areq->skipserver[i] = 1;
259                 }
260             }
261             afs_PutVolume(tvp, READ_LOCK);
262             for (i = 0; i < MAXHOSTS; i++) {
263                 if (tvp->serverHost[i] && areq->skipserver[i] == 0) {
264                     serversleft = 1;
265                     break;
266                 }
267             }
268             return serversleft;
269         }
270     }
271     return 1;
272 }
273
274
275 /*------------------------------------------------------------------------
276  * EXPORTED afs_Analyze
277  *
278  * Description:
279  *      Analyze the outcome of an RPC operation, taking whatever support
280  *      actions are necessary.
281  *
282  * Arguments:
283  *      aconn : Ptr to the relevant connection on which the call was made.
284  *      acode : The return code experienced by the RPC.
285  *      afid  : The FID of the file involved in the action.  This argument
286  *              may be null if none was involved.
287  *      areq  : The request record associated with this operation.
288  *      op    : which RPC we are analyzing.
289  *      cellp : pointer to a cell struct.  Must provide either fid or cell.
290  *
291  * Returns:
292  *      Non-zero value if the related RPC operation should be retried,
293  *      zero otherwise.
294  *
295  * Environment:
296  *      This routine is typically called in a do-while loop, causing the
297  *      embedded RPC operation to be called repeatedly if appropriate
298  *      until whatever error condition (if any) is intolerable.
299  *
300  * Side Effects:
301  *      As advertised.
302  *
303  * NOTE:
304  *      The retry return value is used by afs_StoreAllSegments to determine
305  *      if this is a temporary or permanent error.
306  *------------------------------------------------------------------------*/
307 int
308 afs_Analyze(register struct afs_conn *aconn, afs_int32 acode,
309             struct VenusFid *afid, register struct vrequest *areq, int op,
310             afs_int32 locktype, struct cell *cellp)
311 {
312     afs_int32 i;
313     struct srvAddr *sa;
314     struct server *tsp;
315     struct volume *tvp;
316     afs_int32 shouldRetry = 0;
317     afs_int32 serversleft = 1;
318     struct afs_stats_RPCErrors *aerrP;
319     afs_int32 markeddown;
320
321  
322  
323     if (AFS_IS_DISCONNECTED && !AFS_IN_SYNC) {
324         /* On reconnection, act as connected. XXX: for now.... */
325         /* SXW - This may get very tired after a while. We should try and
326          *       intercept all RPCs before they get here ... */
327         /*printf("afs_Analyze: disconnected\n");*/
328         afs_FinalizeReq(areq);
329         if (aconn) {
330             /* SXW - I suspect that this will _never_ happen - we shouldn't
331              *       get a connection because we're disconnected !!!*/
332             afs_PutConn(aconn, locktype);
333         }
334         return 0;
335     }
336     
337     AFS_STATCNT(afs_Analyze);
338     afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,
339                ICL_TYPE_POINTER, aconn, ICL_TYPE_INT32, acode, ICL_TYPE_LONG,
340                areq->uid);
341
342     aerrP = (struct afs_stats_RPCErrors *)0;
343
344     if ((op >= 0) && (op < AFS_STATS_NUM_FS_RPC_OPS))
345         aerrP = &(afs_stats_cmfullperf.rpc.fsRPCErrors[op]);
346
347     afs_FinalizeReq(areq);
348     if (!aconn && areq->busyCount) {    /* one RPC or more got VBUSY/VRESTARTING */
349
350         tvp = afs_FindVolume(afid, READ_LOCK);
351         if (tvp) {
352             afs_warnuser("afs: Waiting for busy volume %u (%s) in cell %s\n",
353                          (afid ? afid->Fid.Volume : 0),
354                          (tvp->name ? tvp->name : ""),
355                          ((tvp->serverHost[0]
356                            && tvp->serverHost[0]->cell) ? tvp->serverHost[0]->
357                           cell->cellName : ""));
358
359             for (i = 0; i < MAXHOSTS; i++) {
360                 if (tvp->status[i] != not_busy && tvp->status[i] != offline) {
361                     tvp->status[i] = not_busy;
362                 }
363                 if (tvp->status[i] == not_busy)
364                     shouldRetry = 1;
365             }
366             afs_PutVolume(tvp, READ_LOCK);
367         } else {
368             afs_warnuser("afs: Waiting for busy volume %u\n",
369                          (afid ? afid->Fid.Volume : 0));
370         }
371
372         if (areq->busyCount > 100) {
373             if (aerrP)
374                 (aerrP->err_Volume)++;
375             areq->volumeError = VOLBUSY;
376             shouldRetry = 0;
377         } else {
378             VSleep(afs_BusyWaitPeriod); /* poll periodically */
379         }
380         if (shouldRetry != 0)
381             areq->busyCount++;
382
383         return shouldRetry;     /* should retry */
384     }
385
386     if (!aconn || !aconn->srvr) {
387         if (!areq->volumeError) {
388             if (aerrP)
389                 (aerrP->err_Network)++;
390             if (hm_retry_int && !(areq->flags & O_NONBLOCK) &&  /* "hard" mount */
391                 ((afid && afs_IsPrimaryCellNum(afid->Cell))
392                  || (cellp && afs_IsPrimaryCell(cellp)))) {
393                 if (!afid) {
394                     afs_warnuser
395                         ("afs: hard-mount waiting for a vlserver to return to service\n");
396                     VSleep(hm_retry_int);
397                     afs_CheckServers(1, cellp);
398                     shouldRetry = 1;
399                 } else {
400                     tvp = afs_FindVolume(afid, READ_LOCK);
401                     if (!tvp || (tvp->states & VRO)) {
402                         shouldRetry = hm_retry_RO;
403                     } else {
404                         shouldRetry = hm_retry_RW;
405                     }
406                     if (tvp)
407                         afs_PutVolume(tvp, READ_LOCK);
408                     if (shouldRetry) {
409                         afs_warnuser
410                             ("afs: hard-mount waiting for volume %u\n",
411                              afid->Fid.Volume);
412                         VSleep(hm_retry_int);
413                         afs_CheckServers(1, cellp);
414                     }
415                 }
416             } /* if (hm_retry_int ... */
417             else {
418                 areq->networkError = 1;
419             }
420         }
421         return shouldRetry;
422     }
423
424     /* Find server associated with this connection. */
425     sa = aconn->srvr;
426     tsp = sa->server;
427
428     /* Before we do anything with acode, make sure we translate it back to
429      * a system error */
430     if ((acode & ~0xff) == ERROR_TABLE_BASE_uae)
431         acode = et_to_sys_error(acode);
432
433     if (acode == 0) {
434         /* If we previously took an error, mark this volume not busy */
435         if (areq->volumeError) {
436             tvp = afs_FindVolume(afid, READ_LOCK);
437             if (tvp) {
438                 for (i = 0; i < MAXHOSTS; i++) {
439                     if (tvp->serverHost[i] == tsp) {
440                         tvp->status[i] = not_busy;
441                     }
442                 }
443                 afs_PutVolume(tvp, READ_LOCK);
444             }
445         }
446
447         afs_PutConn(aconn, locktype);
448         return 0;
449     }
450
451     /* If network troubles, mark server as having bogued out again. */
452     /* VRESTARTING is < 0 because of backward compatibility issues 
453      * with 3.4 file servers and older cache managers */
454 #ifdef AFS_64BIT_CLIENT
455     if (acode == -455)
456         acode = 455;
457 #endif /* AFS_64BIT_CLIENT */
458     if ((acode < 0) && (acode != VRESTARTING)) {
459         if (acode == RX_CALL_TIMEOUT) {
460             serversleft = afs_BlackListOnce(areq, afid, tsp);
461             areq->idleError++;
462             if (serversleft) {
463                 shouldRetry = 1;
464             } else {
465                 shouldRetry = 0;
466             }
467             /* By doing this, we avoid ever marking a server down
468              * in an idle timeout case. That's because the server is 
469              * still responding and may only be letting a single vnode
470              * time out. We otherwise risk having the server continually
471              * be marked down, then up, then down again... 
472              */
473             goto out;
474         } 
475         markeddown = afs_ServerDown(sa);
476         ForceNewConnections(sa); /**multi homed clients lock:afs_xsrvAddr? */
477         if (aerrP)
478             (aerrP->err_Server)++;
479 #if 0
480         /* retry *once* when the server is timed out in case of NAT */
481         if (markeddown && acode == RX_CALL_DEAD) {
482             aconn->forceConnectFS = 1;
483             shouldRetry = 1;
484         }
485 #endif
486     }
487
488     if (acode == VBUSY || acode == VRESTARTING) {
489         if (acode == VBUSY) {
490             areq->busyCount++;
491             if (aerrP)
492                 (aerrP->err_VolumeBusies)++;
493         } else
494             areq->busyCount = 1;
495
496         tvp = afs_FindVolume(afid, READ_LOCK);
497         if (tvp) {
498             for (i = 0; i < MAXHOSTS; i++) {
499                 if (tvp->serverHost[i] == tsp) {
500                     tvp->status[i] = rdwr_busy; /* can't tell which yet */
501                     /* to tell which, have to look at the op code. */
502                 }
503             }
504             afs_PutVolume(tvp, READ_LOCK);
505         } else {
506             afs_warnuser("afs: Waiting for busy volume %u in cell %s\n",
507                          (afid ? afid->Fid.Volume : 0), tsp->cell->cellName);
508             VSleep(afs_BusyWaitPeriod); /* poll periodically */
509         }
510         shouldRetry = 1;
511         acode = 0;
512     } else if (acode == VICETOKENDEAD
513                || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) {
514         /* any rxkad error is treated as token expiration */
515         struct unixuser *tu;
516         /*
517          * I'm calling these errors protection errors, since they involve
518          * faulty authentication.
519          */
520         if (aerrP)
521             (aerrP->err_Protection)++;
522
523         tu = afs_FindUser(areq->uid, tsp->cell->cellNum, READ_LOCK);
524         if (tu) {
525             if (acode == VICETOKENDEAD) {
526                 aconn->forceConnectFS = 1;
527             } else if (acode == RXKADEXPIRED) {
528                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
529                 aconn->user->states |= UTokensBad;
530                 afs_warnuser
531                     ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
532                      tu->vid, aconn->srvr->server->cell->cellName);
533             } else {
534                 serversleft = afs_BlackListOnce(areq, afid, tsp);
535                 areq->tokenError++;
536
537                 if (serversleft) {
538                     afs_warnuser
539                         ("afs: Tokens for user of AFS id %d for cell %s: rxkad error=%d\n",
540                          tu->vid, aconn->srvr->server->cell->cellName, acode);
541                     shouldRetry = 1;
542                 } else {
543                     areq->tokenError = 0;
544                     aconn->forceConnectFS = 0;  /* don't check until new tokens set */
545                     aconn->user->states |= UTokensBad;
546                     afs_warnuser
547                         ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
548                          tu->vid, aconn->srvr->server->cell->cellName, acode);
549                 }
550             }
551             afs_PutUser(tu, READ_LOCK);
552         } else {
553             /* The else case shouldn't be possible and should probably be replaced by a panic? */
554             if (acode == VICETOKENDEAD) {
555                 aconn->forceConnectFS = 1;
556             } else if (acode == RXKADEXPIRED) {
557                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
558                 aconn->user->states |= UTokensBad;
559                 afs_warnuser
560                     ("afs: Tokens for user %d for cell %s have expired\n",
561                      areq->uid, aconn->srvr->server->cell->cellName);
562             } else {
563                 aconn->forceConnectFS = 0;      /* don't check until new tokens set */
564                 aconn->user->states |= UTokensBad;
565                 afs_warnuser
566                     ("afs: Tokens for user %d for cell %s are discarded (rxkad error = %d)\n",
567                      areq->uid, aconn->srvr->server->cell->cellName, acode);
568             }
569         }
570         shouldRetry = 1;        /* Try again (as root). */
571     }
572     /* Check for access violation. */
573     else if (acode == EACCES) {
574         /* should mark access error in non-existent per-user global structure */
575         if (aerrP)
576             (aerrP->err_Protection)++;
577         areq->accessError = 1;
578         if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
579             areq->permWriteError = 1;
580         shouldRetry = 0;
581     }
582     /* check for ubik errors; treat them like crashed servers */
583     else if (acode >= ERROR_TABLE_BASE_U && acode < ERROR_TABLE_BASE_U + 255) {
584         afs_ServerDown(sa);
585         if (aerrP)
586             (aerrP->err_Server)++;
587         shouldRetry = 1;        /* retryable (maybe one is working) */
588         VSleep(1);              /* just in case */
589     }
590     /* Check for bad volume data base / missing volume. */
591     else if (acode == VSALVAGE || acode == VOFFLINE || acode == VNOVOL
592              || acode == VNOSERVICE || acode == VMOVED) {
593         struct cell *tcell;
594         int same;
595
596         shouldRetry = 1;
597         areq->volumeError = VOLMISSING;
598         if (aerrP)
599             (aerrP->err_Volume)++;
600         if (afid && (tcell = afs_GetCell(afid->Cell, 0))) {
601             same = VLDB_Same(afid, areq);
602             tvp = afs_FindVolume(afid, READ_LOCK);
603             if (tvp) {
604                 for (i = 0; i < MAXHOSTS && tvp->serverHost[i]; i++) {
605                     if (tvp->serverHost[i] == tsp) {
606                         if (tvp->status[i] == end_not_busy)
607                             tvp->status[i] = offline;
608                         else
609                             tvp->status[i]++;
610                     } else if (!same) {
611                         tvp->status[i] = not_busy;      /* reset the others */
612                     }
613                 }
614                 afs_PutVolume(tvp, READ_LOCK);
615             }
616         }
617     } else if (acode >= ERROR_TABLE_BASE_VL && acode <= ERROR_TABLE_BASE_VL + 255) {    /* vlserver errors */
618         shouldRetry = 0;
619         areq->volumeError = VOLMISSING;
620     } else if (acode >= 0) {
621         if (aerrP)
622             (aerrP->err_Other)++;
623         if (op == AFS_STATS_FS_RPCIDX_STOREDATA)
624             areq->permWriteError = 1;
625         shouldRetry = 0;        /* Other random Vice error. */
626     } else if (acode == RX_MSGSIZE) {   /* same meaning as EMSGSIZE... */
627         VSleep(1);              /* Just a hack for desperate times. */
628         if (aerrP)
629             (aerrP->err_Other)++;
630         shouldRetry = 1;        /* packet was too big, please retry call */
631     }
632
633     if (acode < 0 && acode != RX_MSGSIZE && acode != VRESTARTING) {
634         /* If we get here, code < 0 and we have network/Server troubles.
635          * areq->networkError is not set here, since we always
636          * retry in case there is another server.  However, if we find
637          * no connection (aconn == 0) we set the networkError flag.
638          */
639         afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
640         if (aerrP)
641             (aerrP->err_Server)++;
642         VSleep(1);              /* Just a hack for desperate times. */
643         shouldRetry = 1;
644     }
645 out:
646     /* now unlock the connection and return */
647     afs_PutConn(aconn, locktype);
648     return (shouldRetry);
649 }                               /*afs_Analyze */