Changeset 1786


Ignore:
Timestamp:
Aug 30, 2014, 10:03:35 PM (11 years ago)
Author:
Gregg Young
Message:

Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents a trap when FM2 is shutdown while directory containers are still populating (Ticket 535)

Location:
trunk/dll
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/dircnrs.c

    r1778 r1786  
    8686  02 Mar 14 GKY Speed up intial drive scans Ticket 528
    8787  26 Jun 14 SHL Rework DirObjWndProc UM_RESCAN to avoid hanging FM/2 Lite when tree hidden
     88  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
     89                a trap when FM2 is shutdown while directory containers are still populating
    8890
    8991***********************************************************************/
     
    12101212                        0,
    12111213                        0,
    1212                         SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     1214                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     1215      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    12131216      FreeList(dcd->lastselection);
    12141217      WinSetWindowPtr(dcd->hwndCnr, QWL_USER, NULL);    // 13 Apr 10 SHL Set NULL before freeing dcd
     
    16301633      }
    16311634      // 2014-06-11 SHL fm/2 lite can get here before drive scan completes
    1632       if (!fInitialDriveScan)
    1633         PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
     1635      //if (!fInitialDriveScan) // 2014-08-30 GKY This doesn't seem to be needed
     1636        PostMsg(hwnd, UM_SETUP2, MPVOID, MPVOID);
    16341637    }
    16351638    else {
     
    35223525                        0,
    35233526                        0,
    3524                         SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     3527                        SWP_RESTORE | SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
     3528      DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    35253529      FreeList(dcd->lastselection);
    35263530      free(dcd);
  • trunk/dll/filter.c

    r1782 r1786  
    2222  31 May 11 SHL Rework Filter() for speed
    2323  28 Jun 14 GKY Fix errors identified with CPPCheck;
     24  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
     25                a trap when FM2 is shutdown while directory containers are still populating
    2426
    2527***********************************************************************/
     
    8486    return TRUE;                        // No mask data
    8587
     88  DosRequestMutexSem(hmtxFiltering, SEM_INDEFINITE_WAIT);
    8689  pci = (PCNRITEM) rmini;
    8790  // Always show root directory
    8891  // 2011-05-31 SHL fixme to know if this is correct
    8992  if (!(*(pci->pszFileName + 3))
    90       || mask->fShowDirs && (pci->attrFile & FILE_DIRECTORY))
     93      || mask->fShowDirs && (pci->attrFile & FILE_DIRECTORY)) {
     94    DosReleaseMutexSem(hmtxFiltering);
    9195    return TRUE;
     96  }
    9297
    9398  if ((~mask->attrFile & FILE_HIDDEN && pci->attrFile & FILE_HIDDEN) ||
     
    95100      (~mask->attrFile & FILE_READONLY && pci->attrFile & FILE_READONLY) ||
    96101      (~mask->attrFile & FILE_ARCHIVED && pci->attrFile & FILE_ARCHIVED) ||
    97       (~mask->attrFile & FILE_DIRECTORY && pci->attrFile & FILE_DIRECTORY))
     102      (~mask->attrFile & FILE_DIRECTORY && pci->attrFile & FILE_DIRECTORY)) {
     103    DosReleaseMutexSem(hmtxFiltering);
    98104    return FALSE;
     105  }
    99106
    100107  if ((mask->antiattr & FILE_HIDDEN && ~pci->attrFile & FILE_HIDDEN) ||
     
    102109      (mask->antiattr & FILE_READONLY && ~pci->attrFile & FILE_READONLY) ||
    103110      (mask->antiattr & FILE_ARCHIVED && ~pci->attrFile & FILE_ARCHIVED) ||
    104       (mask->antiattr & FILE_DIRECTORY && ~pci->attrFile & FILE_DIRECTORY))
     111      (mask->antiattr & FILE_DIRECTORY && ~pci->attrFile & FILE_DIRECTORY)) {
     112    DosReleaseMutexSem(hmtxFiltering);
    105113    return FALSE;
    106 
    107   if (!*mask->szMask)
    108     return TRUE;                        // No masks
     114  }
     115
     116  if (mask && !*mask->szMask) {
     117    DosReleaseMutexSem(hmtxFiltering);
     118    return TRUE;
     119  }// No masks
    109120
    110121  // Have mask string
     
    118129
    119130  if (!mask->pszMasks[1]) {
     131    DosReleaseMutexSem(hmtxFiltering);
    120132    // Just one mask string
    121133    return wildcard(strchr(mask->szMask, '\\') ||
     
    153165    }
    154166  } // for
    155 
     167  DosReleaseMutexSem(hmtxFiltering);
    156168  return matched;
    157169}
  • trunk/dll/init.c

    r1778 r1786  
    129129                Added option to suppress message regarding missing bzip2.exe
    130130                or gzip.exe on TAR.B/GZ archives.
     131  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
     132                a trap when FM2 is shutdown while directory containers are still populating
    131133
    132134***********************************************************************/
     
    228230HMTX hmtxFM2Globals;
    229231HMTX hmtxScanning;
     232HMTX hmtxFiltering;
    230233HEV  hevTreeCnrScanComplete;
    231234ULONG OS2ver[2];
     
    590593  save_dir(s);
    591594  AddBackslashToPath(s);
    592   //if (s[strlen(s) - 1] != '\\')
    593   //  strcat(s, "\\");
    594595  enddir = &s[strlen(s)];
    595596  if (*ArcTempRoot) {
     
    11611162  if (DosCreateMutexSem(NULL, &hmtxFM2Delete, 0L, FALSE))
    11621163    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
    1163               PCSZ_DOSCREATEMUTEXSEM);
     1164              PCSZ_DOSCREATEMUTEXSEM);
     1165  if (DosCreateMutexSem(NULL, &hmtxFiltering, 0L, FALSE))
     1166    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
     1167              PCSZ_DOSCREATEMUTEXSEM);
    11641168  if (DosCreateEventSem(NULL, &hevTreeCnrScanComplete, 0L, TRUE))
    11651169    Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
  • trunk/dll/init.h

    r1753 r1786  
    3939                Added option to suppress message regarding missing bzip2.exe
    4040                or gzip.exe on TAR.B/GZ archives.
     41  30 Aug 14 GKY Add semaphore hmtxFiltering to prevent freeing dcd while filtering. Prevents
     42                a trap when FM2 is shutdown while directory containers are still populating
    4143
    4244***********************************************************************/
     
    236238extern HMTX hmtxFM2Delete;
    237239extern HMTX hmtxScanning;
     240extern HMTX hmtxFiltering;
    238241extern HEV  hevTreeCnrScanComplete;
    239242#endif
Note: See TracChangeset for help on using the changeset viewer.