Changeset 1564
Legend:
- Unmodified
 - Added
 - Removed
 
- 
      
trunk/dll/filldir.c
r1555 r1564 91 91 entries in the tree container, fix related semaphore performance using 92 92 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 93 96 94 97 ***********************************************************************/ … … 98 101 #include <malloc.h> // _msize _heapchk 99 102 #include <ctype.h> 103 #include <limits.h> 100 104 // #include <process.h> // _beginthread 101 105 … … 134 138 #include "fm3dlg.h" // INFO_LABEL 135 139 #include "pathutil.h" // AddBackslashToPath 140 #include "tmrsvcs.h" // ITIMER_DESC 136 141 137 142 VOID StubbyScanThread(VOID * arg); … … 944 949 ULONG ulBufBytes; 945 950 ULONG x; 951 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY 946 952 947 953 if (isalpha(*szDirBase) && szDirBase[1] == ':' && szDirBase[2] == '\\') { … … 980 986 &ulFindCnt, 981 987 FIL_QUERYEASIZEL); 982 priority_normal();988 //priority_normal(); 983 989 pszFileSpec[strlen(pszFileSpec) - 1] = 0; // Chop off wildcard 984 990 if (!rc) { 991 InitITimer(&itdSleep, 500); 985 992 do { 986 993 /* … … 1088 1095 cAffbTotal += ulSelCnt; 1089 1096 // 15 Sep 09 SHL allow timed updates to see 1090 if (dcd) {1097 /*if (dcd) { 1091 1098 dcd->totalfiles += ulSelCnt; 1092 1099 dcd->ullTotalBytes += ullTotalBytes; 1093 } 1100 } */ //30 May 11 GKY caused counter to increment twice 1094 1101 } 1095 1102 else { … … 1106 1113 ulFindCnt = ulFindMax; 1107 1114 rc = xDosFindNext(hdir, paffbFound, ulBufBytes, &ulFindCnt, FIL_QUERYEASIZEL); 1108 priority_normal();1115 //priority_normal(); 1109 1116 if (rc) 1110 DosError(FERR_DISABLEHARDERR); 1117 DosError(FERR_DISABLEHARDERR); 1118 SleepIfNeeded(&itdSleep, 1); 1111 1119 } while (!rc); 1112 1120 … … 1122 1130 goto Abort; 1123 1131 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) { 1156 1172 memset(&ri, 0, sizeof(RECORDINSERT)); 1157 1173 ri.cb = sizeof(RECORDINSERT); … … 1159 1175 ri.pRecordParent = (PRECORDCORE) pciParent; 1160 1176 ri.zOrder = (ULONG) CMA_TOP; 1161 ri.cRecordsInsert = cAffbTotal;1177 ri.cRecordsInsert = ulRecsToInsert; 1162 1178 ri.fInvalidateRecord = (!fSyncUpdates && dcd && 1163 1179 dcd->type == DIR_FRAME) ? FALSE : TRUE; … … 1173 1189 ullTotalBytes = 0; 1174 1190 if (WinIsWindow((HAB) 0, hwndCnr)) 1175 FreeCnrItemList(hwndCnr, pciFirst); 1191 FreeCnrItemList(hwndCnr, pciFirst); 1192 pciFirst = NULL; 1193 break; 1176 1194 } 1177 1195 } 1178 } 1179 } 1196 } 1197 SleepIfNeeded(&itdSleep, 1); 1198 } 1180 1199 if (ok) { 1181 1200 ullReturnBytes += ullTotalBytes; … … 1959 1978 PCNRITEM pciNext; 1960 1979 USHORT usCount; 1961 1980 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY 1981 1982 InitITimer(&itdSleep, 500); 1962 1983 for (usCount = 0; pci; usCount++) { 1963 1984 pciNext = (PCNRITEM) pci->rc.preccNextRecord; 1964 1985 FreeCnrItemData(pci); 1965 1986 pci = pciNext; 1987 SleepIfNeeded(&itdSleep, 1); 1966 1988 } 1967 1989 … … 1984 2006 INT remaining = usCnt; 1985 2007 PCNRITEM pci; 2008 ITIMER_DESC itdSleep = { 0 }; // 30 May 11 GKY 2009 1986 2010 1987 2011 if ((usCnt && !pciFirst) || (!usCnt && pciFirst)) { … … 2003 2027 } 2004 2028 } 2029 InitITimer(&itdSleep, 500); 2005 2030 while (pci) { 2006 2031 // 12 Sep 07 SHL dwg drivebar crash testing - ticket# ??? … … 2012 2037 Dos_Error(MB_ENTER, apiret, HWND_DESKTOP, pszSrcFile, __LINE__, 2013 2038 "DosQueryMem failed pci %p pciLast %p", pci, pciLast); 2014 FreeCnrItemData(pci);2039 FreeCnrItemData(pci); 2015 2040 pciLast = pci; 2016 2041 pci = (PCNRITEM)pci->rc.preccNextRecord; 2017 2042 if (remaining && --remaining == 0) 2018 break; 2043 break; 2044 SleepIfNeeded(&itdSleep, 1); 2019 2045 } 2020 2046 }  - 
      
trunk/dll/grep.c
r1544 r1564 36 36 Mostly cast CHAR CONSTANT * as CHAR *. 37 37 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. 38 41 39 42 ***********************************************************************/ … … 43 46 #include <ctype.h> 44 47 #include <share.h> 48 #include <limits.h> 45 49 46 50 #define INCL_DOS … … 718 722 PCNRITEM pci, pciFirst; 719 723 UINT x; 724 ULONG ulRecsToInsert; 720 725 721 726 if (!grep || !grep->toinsert || !grep->insertffb || !grep->dir) 722 727 return FALSE; 723 728 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 } 736 743 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 } 739 753 } 740 754 } 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; 764 775 } 765 776 SleepIfNeeded(pitdSleep, 1); 777 }//for 766 778 // if (grep->toinsert == FilesToGet) // 07 Feb 08 SHL 767 779 // DosSleep(0); //26 Aug 07 GKY 1 // 07 Feb 08 SHL … … 769 781 PostMsg(grep->hwndFiles, UM_RESCAN, MPVOID, MPVOID); 770 782 return TRUE; 771 }772 freegreplist(grep);773 return FALSE;774 783 } 775 784  
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  