[omniORB] NT Thread Question

Robert H. Fritz rfritz@geologics.com
Fri, 8 May 1998 11:16:49 -0400


Hi Everyone,

I've got a Win95 machine running as a client and an NT40 workstation acting
as a server.  The client is calling a oneway method on the server and
passing an object reference (of itself) to the server.  When the
server-method completes, the server callsback a client-method using this
object reference. This arrangement worked fine until I re-implemented the
server method using AfxBeginThread.  Now this arrangement only works when
the client and server are running on the NT machine.  When the Win95 client
calls the server, the thread gets an access violation when attempting to
call the client-method.  Under debug, the object reference and the string
appear to be trash.  Is there some thread-safe omniORB call I should be
making?

Any info appreciated.

Rob Fritz
rfritz@geologics.com

The relevant code is relatively simple:

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

tCDoCmdThreadInfo m_DoCmdThreadInfo;

// This is the oneway server method invoked by the client
//
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);
}

// 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;
}