DEVEL15-windows-cache-validation-20090610
authorJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 19 Jun 2009 04:13:14 +0000 (04:13 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Fri, 19 Jun 2009 04:13:14 +0000 (04:13 +0000)
LICENSE MIT

correct cell validation to avoid false detection of infinite loops
if a cm_cell_t object had to be freed.

add newlines to output of volumeHashTableSize and cellHashTableSize

(cherry picked from commit ae1923e36260ff59efb85dda99b5345341bff6d8)

src/WINNT/afsd/cm_cell.c
src/WINNT/afsd/cm_memmap.c

index 68ed022..7c3f74c 100644 (file)
@@ -457,32 +457,32 @@ long
 cm_ValidateCell(void)
 {
     cm_cell_t * cellp;
-    afs_uint32 count;
+    afs_uint32 count1, count2;
 
-    for (cellp = cm_data.allCellsp, count = 0; cellp; cellp=cellp->allNextp, count++) {
+    for (cellp = cm_data.allCellsp, count1 = 0; cellp; cellp=cellp->allNextp, count1++) {
         if ( cellp->magic != CM_CELL_MAGIC ) {
             afsi_log("cm_ValidateCell failure: cellp->magic != CM_CELL_MAGIC");
             fprintf(stderr, "cm_ValidateCell failure: cellp->magic != CM_CELL_MAGIC\n");
             return -1;
         }
-        if ( count != 0 && cellp == cm_data.allCellsp ||
-             count > cm_data.maxCells ) {
+        if ( count1 != 0 && cellp == cm_data.allCellsp ||
+             count1 > cm_data.maxCells ) {
             afsi_log("cm_ValidateCell failure: cm_data.allCellsp infinite loop");
             fprintf(stderr, "cm_ValidateCell failure: cm_data.allCellsp infinite loop\n");
             return -2;
         }
     }
 
-    for (cellp = cm_data.freeCellsp; cellp; cellp=cellp->freeNextp, count++) {
-        if ( count != 0 && cellp == cm_data.freeCellsp ||
-             count > cm_data.maxCells ) {
+    for (cellp = cm_data.freeCellsp, count2 = 0; cellp; cellp=cellp->freeNextp, count2++) {
+        if ( count2 != 0 && cellp == cm_data.freeCellsp ||
+             count2 > cm_data.maxCells ) {
             afsi_log("cm_ValidateCell failure: cm_data.freeCellsp infinite loop");
             fprintf(stderr, "cm_ValidateCell failure: cm_data.freeCellsp infinite loop\n");
             return -3;
         }
     }
 
-    if ( count != cm_data.currentCells ) {
+    if ( (count1 + count2) != cm_data.currentCells ) {
         afsi_log("cm_ValidateCell failure: count != cm_data.currentCells");
         fprintf(stderr, "cm_ValidateCell failure: count != cm_data.currentCells\n");
         return -4;
index c0473b3..bf9767c 100644 (file)
@@ -424,10 +424,10 @@ cm_ValidateMappedMemory(char * cachePath)
     fprintf(stderr,"  blockSize      = %u\n", config_data_p->blockSize);
     fprintf(stderr,"  bufferSize     = %I64u\n", config_data_p->bufferSize);
     fprintf(stderr,"  cacheType      = %u\n", config_data_p->cacheType);
-    fprintf(stderr,"  volumeHashTableSize = %u", config_data_p->volumeHashTableSize);
+    fprintf(stderr,"  volumeHashTableSize = %u\n", config_data_p->volumeHashTableSize);
     fprintf(stderr,"  currentVolumes = %u\n", config_data_p->currentVolumes);
     fprintf(stderr,"  maxVolumes     = %u\n", config_data_p->maxVolumes);
-    fprintf(stderr,"  cellHashTableSize = %u", config_data_p->cellHashTableSize);
+    fprintf(stderr,"  cellHashTableSize = %u\n", config_data_p->cellHashTableSize);
     fprintf(stderr,"  currentCells   = %u\n", config_data_p->currentCells);
     fprintf(stderr,"  maxCells       = %u\n", config_data_p->maxCells);
     fprintf(stderr,"  scacheHashTableSize  = %u\n", config_data_p->scacheHashTableSize);