[omniORB] NT Thread Question

Dietmar May dcmay@object-workshops.com
Fri, 8 May 1998 14:03:00 -0400


Robert,

> typedef struct
> {
> 	Echo_Client_ptr  m_rcEchoClient;
> 	const char *m_lpszcmd;
> } tCDoCmdThreadInfo;

Have you tried using an Echo_Client_var instead of _ptr? It seems likely
that after you've started the thread using AfxBeginThread, that your
object reference will go away, since you're returning from the doCMD()
method - back to your Win95 client. The reference is not guaranteed to
be valid (nor likely to be) after your method completes - and it looks
like it isn't.

> void
> Echo_Server_i::doCMD ( Echo_Client_ptr  ar_cEchoClient, const char *
>  as_cmd )
> {
>             // repackaging required for AfxBeginThread
>             //
> 	m_DoCmdThreadInfo.m_rcEchoClient = ar_cEchoClient;
> 	m_DoCmdThreadInfo.m_lpszcmd = as_cmd;
> 	AfxBeginThread (DoCmdThreadProc, &m_DoCmdThreadInfo);

     What happens to ar_cEchoClient now?

> }

> // This is the real method body.
> //
> UINT DoCmdThreadProc(LPVOID pParam)
> {
> tCDoCmdThreadInfo* pDoCmdInfo = (tCDoCmdThreadInfo*)pParam;   // Debug
> reveals trash
> 
>   char *p = CORBA::string_dup(pDoCmdInfo->m_lpszcmd);
> // Actual method stuff here
> 
> // Now we're done.  Callback to the client.
>   pDoCmdInfo->m_rcEchoClient->echoString (p);
> 
>   return 0;
> }

Regards,
Dietmar
(Robert: please excuse duplicate: I didn't reply to the mailing list).