home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / PID.C < prev    next >
Text File  |  1996-03-20  |  30KB  |  716 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   pid.c                                                                   */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   Functions for creating, accessing, and maintaining the shared memory    */
  8. /*   heap on the dbg side of the connection when debugging multiple          */
  9. /*   processes.  On the esp side, we use a c-runtime heap since it           */
  10. /*   doesn't have to be shared.                                              */
  11. /*                                                                           */
  12. /* History:                                                                  */
  13. /*                                                                           */
  14. /*   10/14/94 Created.                                                       */
  15. /*                                                                           */
  16. /*****************************************************************************/
  17.  
  18. #include "all.h"
  19.  
  20. #define PID_SHARED_MEM_SIZE  5*4096
  21.  
  22. static ALLPIDS *pAllpids = NULL;
  23. static ULONG   *pSharedMem;
  24.  
  25. ULONG   *GetShrMem ( void ) { return( pSharedMem ); }
  26. ALLPIDS *GetAllpids( void ) { return( pAllpids   ); }
  27.  
  28. /*****************************************************************************/
  29. /* AddPid()                                                                  */
  30. /*                                                                           */
  31. /* Description:                                                              */
  32. /*                                                                           */
  33. /*   Add a pid structure to the allpids list in the shared heap.             */
  34. /*   DosAllocMem() is used because of sharing requirements.                  */
  35. /*                                                                           */
  36. /* Parameters:                                                               */
  37. /*                                                                           */
  38. /*   pid         the process id of a process being debugged.                 */
  39. /*   sid         the session id that the pid is running in.                  */
  40. /*   EspSid      the session id of the probe( local/child/multiple process ) */
  41. /*   type        the type of the process.                                    */
  42. /*   pFileSpec ->the name of the process.                                    */
  43. /*                                                                           */
  44. /* Return:                                                                   */
  45. /*                                                                           */
  46. /* Assumptions:                                                              */
  47. /*                                                                           */
  48. /*****************************************************************************/
  49. void AddPid( USHORT  pid,
  50.              ULONG   sid,
  51.              ULONG   EspSid,
  52.              ULONG   type,
  53.              char   *pFileSpec )
  54. {
  55.  ALLPIDS *p, *q, *r;
  56.  ULONG    flags;
  57.  
  58.  /****************************************************************************/
  59.  /* - test to see if this pid is already accounted for.                      */
  60.  /****************************************************************************/
  61.  for( p = pAllpids ; p ; p = p->next )
  62.   if( p->pid == pid )
  63.    return;
  64.  
  65.  /****************************************************************************/
  66.  /* - Don't use a shared heap if we're debugging a single process.           */
  67.  /****************************************************************************/
  68.  if( SingleMultiple() == SINGLE )
  69.  {
  70.   p = Talloc(sizeof(ALLPIDS));
  71.   memset(p, 0, sizeof(ALLPIDS) );
  72.   p->pid                     = pid;
  73.   p->sid                     = sid;
  74.   p->type                    = type;
  75.   p->EspSid                  = EspSid;
  76.   p->Connect                 = DISCONNECTED;
  77.  
  78.   if( pFileSpec != NULL )
  79.   {
  80.    p->pFileSpec = Talloc( strlen(pFileSpec) + 1 );
  81.    strcpy(p->pFileSpec, pFileSpec);
  82.   }
  83.  
  84.   for( q = (ALLPIDS*)&pAllpids, r = pAllpids ; r ; q = r, r = r->next ){;}
  85.  
  86.   q->next = p;
  87.  
  88.   return;
  89.  }
  90.  
  91.  /****************************************************************************/
  92.  /* - Come here only if we're using configurations that require a shared     */
  93.  /*   heap.                                                                  */
  94.  /* - allocate a node and add it to the head of the list.                    */
  95.  /****************************************************************************/
  96.  if( pAllpids == NULL )
  97.  {
  98.   if( IsVerbose() ) {printf("\nHeap Started");fflush(0);}
  99.   flags = OBJ_GIVEABLE | PAG_READ | PAG_WRITE | OBJ_GETTABLE;
  100.   DosAllocSharedMem( (PPVOID)&pSharedMem, NULL, PID_SHARED_MEM_SIZE, flags );
  101.   flags = DOSSUB_INIT | DOSSUB_SPARSE_OBJ;
  102.   DosSubSetMem( pSharedMem, flags, PID_SHARED_MEM_SIZE );
  103.  }
  104.  DosSubAllocMem( pSharedMem, (PPVOID)&p, sizeof(ALLPIDS) );
  105.  
  106.  memset(p, 0, sizeof(ALLPIDS) );
  107.  p->pid                     = pid;
  108.  p->sid                     = sid;
  109.  p->EspSid                  = EspSid;
  110.  p->type                    = type;
  111.  p->Connect                 = DISCONNECTED;
  112.  p->PidFlags.ConnectYielded = FALSE;
  113.  p->PidFlags.IsDebug        = FALSE;
  114.  p->PidFlags.Initializing   = TRUE;
  115.  p->pSqeMsg                 = NULL;
  116.  if( pFileSpec != NULL )
  117.  {
  118.   DosSubAllocMem( pSharedMem, (PPVOID)&(p->pFileSpec), strlen(pFileSpec) + 1 );
  119.   strcpy(p->pFileSpec, pFileSpec);
  120.  }
  121.  
  122.  for( q = (ALLPIDS*)&pAllpids, r = pAllpids ; r ; q = r, r = r->next ){;}
  123.  
  124.  q->next = p;
  125. }
  126.  
  127. void FreeAllPids( void )
  128. {
  129.  ALLPIDS *ptr;
  130.  ALLPIDS *ptrnext;
  131.  
  132.  for( ptr = pAllpids; ptr != NULL; )
  133.  {
  134.   ptrnext=ptr->next;
  135.   if(ptr->pFileSpec) Tfree(ptr->pFileSpec);
  136.   Tfree((void*)ptr);
  137.   ptr=ptrnext;
  138.  }
  139.  pAllpids = NULL;
  140. }
  141.  
  142. /*****************************************************************************/
  143. /* RemovePid()                                                               */
  144. /*                                                                           */
  145. /* Description:                                                              */
  146. /*                                                                           */
  147. /*   Remove a pid structure from the shared heap.                            */
  148. /*                                                                           */
  149. /* Parameters:                                                               */
  150. /*                                                                           */
  151. /*   pid         the process id of a process being debugged.                 */
  152. /*                                                                           */
  153. /* Return:                                                                   */
  154. /*                                                                           */
  155. /* Assumptions:                                                              */
  156. /*                                                                           */
  157. /*****************************************************************************/
  158. void RemovePid( USHORT pid )
  159. {
  160.  ALLPIDS *pprev;
  161.  ALLPIDS *p;
  162.  
  163.  pprev = (ALLPIDS *)&pAllpids;
  164.  for( p = pprev->next; p ; pprev = p, p = pprev->next )
  165.  {
  166.   if( p->pid == pid )
  167.   {
  168.    pprev->next = p->next;
  169.    if( p->pFileSpec != NULL )
  170.     DosSubFreeMem( pSharedMem, p->pFileSpec, strlen(p->pFileSpec) + 1 );
  171.    if( p->pTermQue != NULL )
  172.     DosSubFreeMem( pSharedMem, p->pTermQue, strlen(p->pTermQue) + 1 );
  173.    DosSubFreeMem( pSharedMem, p, sizeof(ALLPIDS) );
  174.    break;
  175.   }
  176.  }
  177. }
  178.  
  179.  
  180. /*****************************************************************************/
  181. /* - Free the shared memory heap structures.                                 */
  182. /*****************************************************************************/
  183. void FreeSharedHeap( void )
  184. {
  185.  ALLPIDS *p;
  186.  
  187.  if( IsVerbose() ) { printf("\nShared Heap freed."); fflush(0); }
  188.  for( p = pAllpids ; p ; p = pAllpids )
  189.  {
  190.   RemovePid( p->pid );
  191.  }
  192.  DosFreeMem(pSharedMem);
  193.  pSharedMem = NULL;
  194. }
  195.  
  196. /*****************************************************************************/
  197. /* - Get read/write access to the shared memory heap for this debugger.      */
  198. /*****************************************************************************/
  199. void SetShrMem( ULONG *ShrMemBaseAddr )
  200. {
  201.  pSharedMem = ShrMemBaseAddr;
  202.  DosGetSharedMem( pSharedMem, PAG_READ | PAG_WRITE );
  203. }
  204.  
  205. /*****************************************************************************/
  206. /* - set the pointer to the shared memory heap as inherited from the         */
  207. /*   parent debugger at invocation time.                                     */
  208. /*****************************************************************************/
  209. void SetShrHeap( ULONG *HeapBigPtr )
  210. {
  211.  pAllpids = (ALLPIDS *)HeapBigPtr;
  212. }
  213.  
  214. /*****************************************************************************/
  215. /* - Get a pointer to a pid structure.                                       */
  216. /*****************************************************************************/
  217. ALLPIDS *GetPid( USHORT pid )
  218. {
  219.  ALLPIDS *p;
  220.  
  221.  for( p = pAllpids ; p ; p = p->next )
  222.  {
  223.   if( p->pid == pid )
  224.    break;
  225.  }
  226.  return(p);
  227. }
  228.  
  229.  
  230. /*****************************************************************************/
  231. /*                                                                           */
  232. /*  - Test to see if a pid is currently connected.  This only applies to     */
  233. /*    serial connections.                                                    */
  234. /*                                                                           */
  235. /*****************************************************************************/
  236. BOOL IsPidConnected( void )
  237. {
  238.  ALLPIDS *p;
  239.  
  240.  for( p = pAllpids ; p ; p = p->next )
  241.   if( p->Connect == CONNECTED )
  242.    return( TRUE );
  243.  return( FALSE );
  244. }
  245.  
  246.  
  247. /*****************************************************************************/
  248. /* GetPidIndex()                                                             */
  249. /*                                                                           */
  250. /* Description:                                                              */
  251. /*                                                                           */
  252. /*   Get a pointer to a specific node.                                       */
  253. /*                                                                           */
  254. /* Parameters:                                                               */
  255. /*                                                                           */
  256. /*   index   the index of the process node we're seeking.                    */
  257. /*                                                                           */
  258. /* Return:                                                                   */
  259. /*                                                                           */
  260. /*   p       -> to the structure for the parameter pid.                      */
  261. /*                                                                           */
  262. /* Assumptions:                                                              */
  263. /*                                                                           */
  264. /*   index > 0                                                               */
  265. /*                                                                           */
  266. /*****************************************************************************/
  267. ALLPIDS *GetPidIndex( int index )
  268. {
  269.  ALLPIDS *p;
  270.  
  271.  for( p = pAllpids, --index; index > 0; p = p->next, index-- ){;}
  272.  return(p);
  273. }
  274.  
  275. /*****************************************************************************/
  276. /*                                                                           */
  277. /* - This only applies to serial connections only.                           */
  278. /* - Get a pointer to the node that is currently connected.  Applies to      */
  279. /*   serial connections only.                                                */
  280. /*                                                                           */
  281. /*****************************************************************************/
  282. ALLPIDS *GetPidConnected( void )
  283. {
  284.  ALLPIDS *p;
  285.  
  286.  for( p = pAllpids ; p ; p = p->next )
  287.   if( p->Connect == CONNECTED )
  288.    return( p );
  289.  return( NULL );
  290. }
  291.  
  292. #ifdef __ESP__
  293. /*---------------------------------------------------------------------------*/
  294.  
  295. /*****************************************************************************/
  296. /*                                                                           */
  297. /* - Get a pointer to the structure containing the pid of an esp attached    */
  298. /*   to a process.                                                           */
  299. /*                                                                           */
  300. /*****************************************************************************/
  301. ALLPIDS *GetEspPid( USHORT EspPid )
  302. {
  303.  ALLPIDS *p;
  304.  
  305.  for( p = pAllpids ; p ; p = p->next )
  306.  {
  307.   if( p->EspPid == EspPid )
  308.    break;
  309.  }
  310.  return(p);
  311. }
  312.  
  313. /*---------------------------------------------------------------------------*/
  314. #endif
  315.  
  316.  
  317. #ifdef __DBG__
  318. /*---------------------------------------------------------------------------*/
  319.  
  320. /*****************************************************************************/
  321. /* - add the session id of a debugger session to a pid structure.            */
  322. /*****************************************************************************/
  323. void AddDbgPidAndSid( USHORT pid, USHORT DbgPid, ULONG DbgSid )
  324. {
  325.  ALLPIDS *p;
  326.  
  327.  for( p = pAllpids ; p ; p = p->next )
  328.   if( p->pid == pid )
  329.   {
  330.    p->DbgSid = DbgSid;
  331.    p->DbgPid = DbgPid;
  332.    break;
  333.   }
  334. }
  335.  
  336. /*****************************************************************************/
  337. /*                                                                           */
  338. /* - This only applies to serial connections.                                */
  339. /* - This thread periodically checks for a manual disconnect by the user     */
  340. /*   and displays a message if it happens.                                   */
  341. /*                                                                           */
  342. /*****************************************************************************/
  343. static BOOL KillChk4Disconnect = FALSE;
  344.  
  345. void SetKillChk4Disconnect( BOOL TorF ) { KillChk4Disconnect = TorF; }
  346.  
  347. void CheckForDisConnect( void *dummy )
  348. {
  349.  ALLPIDS *p;
  350.  
  351.  /****************************************************************************/
  352.  /* - This thread gets launched after the connectsema4 is posted.            */
  353.  /*   It waits for a possible disconnection, posts a message, and dies.      */
  354.  /****************************************************************************/
  355.  p = GetPid( DbgGetProcessID() );
  356.  
  357.  if( IsVerbose() ) {printf("\nChk4Disconnect started");fflush(0);}
  358.  for( ; KillChk4Disconnect == FALSE ; )
  359.  {
  360.   if( p->PidFlags.ConnectYielded == TRUE )
  361.   {
  362.    fmterr("Disconnected...double click on window to reconnect.");
  363.    p->PidFlags.ConnectYielded = FALSE ;
  364.   }
  365.   DosSleep(1500);
  366.  }
  367.  if( IsVerbose() ) {printf("\nChk4Disconnect ended");fflush(0);}
  368.  _endthread();
  369. }
  370.  
  371. void Check4ConnectRequest( void *dummy )
  372. {
  373.  ALLPIDS *p;
  374.  
  375.  /****************************************************************************/
  376.  /* - This thread gets launched after the connectsema4 is posted.            */
  377.  /****************************************************************************/
  378.  
  379.  if( IsVerbose() ) {printf("\nChk4 connect request started");fflush(0);}
  380.  for(;;)
  381.  {
  382.   p = GetPid( DbgGetProcessID() );
  383.   if( p && (p->PidFlags.RequestConnect == TRUE) )
  384.   {
  385.    beep();
  386.    SayStatusMsg("Connect Request... Ctrl-Break or select Misc->Process");
  387.    p->PidFlags.RequestConnect = FALSE ;
  388.   }
  389.   DosSleep(2000);
  390.  }
  391. }
  392.  
  393. /*****************************************************************************/
  394. /*                                                                           */
  395. /* - Get a pointer to the structure containing the pid of a debugger.        */
  396. /*                                                                           */
  397. /*****************************************************************************/
  398. ALLPIDS *GetDbgPid( USHORT DbgPid )
  399. {
  400.  ALLPIDS *p;
  401.  
  402.  for( p = pAllpids ; p ; p = p->next )
  403.  {
  404.   if( p->DbgPid == DbgPid )
  405.    break;
  406.  }
  407.  return(p);
  408. }
  409.  
  410. /*****************************************************************************/
  411. /* - Get read/write access to the shared memory heap for this debugger.      */
  412. /*****************************************************************************/
  413. void SetExecutionFlag( BOOL TorF )
  414. {
  415.  ALLPIDS *p;
  416.  
  417.  p = GetPid( DbgGetProcessID() );
  418.  p->PidFlags.Executing = TorF;
  419. }
  420.  
  421. /*---------------------------------------------------------------------------*/
  422. #endif
  423.  
  424. #ifdef __ESP__
  425. /*---------------------------------------------------------------------------*/
  426. /*****************************************************************************/
  427. /* AddMessage()                                                              */
  428. /*                                                                           */
  429. /* Description:                                                              */
  430. /*                                                                           */
  431. /*   Add a message to the message queue for serial multiple process.         */
  432. /*                                                                           */
  433. /* Parameters:                                                               */
  434. /*                                                                           */
  435. /*   msg    the id of the message that is being queued.                      */
  436. /*   pBuf   -> to a buffer of parms for this notification.                   */
  437. /*   BufLen size of the parm block for this message.                         */
  438. /*                                                                           */
  439. /* Return:                                                                   */
  440. /*                                                                           */
  441. /* Assumptions:                                                              */
  442. /*                                                                           */
  443. /*****************************************************************************/
  444. void AddMessage( UCHAR msg, void *pBuf, ULONG BufLen )
  445. {
  446.  SQE_MESSAGE  *pSqe, *q, *r;
  447.  ULONG         sqe_size;
  448.  
  449.  sqe_size = sizeof(SQE_MESSAGE) + BufLen - sizeof(pSqe->parms);
  450.  
  451.  pSqe = NULL;
  452.  DosSubAllocMem( pSharedMem, (PPVOID)&pSqe, sqe_size );
  453.  
  454.  memset( pSqe, 0, sqe_size );
  455.  pSqe->next     = NULL;
  456.  pSqe->Reported = FALSE;
  457.  pSqe->msg      = msg;
  458.  pSqe->size     = sqe_size;
  459.  memcpy( pSqe->parms, pBuf, BufLen );
  460.  
  461.  
  462.  q = (SQE_MESSAGE*)&(pAllpids->pSqeMsg);
  463.  r = pAllpids->pSqeMsg;
  464.  
  465.  for( ; r ; q = r, r = r->next ){;}
  466.  
  467.  q->next = pSqe;
  468.  
  469.  q = (SQE_MESSAGE*)&(pAllpids->pSqeMsg);
  470.  r = pAllpids->pSqeMsg;
  471. }
  472.  
  473. /*****************************************************************************/
  474. /* RemoveMessage()                                                           */
  475. /*                                                                           */
  476. /* Description:                                                              */
  477. /*                                                                           */
  478. /*   Remove a message from the message queue for serial multiple process.    */
  479. /*                                                                           */
  480. /* Parameters:                                                               */
  481. /*                                                                           */
  482. /*   pSqe   -> to the message element to be removed.                         */
  483. /*                                                                           */
  484. /* Return:                                                                   */
  485. /*                                                                           */
  486. /* Assumptions:                                                              */
  487. /*                                                                           */
  488. /*****************************************************************************/
  489. void RemoveMessage( SQE_MESSAGE *pSqe )
  490. {
  491.  SQE_MESSAGE  *q, *r;
  492.  
  493.  q = (SQE_MESSAGE*)&(pAllpids->pSqeMsg);
  494.  r = pAllpids->pSqeMsg;
  495.  
  496.  while( r != pSqe ) { r = r->next; }
  497.  
  498.  q->next = r->next;
  499.  
  500.  for( ; r ; q = r, r = r->next ){;}
  501.  
  502.  DosSubFreeMem( pSharedMem, pSqe, pSqe->size );
  503.  
  504.  q = (SQE_MESSAGE*)&(pAllpids->pSqeMsg);
  505.  r = pAllpids->pSqeMsg;
  506. }
  507.  
  508. /*****************************************************************************/
  509. /* GetConnectNotification()                                                  */
  510. /*                                                                           */
  511. /* Description:                                                              */
  512. /*                                                                           */
  513. /*   We want to poll in notifications for connect requests that cannot       */
  514. /*   be serviced.                                                            */
  515. /*                                                                           */
  516. /* Parameters:                                                               */
  517. /*                                                                           */
  518. /* Return:                                                                   */
  519. /*                                                                           */
  520. /*   pSqe   -> to the connect request that has not been serviced or          */
  521. /*             reported.                                                     */
  522. /*                                                                           */
  523. /* Assumptions:                                                              */
  524. /*                                                                           */
  525. /*****************************************************************************/
  526. SQE_MESSAGE *GetConnectNotification( void )
  527. {
  528.  SQE_MESSAGE  *pSqe;
  529.  
  530.  
  531.  
  532.  for( pSqe = pAllpids->pSqeMsg; pSqe ; pSqe = pSqe->next )
  533.  {
  534.   if( (pSqe->msg == CONNECT_DBG) && (pSqe->Reported == FALSE) )
  535.   {
  536.    pSqe->Reported = TRUE;
  537.    return(pSqe);
  538.   }
  539.  }
  540.  return(NULL);
  541. }
  542.  
  543. /*****************************************************************************/
  544. /* IsConnectRequestQueued()                                                  */
  545. /*                                                                           */
  546. /* Description:                                                              */
  547. /*                                                                           */
  548. /*   Check to see if there is a connect queued for this pid.                 */
  549. /*                                                                           */
  550. /* Parameters:                                                               */
  551. /*                                                                           */
  552. /*   pid    -> to the message element to be removed.                         */
  553. /*                                                                           */
  554. /* Return:                                                                   */
  555. /*                                                                           */
  556. /*   pSqe   -> to the connect request that has not been serviced or          */
  557. /*             reported.                                                     */
  558. /*          NULL==> not queued.                                              */
  559. /*                                                                           */
  560. /* Assumptions:                                                              */
  561. /*                                                                           */
  562. /*  pAllpids != NULL                                                         */
  563. /*                                                                           */
  564. /*****************************************************************************/
  565. SQE_MESSAGE *IsConnectRequestQueued( USHORT pid )
  566. {
  567.  SQE_MESSAGE  *pSqe;
  568.  USHORT        QuePid;
  569.  
  570.  for( pSqe = pAllpids->pSqeMsg; pSqe ; pSqe = pSqe->next )
  571.  {
  572.   if( pSqe->msg == CONNECT_DBG )
  573.   {
  574.    QuePid = *(USHORT*)pSqe->parms;
  575.    if( QuePid == pid )
  576.     return(pSqe);
  577.   }
  578.  }
  579.  return(NULL);
  580. }
  581.  
  582. /*****************************************************************************/
  583. /* ReportMessage()                                                           */
  584. /*                                                                           */
  585. /* Description:                                                              */
  586. /*                                                                           */
  587. /*   Report a message from the message queue for serial multiple process.    */
  588. /*                                                                           */
  589. /* Parameters:                                                               */
  590. /*                                                                           */
  591. /* Return:                                                                   */
  592. /*                                                                           */
  593. /* Assumptions:                                                              */
  594. /*                                                                           */
  595. /*****************************************************************************/
  596. void ReportMessage( void )
  597. {
  598.  SQE_MESSAGE *pSqe = NULL;
  599.  COMMAND      cmd;
  600.  LHANDLE      handle;
  601.  
  602.  
  603.  /****************************************************************************/
  604.  /* - Test for the existence of the shared heap.                             */
  605.  /****************************************************************************/
  606.  if( pAllpids == NULL )
  607.   return;
  608.  
  609.  /****************************************************************************/
  610.  /* - Get the handle to the serial channel.                                  */
  611.  /****************************************************************************/
  612.  handle = GetComHandle();
  613.  
  614.  /****************************************************************************/
  615.  /* - Get a pointer to the first message in the que.                         */
  616.  /****************************************************************************/
  617.  pSqe = pAllpids->pSqeMsg;
  618.  
  619.  if( pSqe == NULL )
  620.  {
  621.   /***************************************************************************/
  622.   /* - If no messages, then simply close the serial poll loop.               */
  623.   /***************************************************************************/
  624.   memset(&cmd,0,sizeof(cmd) );
  625.  
  626.   cmd.api = SERIAL_POLL;
  627.   cmd.cmd = 0;
  628.  
  629.   RmtSend( handle, &cmd, sizeof(cmd) );
  630.  }
  631.  else
  632.  {
  633.   /***************************************************************************/
  634.   /* - Else, grab the next mesage in the queue and report it.                */
  635.   /***************************************************************************/
  636.   switch( pSqe->msg )
  637.   {
  638.    case NEW_PROCESS:
  639.    {
  640.     SQE_NEW_PROCESS *pnp;
  641.     USHORT pid;
  642.     ULONG  type;
  643.     ULONG  mte;
  644.  
  645.     pnp  = (SQE_NEW_PROCESS*)(pSqe->parms);
  646.     pid  = pnp->pid;
  647.     type = pnp->type;
  648.     mte  = pnp->mte;
  649.  
  650.     SendNewProcessToDbg( handle, pid, type, mte );
  651.     RemoveMessage( pSqe );
  652.    }
  653.    break;
  654.  
  655.    case CONNECT_DBG:
  656.    {
  657.     ALLPIDS *p;
  658.     USHORT   pid;
  659.     BOOL     TorF;
  660.  
  661.     pid = *(USHORT*)pSqe->parms;
  662.  
  663.  
  664.     if( IsPidConnected() == FALSE )
  665.     {
  666.  
  667.      p   = GetPid( pid );
  668.      ConnectDbg( handle, pid );
  669.  
  670.      p->Connect = CONNECTED;
  671.  
  672.      TorF = TRUE;
  673.      if( p->pid == GetEspProcessID() )
  674.       TorF = FALSE;
  675.  
  676.      PostConnectSema4( &p->ConnectSema4, TorF );
  677.      RemoveMessage( pSqe );
  678.     }
  679.     else
  680.     {
  681.      /************************************************************************/
  682.      /* - At this point, we have a queued connect request.                   */
  683.      /* - If this pid is already connected, then remove it.                  */
  684.      /* - Else, leave it in the queue and complete the serial poll.          */
  685.      /************************************************************************/
  686.      if( GetPidConnected()->pid == pid )
  687.       RemoveMessage( pSqe );
  688.  
  689.      memset(&cmd,0,sizeof(cmd) );
  690.      cmd.api = SERIAL_POLL;
  691.      cmd.cmd = 0;
  692.  
  693.      /************************************************************************/
  694.      /* - Check to see if there are any connect requests that haven't        */
  695.      /*   been reported.                                                     */
  696.      /* - If there are, then send back the pid.                              */
  697.      /************************************************************************/
  698.      pSqe = GetConnectNotification();
  699.      if( pSqe )
  700.       cmd.cmd = CONNECT_NOTIFY;
  701.  
  702.      RmtSend( handle, &cmd, sizeof(cmd) );
  703.      if( pSqe )
  704.      {
  705.       pid = *(USHORT*)pSqe->parms;
  706.       RmtSend( handle, &pid, sizeof(pid) );
  707.      }
  708.     }
  709.    }
  710.    break;
  711.   }
  712.  }
  713. }
  714. /*---------------------------------------------------------------------------*/
  715. #endif
  716.