Changeset 1564


Ignore:
Timestamp:
May 30, 2011, 10:05:56 PM (14 years ago)
Author:
Gregg Young
Message:

Rework filldir and grep directories to correctly support more than 65K records.
Collector was trapping. Added SleepIfNeeded to loops to improve WPS responsiveness.

Location:
trunk/dll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/filldir.c

    r1555 r1564  
    9191                entries in the tree container, fix related semaphore performance using
    9292                combination of event and mutex semaphores
     93  30 May 11 GKY Fixed trap caused by passing a nonexistant pci to FillInRecordFromFFB in FillDir
     94                because pci is limited to 65535 files. (nRecord is a USHORT) SHL's single loop
     95  30 May 11 GKY Added SleepIfNeeded to DosFind and container load loops to improve WPS responsiveness
    9396
    9497***********************************************************************/
     
    98101#include <malloc.h>                     // _msize _heapchk
    99102#include <ctype.h>
     103#include <limits.h>
    100104// #include <process.h>                 // _beginthread
    101105
     
    134138#include "fm3dlg.h"                     // INFO_LABEL
    135139#include "pathutil.h"                   // AddBackslashToPath
     140#include "tmrsvcs.h"                    // ITIMER_DESC
    136141
    137142VOID StubbyScanThread(VOID * arg);
     
    944949  ULONG ulBufBytes;
    945950  ULONG x;
     951  ITIMER_DESC itdSleep = { 0 };         // 30 May 11 GKY
    946952
    947953  if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') {
     
    980986                       &ulFindCnt,
    981987                       FIL_QUERYEASIZEL);
    982     priority_normal();
     988    //priority_normal();
    983989    pszFileSpec[strlen(pszFileSpec) - 1] = 0;   // Chop off wildcard
    984990    if (!rc) {
     991      InitITimer(&itdSleep, 500);
    985992      do {
    986993        /*
     
    10881095              cAffbTotal += ulSelCnt;
    10891096              // 15 Sep 09 SHL allow timed updates to see
    1090               if (dcd) {
     1097              /*if (dcd) {
    10911098                dcd->totalfiles += ulSelCnt;
    10921099                dcd->ullTotalBytes += ullTotalBytes;
    1093               }
     1100              } */  //30 May 11 GKY caused counter to increment twice
    10941101            }
    10951102            else {
     
    11061113        ulFindCnt = ulFindMax;
    11071114        rc = xDosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL);
    1108         priority_normal();
     1115        //priority_normal();
    11091116        if (rc)
    1110           DosError(FERR_DISABLEHARDERR);
     1117          DosError(FERR_DISABLEHARDERR);
     1118        SleepIfNeeded(&itdSleep, 1);
    11111119      } while (!rc);
    11121120
     
    11221130          goto Abort;
    11231131
    1124         pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
    1125                               MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(cAffbTotal));
    1126 
    1127         if (!pciFirst) {
    1128           Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
    1129                     GetPString(IDS_CMALLOCRECERRTEXT));
    1130           ok = FALSE;
    1131           ullTotalBytes = 0;
    1132         }
    1133         else {
    1134           // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records
    1135           if (hwndStatus && dcd &&
    1136               dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
    1137             WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_PLEASEWAITCOUNTINGTEXT));
    1138           }
    1139           pci = pciFirst;
    1140           ullTotalBytes = 0;
    1141           pffbFile = paffbTotal;
    1142           for (x = 0; x < cAffbTotal; x++) {
    1143             ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
    1144                                            pffbFile, partial, dcd);
    1145             pci = (PCNRITEM) pci->rc.preccNextRecord;
    1146             ullTotalBytes += ullBytes;
    1147             // 15 Sep 09 SHL allow timed updates to see
    1148             if (dcd) {
    1149               dcd->totalfiles = x;
    1150               dcd->ullTotalBytes = ullTotalBytes;
    1151             }
    1152             // Can not use offset since we have merged lists - this should be equivalent
    1153             pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L));
    1154           }
    1155           if (cAffbTotal) {
     1132        pci = NULL;
     1133        ullTotalBytes = 0;
     1134        pffbFile = paffbTotal;
     1135        for (x = 0; x < cAffbTotal; x++) {
     1136          ULONG ulRecsToInsert;
     1137
     1138          if (pci ==NULL) {
     1139            ulRecsToInsert = cAffbTotal - x <  USHRT_MAX  ? cAffbTotal - x : USHRT_MAX;
     1140            pciFirst = WinSendMsg(hwndCnr, CM_ALLOCRECORD,
     1141                                  MPFROMLONG(EXTRA_RECORD_BYTES), MPFROMLONG(ulRecsToInsert));
     1142
     1143            if (!pciFirst) {
     1144              Win_Error(hwndCnr, HWND_DESKTOP, pszSrcFile, __LINE__,
     1145                        GetPString(IDS_CMALLOCRECERRTEXT));
     1146              ok = FALSE;
     1147              ullTotalBytes = 0;
     1148              break;
     1149            }
     1150            else {
     1151              // 04 Jan 08 SHL fixme like comp.c to handle less than ulSelCnt records
     1152              if (hwndStatus && dcd &&
     1153                  dcd->hwndFrame == WinQueryActiveWindow(dcd->hwndParent)) {
     1154                WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_PLEASEWAITCOUNTINGTEXT));
     1155              }
     1156              pci = pciFirst;
     1157            }
     1158          }
     1159          ullBytes = FillInRecordFromFFB(hwndCnr, pci, pszFileSpec,
     1160                                         pffbFile, partial, dcd);
     1161          pci = (PCNRITEM) pci->rc.preccNextRecord;
     1162          ullTotalBytes += ullBytes;
     1163          // 15 Sep 09 SHL allow timed updates to see
     1164          if (dcd) {
     1165            dcd->totalfiles = x;
     1166            dcd->ullTotalBytes = ullTotalBytes;
     1167          }
     1168          // Can not use offset since we have merged lists - this should be equivalent
     1169          pffbFile = (PFILEFINDBUF4L)((PBYTE)pffbFile + sizeof(FILEFINDBUF4L));
     1170
     1171          if (pci == NULL && ulRecsToInsert) {
    11561172            memset(&ri, 0, sizeof(RECORDINSERT));
    11571173            ri.cb = sizeof(RECORDINSERT);
     
    11591175            ri.pRecordParent = (PRECORDCORE) pciParent;
    11601176            ri.zOrder = (ULONG) CMA_TOP;
    1161             ri.cRecordsInsert = cAffbTotal;
     1177            ri.cRecordsInsert = ulRecsToInsert;
    11621178            ri.fInvalidateRecord = (!fSyncUpdates && dcd &&
    11631179                                    dcd->type == DIR_FRAME) ? FALSE : TRUE;
     
    11731189                ullTotalBytes = 0;
    11741190                if (WinIsWindow((HAB) 0, hwndCnr))
    1175                   FreeCnrItemList(hwndCnr, pciFirst);
     1191                  FreeCnrItemList(hwndCnr, pciFirst);
     1192                pciFirst = NULL;
     1193                break;
    11761194              }
    11771195            }
    1178           }
    1179         }
     1196          }
     1197          SleepIfNeeded(&itdSleep, 1);
     1198        }
    11801199        if (ok) {
    11811200          ullReturnBytes += ullTotalBytes;
     
    19591978  PCNRITEM pciNext;
    19601979  USHORT usCount;
    1961 
     1980  ITIMER_DESC itdSleep = { 0 };         // 30 May 11 GKY
     1981
     1982  InitITimer(&itdSleep, 500);
    19621983  for (usCount = 0; pci; usCount++) {
    19631984    pciNext = (PCNRITEM) pci->rc.preccNextRecord;
    19641985    FreeCnrItemData(pci);
    19651986    pci = pciNext;
     1987    SleepIfNeeded(&itdSleep, 1);
    19661988  }
    19671989
     
    19842006  INT remaining = usCnt;
    19852007  PCNRITEM pci;
     2008  ITIMER_DESC itdSleep = { 0 };         // 30 May 11 GKY
     2009     
    19862010
    19872011  if ((usCnt && !pciFirst) || (!usCnt && pciFirst)) {
     
    20032027        }
    20042028      }
     2029      InitITimer(&itdSleep, 500);
    20052030      while (pci) {
    20062031        // 12 Sep 07 SHL dwg drivebar crash testing - ticket# ???
     
    20122037          Dos_Error(MB_ENTER, apiret, HWND_DESKTOP, pszSrcFile, __LINE__,
    20132038                    "DosQueryMem failed pci %p pciLast %p", pci, pciLast);
    2014         FreeCnrItemData(pci);
     2039        FreeCnrItemData(pci);
    20152040        pciLast = pci;
    20162041        pci = (PCNRITEM)pci->rc.preccNextRecord;
    20172042        if (remaining && --remaining == 0)
    2018           break;
     2043          break;
     2044        SleepIfNeeded(&itdSleep, 1);
    20192045      }
    20202046    }
  • trunk/dll/grep.c

    r1544 r1564  
    3636                Mostly cast CHAR CONSTANT * as CHAR *.
    3737  29 May 10 GKY Suppress ERROR_FILENAME_EXCED_RANGE error because of problem with NTFS
     38  30 May 11 GKY Fixed potential trap caused by passing a nonexistant pci to FillInRecordFromFFB
     39                in DoInsertion because pci is limited to 65535 files. (nRecord is a USHORT)
     40                SHL's single loop fix.
    3841
    3942***********************************************************************/
     
    4346#include <ctype.h>
    4447#include <share.h>
     48#include <limits.h>
    4549
    4650#define INCL_DOS
     
    718722  PCNRITEM pci, pciFirst;
    719723  UINT x;
     724  ULONG ulRecsToInsert;
    720725
    721726  if (!grep || !grep->toinsert || !grep->insertffb || !grep->dir)
    722727    return FALSE;
    723728
    724   pci = WinSendMsg(grep->hwndFiles,
    725                    CM_ALLOCRECORD,
    726                    MPFROMLONG(EXTRA_RECORD_BYTES),
    727                    MPFROMLONG(grep->toinsert));
    728   if (!pci) {
    729     Win_Error(grep->hwndFiles, grep->hwndFiles, pszSrcFile, __LINE__,
    730               PCSZ_CM_ALLOCRECORD);
    731   }
    732   else {
    733     if (grep->sayfiles) {
    734       if (!hwndStatus)
    735         WinSetWindowText(grep->hwndCurFile, (CHAR *) GetPString(IDS_GREPINSERTINGTEXT));
     729  pci = NULL;
     730  dcd = INSTDATA(grep->hwndFiles);
     731  for (x = 0; grep->insertffb[x]; x++) {
     732    if (pci == NULL) {
     733      ulRecsToInsert = grep->toinsert - x < USHRT_MAX  ? grep->toinsert - x : USHRT_MAX;
     734      pciFirst = WinSendMsg(grep->hwndFiles, CM_ALLOCRECORD,
     735                       MPFROMLONG(EXTRA_RECORD_BYTES),
     736                       MPFROMLONG(ulRecsToInsert));
     737      if (!pciFirst) {
     738        Win_Error(grep->hwndFiles, grep->hwndFiles, pszSrcFile, __LINE__,
     739                  PCSZ_CM_ALLOCRECORD);
     740        freegreplist(grep);
     741        return FALSE;
     742      }
    736743      else {
    737         if (WinQueryFocus(HWND_DESKTOP) == grep->hwndFiles)
    738           WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_GREPINSERTINGTEXT));
     744        pci = pciFirst;
     745        if (grep->sayfiles) {
     746          if (!hwndStatus)
     747            WinSetWindowText(grep->hwndCurFile, (CHAR *) GetPString(IDS_GREPINSERTINGTEXT));
     748          else {
     749            if (WinQueryFocus(HWND_DESKTOP) == grep->hwndFiles)
     750              WinSetWindowText(hwndStatus, (CHAR *) GetPString(IDS_GREPINSERTINGTEXT));
     751          }
     752        }
    739753      }
    740754    }
    741     pciFirst = pci;
    742     dcd = INSTDATA(grep->hwndFiles);
    743     for (x = 0; grep->insertffb[x]; x++) {
    744       FillInRecordFromFFB(grep->hwndFiles,
    745                           pci, grep->dir[x], grep->insertffb[x], FALSE, dcd);
    746       pci = (PCNRITEM) pci->rc.preccNextRecord;
    747       SleepIfNeeded(pitdSleep, 1);
    748     } // for
    749     memset(&ri, 0, sizeof(RECORDINSERT));
    750     ri.cb = sizeof(RECORDINSERT);
    751     ri.pRecordOrder = (PRECORDCORE) CMA_END;
    752     ri.pRecordParent = (PRECORDCORE) NULL;
    753     ri.zOrder = (USHORT) CMA_TOP;
    754     ri.cRecordsInsert = grep->toinsert;
    755     ri.fInvalidateRecord = TRUE;
    756     WinSendMsg(grep->hwndFiles,
    757                CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
    758     if (dcd) {
    759       //DosEnterCritSec(); //GKY 11-29-08
    760       DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
    761       dcd->ullTotalBytes += grep->insertedbytes;
    762       DosReleaseMutexSem(hmtxFM2Globals);
    763       //DosExitCritSec();
     755    FillInRecordFromFFB(grep->hwndFiles,
     756                        pci, grep->dir[x], grep->insertffb[x], FALSE, dcd);
     757    pci = (PCNRITEM) pci->rc.preccNextRecord;
     758    //SleepIfNeeded(pitdSleep, 1);
     759    if (pci == NULL && ulRecsToInsert) {
     760      memset(&ri, 0, sizeof(RECORDINSERT));
     761      ri.cb = sizeof(RECORDINSERT);
     762      ri.pRecordOrder = (PRECORDCORE) CMA_END;
     763      ri.pRecordParent = (PRECORDCORE) NULL;
     764      ri.zOrder = (USHORT) CMA_TOP;
     765      ri.cRecordsInsert = ulRecsToInsert;
     766      ri.fInvalidateRecord = TRUE;
     767      WinSendMsg(grep->hwndFiles,
     768                 CM_INSERTRECORD, MPFROMP(pciFirst), MPFROMP(&ri));
     769      if (dcd) {
     770        DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
     771        dcd->ullTotalBytes += grep->insertedbytes;
     772        DosReleaseMutexSem(hmtxFM2Globals);
     773      }
     774      pciFirst = NULL;
    764775    }
    765776    SleepIfNeeded(pitdSleep, 1);
     777  }//for
    766778    // if (grep->toinsert == FilesToGet)        // 07 Feb 08 SHL
    767779    //  DosSleep(0);  //26 Aug 07 GKY 1 // 07 Feb 08 SHL
     
    769781    PostMsg(grep->hwndFiles, UM_RESCAN, MPVOID, MPVOID);
    770782    return TRUE;
    771   }
    772   freegreplist(grep);
    773   return FALSE;
    774783}
    775784
Note: See TracChangeset for help on using the changeset viewer.