G
Guest
Hi everybody
I am creating an application using VC++ that runs on a terminal server with 30 end users. The end users will use thin clients as front end machines. The application consists of a main menu executeble that opens other executables depending on the user selection. In order to establish that communication I use named pipes. Actually I use 1 named pipe as the main tube for data transfer. What happens is that sometimes the session of any user may freeze and another user may view his data. As a result I have started suspecting that something is wrong with the method that creates the child process and also that at a certain point one user may "use" the name pipe share of the other. The code that performs the above call is:
int CTransfer::StartTalking(CString szNewProcess, CNamedPipe* m_ServerObject, char *pszBuffer)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char szProcess[128];
strcpy(szProcess , (LPCTSTR)szNewProcess);
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
szNewProcess += ".exe";
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
szProcess, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
TRUE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
return 1;
}
#ifndef _DEBUG
if (strlen(pszBuffer))
{
DWORD dwBytesWritten;
if (m_ServerObject->ConnectClient())
m_ServerObject->Write(pszBuffer , strlen(pszBuffer), dwBytesWritten);
}
#endif
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
I am thinking that I could do certain things such as:
1. create 1 named pipe per module in order to distribute traffic to more named pipes.
2. use a CreateMutex before the CreateProcess and Release it before the WaitforSingleObject
I will definitely appreciate any opion or help that you might provide.
Thank you for your time
Spiros Prantalos
I am creating an application using VC++ that runs on a terminal server with 30 end users. The end users will use thin clients as front end machines. The application consists of a main menu executeble that opens other executables depending on the user selection. In order to establish that communication I use named pipes. Actually I use 1 named pipe as the main tube for data transfer. What happens is that sometimes the session of any user may freeze and another user may view his data. As a result I have started suspecting that something is wrong with the method that creates the child process and also that at a certain point one user may "use" the name pipe share of the other. The code that performs the above call is:
int CTransfer::StartTalking(CString szNewProcess, CNamedPipe* m_ServerObject, char *pszBuffer)
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
char szProcess[128];
strcpy(szProcess , (LPCTSTR)szNewProcess);
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
szNewProcess += ".exe";
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line).
szProcess, // Command line.
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
TRUE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure.
)
{
return 1;
}
#ifndef _DEBUG
if (strlen(pszBuffer))
{
DWORD dwBytesWritten;
if (m_ServerObject->ConnectClient())
m_ServerObject->Write(pszBuffer , strlen(pszBuffer), dwBytesWritten);
}
#endif
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return 0;
}
I am thinking that I could do certain things such as:
1. create 1 named pipe per module in order to distribute traffic to more named pipes.
2. use a CreateMutex before the CreateProcess and Release it before the WaitforSingleObject
I will definitely appreciate any opion or help that you might provide.
Thank you for your time
Spiros Prantalos