- Timestamp:
- Sep 6, 2011, 11:02:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110710/psLib/src/sys/psMemory.c
r31660 r32339 515 515 continue; 516 516 } 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 } 531 545 532 546 // the markers are ours! … … 889 903 psMemBlock ***array, 890 904 FILE * fd, 891 bool persistence) 905 bool persistence, 906 int maxDisplayedLeaksCount ///< List at most maxDisplayedLeaksCount (-1 for all) 907 ) 892 908 { 893 909 psS32 nleak = 0; … … 896 912 897 913 // 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 } 899 917 900 918 // make sure that the memblock list is free of corruption before we crawl … … 915 933 for (memBlock = topBlock; memBlock->nextBlock != NULL; memBlock = memBlock->nextBlock) { } 916 934 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; 917 953 // iterate through the block list starting with the oldest block 918 954 for (; memBlock != NULL; memBlock = memBlock->previousBlock) { … … 924 960 925 961 // only print a max of 500 leaks (make this an argument) 926 if ( (nleak < 500) && (fd != NULL)) {962 if ( (nleak <= maxToDisplay) && (fd != NULL) ) { 927 963 if (nleak == 1) { 928 964 fprintf(fd, "# func at (file:line) ID: X Ref: X\n");
Note:
See TracChangeset
for help on using the changeset viewer.
