Changeset 1271


Ignore:
Timestamp:
Nov 10, 2008, 4:58:50 AM (17 years ago)
Author:
Gregg Young
Message:

A fix for the ticket 58 hang which runs runemf2 with the WAIT flag in a separate thread. This appears to fix Ticket 58 for all cases. Removed semaphore fix and reverted hTermQSem code.

Location:
trunk/dll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/arccnrs.c

    r1270 r1271  
    162162typedef struct {
    163163
    164   CHAR filename[CCHMAXPATH];
    165   HWND hwndCnr;
     164  CHAR   filename[CCHMAXPATH];   //file passed as MP1 message parameter (file selected)
     165  HWND   hwndCnr;                //hwnd you want the message posted to
     166  HWND   hwndClient;             //hwnd calling this thread; NULL will work
     167  ULONG  RunFlags;               //runemf2 flags see systemf.h
     168  CHAR   *pszDirectory;
     169  CHAR   *pszEnvironment;
     170  CHAR   formatstring[40];       //Usally "%s"
     171  CHAR   CmdLine[1024];    //Use sprintf to format multipart command line into single string
    166172}
    167173WAITCHILD;
     
    173179  HAB thab;
    174180  CHAR *filename;
     181  INT ret;
    175182
    176183  DosError(FERR_DISABLEHARDERR);
     
    186193    if (thab) {
    187194      IncrThreadUsage();
    188       priority_normal();
    189       DosWaitEventSem(hWaitChildSem, SEM_INDEFINITE_WAIT);
    190       priority_bumped();
    191       if (IsFile(WaitChild->filename) == 1)
    192         PostMsg(WaitChild->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
     195      priority_bumped(); //normal();
     196      ret = runemf2(WaitChild->RunFlags, WaitChild->hwndClient, pszSrcFile, __LINE__,
     197                    WaitChild->pszDirectory, WaitChild->pszEnvironment,
     198                    WaitChild->formatstring, WaitChild->CmdLine);
     199      if (ret != -1) {
     200        //priority_bumped();
     201        if (IsFile(WaitChild->filename) == 1)
     202          PostMsg(WaitChild->hwndCnr, UM_ENTER, MPFROMP(filename), MPVOID);
     203      }
    193204      DecrThreadUsage();
    194205      WinTerminate(thab);
    195206    }
     207    xfree(WaitChild->pszDirectory, pszSrcFile, __LINE__);
     208    xfree(WaitChild->pszEnvironment, pszSrcFile, __LINE__);
    196209    free(WaitChild);
    197210  } // if WaitChild
     
    15601573          return 0;
    15611574        }
    1562         runemf2(SEPARATE | ASYNCHRONOUS | WAIT |
     1575        sprintf(WaitChild->CmdLine, "%s %s %s",
     1576                                    dcd->info->exwdirs ? dcd->info->exwdirs :
     1577                                    dcd->info->extract,
     1578                                    BldQuotedFileName(szQuotedArcName, dcd->arcname),
     1579                                    BldQuotedFileName(szQuotedMemberName, s));
     1580        /*runemf2(SEPARATE | ASYNCHRONOUS | WAIT |
    15631581                (fArcStuffVisible ? 0 : BACKGROUND),
    1564                 dcd->hwndClient, pszSrcFile, __LINE__, dcd->workdir, NULL,
     1582                , pszSrcFile, __LINE__, dcd->workdir, NULL,
    15651583                "%s %s %s",
    15661584                dcd->info->exwdirs ? dcd->info->exwdirs :
    15671585                                     dcd->info->extract,
    15681586                BldQuotedFileName(szQuotedArcName, dcd->arcname),
    1569                 BldQuotedFileName(szQuotedMemberName, s));
     1587                BldQuotedFileName(szQuotedMemberName, s));*/
    15701588        if (!dcd->info->exwdirs) {
    15711589          p = s;
     
    15861604          p++;
    15871605        }
    1588         free(s);
     1606        free(s);
     1607        WaitChild->RunFlags = SEPARATE | ASYNCHRONOUS | WAIT |
     1608                              (fArcStuffVisible ? 0 : BACKGROUND);
     1609        WaitChild->hwndClient = dcd->hwndClient;
     1610        WaitChild->pszDirectory = xstrdup(dcd->workdir, pszSrcFile, __LINE__);
     1611        WaitChild->pszEnvironment = NULL;
     1612        strcpy(WaitChild->formatstring, "%s");
    15891613        WaitChild->hwndCnr = dcd->hwndCnr;
    15901614        rc = _beginthread(WaitChildThread, NULL, 65536, WaitChild);
  • trunk/dll/systemf.c

    r1270 r1271  
    6262
    6363static PSZ pszSrcFile = __FILE__;
    64 
    65 HEV hWaitChildSem;
    6664
    6765//static HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
     
    694692  static char szTermQName[30];
    695693  static HQUEUE hTermQ;
    696   //static HEV hTermQSem;
     694  static HEV hTermQSem;
    697695
    698696  if (pszDirectory && *pszDirectory) {
     
    10821080          }
    10831081          else {
    1084             rc = DosCreateEventSem(NULL,(PHEV)&hWaitChildSem,0,FALSE);
     1082            rc = DosCreateEventSem(NULL,(PHEV)&hTermQSem,0,FALSE);
    10851083            if (rc) {
    1086                 hWaitChildSem = (HEV)0;     // Try to survive
     1084                hTermQSem = (HEV)0;     // Try to survive
    10871085                DosCloseQueue(hTermQ);
    10881086                hTermQ = (HQUEUE)0;     // Try to survive
     
    10931091          }
    10941092        } // if 1st time
    1095         useTermQ = hTermQ && hWaitChildSem;
     1093        useTermQ = hTermQ && hTermQSem;
    10961094        if (!rc)
    10971095          DosExitCritSec();
     
    11341132      //     sdata.PgmInputs, sdata.TermQ, sdata.InheritOpt,
    11351133      //   sdata.SessionType, szTermQName,
    1136       //   hTermQ, hWaitChildSem); fflush(stdout);
     1134      //   hTermQ, ); fflush(stdout);
    11371135      ret = DosStartSession(&sdata, &ulSessID, &sessPID);
    11381136
     
    11811179        }
    11821180        else {
    1183           ULONG clPosted;
    1184 
    1185           DosResetEventSem(hWaitChildSem, &clPosted);
    11861181          for (ctr = 0;; ctr++)
    11871182          {
    11881183            if (ctr < 20) {
    11891184              rc = DosReadQueue(hTermQ, &rq, &ulLength, (PPVOID)&pTermInfo, 0,
    1190                                 DCWW_NOWAIT, &bPriority, hWaitChildSem);
     1185                                DCWW_NOWAIT, &bPriority, hTermQSem);
    11911186              if (rc == ERROR_QUE_EMPTY) {
    11921187                DosSleep(50);//05 Aug 07 GKY 100
     
    12151210
    12161211            if (pTermInfo->usSessID == ulSessID) {
    1217               DosPostEventSem(hWaitChildSem); //Posted to WaitChildThread (arccnrs.c)
    1218                 break;                    // Our session is done
     1212              priority_bumped();
     1213              break;                    // Our session is done
    12191214            }
    12201215
  • trunk/dll/systemf.h

    r1268 r1271  
    4848EXECARGS;
    4949
    50 extern HEV hWaitChildSem;
    51 
    5250INT ExecOnList(HWND hwnd, CHAR * command, INT flags, CHAR * tpath,
    5351               CHAR ** list, CHAR * prompt, PCSZ pszCallingFile, UINT uiLineNumber);
Note: See TracChangeset for help on using the changeset viewer.