IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 6, 2011, 11:02:30 AM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110710/psLib/src/sys/psMemory.c

    r31660 r32339  
    515515            continue;
    516516        }
    517         if (memBlock->nextBlock && memBlock->nextBlock->inFlight) {
    518             // nope, we need to try again
    519             MUTEX_UNLOCK(&memBlockListMutex);
    520             usleep (BLOCK_SLEEP);
    521             retryLock ++;
    522             continue;
    523         }
    524         if (memBlock->previousBlock && memBlock->previousBlock->inFlight) {
    525             // nope, we need to try again
    526             MUTEX_UNLOCK(&memBlockListMutex);
    527             usleep (BLOCK_SLEEP);
    528             retryLock ++;
    529             continue;
    530         }
     517        if (memBlock->nextBlock && memBlock->nextBlock->inFlight) {
     518            // we reply on the value of 'inFlight'.  we should crash if this block is corrupted
     519            if (memBlock->nextBlock->startblock != P_PS_MEMMAGIC) {
     520                PS_MEM_ABORT(__func__, "Unsafe to Continue\n");
     521            }
     522            if (memBlock->nextBlock->endblock != P_PS_MEMMAGIC) {
     523                PS_MEM_ABORT(__func__, "Unsafe to Continue\n");
     524            }
     525            // nope, we need to try again
     526            MUTEX_UNLOCK(&memBlockListMutex);
     527            usleep (BLOCK_SLEEP);
     528            retryLock ++;
     529            continue;
     530        }
     531        if (memBlock->previousBlock && memBlock->previousBlock->inFlight) {
     532            // we reply on the value of 'inFlight'.  we should crash if this block is corrupted
     533            if (memBlock->previousBlock->startblock != P_PS_MEMMAGIC) {
     534                PS_MEM_ABORT(__func__, "Unsafe to Continue\n");
     535            }
     536            if (memBlock->previousBlock->endblock != P_PS_MEMMAGIC) {
     537                PS_MEM_ABORT(__func__, "Unsafe to Continue\n");
     538            }
     539            // nope, we need to try again
     540            MUTEX_UNLOCK(&memBlockListMutex);
     541            usleep (BLOCK_SLEEP);
     542            retryLock ++;
     543            continue;
     544        }
    531545
    532546        // the markers are ours!
     
    889903                      psMemBlock ***array,
    890904                      FILE * fd,
    891                       bool persistence)
     905                      bool persistence,
     906                      int maxDisplayedLeaksCount          ///< List at most maxDisplayedLeaksCount (-1 for all)
     907                  )
    892908{
    893909    psS32 nleak = 0;
     
    896912
    897913    // XXX move this elsewhere?
    898     fprintf (stderr, "set %d locks, cleared %d locks, retry on %d locks (memID %ld)\n", setLock, clearLock, retryLock, memid);
     914    if (fd != NULL) {
     915      fprintf (fd, "set %d locks, cleared %d locks, retry on %d locks (memID %ld)\n", setLock, clearLock, retryLock, memid);
     916    }
    899917
    900918    // make sure that the memblock list is free of corruption before we crawl
     
    915933    for (memBlock = topBlock; memBlock->nextBlock != NULL; memBlock = memBlock->nextBlock) { }
    916934
     935    int maxToDisplay = maxDisplayedLeaksCount;
     936    psMemBlock *memBlockBackup = memBlock;
     937    if (maxToDisplay == -1 ) {
     938      for (; memBlock != NULL; memBlock = memBlock->previousBlock) {
     939        if ( (memBlock->refCounter > 0) &&
     940             ( (persistence) || (!persistence && !memBlock->persistent) ) &&
     941             (memBlock->id >= id0)) {
     942          nleak++;
     943        }
     944      }
     945      maxToDisplay=nleak;
     946    }
     947    if (fd != NULL) {
     948      fprintf(fd, "Number of leaks to display: %d\n", maxToDisplay);
     949    }
     950    memBlock = memBlockBackup;
     951
     952    nleak=0;
    917953    // iterate through the block list starting with the oldest block
    918954    for (; memBlock != NULL; memBlock = memBlock->previousBlock) {
     
    924960
    925961            // only print a max of 500 leaks (make this an argument)
    926             if ((nleak < 500) && (fd != NULL)) {
     962            if ( (nleak <= maxToDisplay) && (fd != NULL) ) {
    927963                if (nleak == 1) {
    928964                    fprintf(fd, "# func at (file:line)  ID: X  Ref: X\n");
Note: See TracChangeset for help on using the changeset viewer.