Fred
2007-11-15 01:02:14 UTC
Hi,
I am trying to connect to a SSL (https) using the Device Emulator (v2) and
WM5.
It works fine on the Smartphone, yet fails on the Pocket PC (DE 2) when I
create more that 16 threads!!!!.
(In the actual program I create a threadpool on startup)
I have cobbled together a quick hack (below) to illustrate the problem.
To summarise I create the threads then try to connect to the HTTPS
a. no threads - works on both PPC and SP.
b. < 16 Threads - works on SP and PPC.
c. >=16 Threads - works on SP fails and PPC.
Surely I'm missing something simple, some environment variable or something
on the PPC emulator.
I am dazed and confused.
Any help appreciated
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CThreadPoolSimple *pWTPool =new CThreadPoolSimple();//fails
testSSL();//Fails!!!!!!!!
.
.
.
###
//#define MAX_THREADS 15 //works
#define MAX_THREADS 16 //faisl on PPC
CThreadPoolSimple()
{
PMYDATA pData;
DWORD dwThreadId[MAX_THREADS];
HANDLE hThread[MAX_THREADS];
int i;
// Create MAX_THREADS worker threads.
int j=MAX_THREADS;
for( i=0; i<MAX_THREADS; i++ )
{
// Allocate memory for thread data.
pData = (PMYDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(MYDATA));
if( pData == NULL )
ExitProcess(2);
// Generate unique data for each thread.
pData->val1 = i;
pData->val2 = i+100;
hThread[i] = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc1, // thread function
pData, // argument to thread function
CREATE_SUSPENDED, // use default creation flags
&dwThreadId[i]); // returns the thread identifier
}
}
###
int testSSL()
{
//Hack Stuff
DWORD a=0;
HINTERNET hSession,hDownload,hRequest;
if((hSession = InternetOpen(_T("MFFS"), INTERNET_OPEN_TYPE_DIRECT, NULL,
NULL, 0)) == NULL){return 0;
}
if((hDownload = InternetConnect(hSession, _T("login.yahoo.com"),
INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0)) ==
NULL){
return 0;
}
if((hRequest = HttpOpenRequest(hDownload, _T("POST"),
_T("https://login.yahoo.com/config/login?"), NULL, NULL, NULL,
INTERNET_FLAG_SECURE, 0)) == NULL){
a=GetLastError();
// Error 1359 is ERROR_INTERNAL_ERROR
return 0;
}
return(1);
}
I am trying to connect to a SSL (https) using the Device Emulator (v2) and
WM5.
It works fine on the Smartphone, yet fails on the Pocket PC (DE 2) when I
create more that 16 threads!!!!.
(In the actual program I create a threadpool on startup)
I have cobbled together a quick hack (below) to illustrate the problem.
To summarise I create the threads then try to connect to the HTTPS
a. no threads - works on both PPC and SP.
b. < 16 Threads - works on SP and PPC.
c. >=16 Threads - works on SP fails and PPC.
Surely I'm missing something simple, some environment variable or something
on the PPC emulator.
I am dazed and confused.
Any help appreciated
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
CThreadPoolSimple *pWTPool =new CThreadPoolSimple();//fails
testSSL();//Fails!!!!!!!!
.
.
.
###
//#define MAX_THREADS 15 //works
#define MAX_THREADS 16 //faisl on PPC
CThreadPoolSimple()
{
PMYDATA pData;
DWORD dwThreadId[MAX_THREADS];
HANDLE hThread[MAX_THREADS];
int i;
// Create MAX_THREADS worker threads.
int j=MAX_THREADS;
for( i=0; i<MAX_THREADS; i++ )
{
// Allocate memory for thread data.
pData = (PMYDATA)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(MYDATA));
if( pData == NULL )
ExitProcess(2);
// Generate unique data for each thread.
pData->val1 = i;
pData->val2 = i+100;
hThread[i] = CreateThread(
NULL, // default security attributes
0, // use default stack size
ThreadProc1, // thread function
pData, // argument to thread function
CREATE_SUSPENDED, // use default creation flags
&dwThreadId[i]); // returns the thread identifier
}
}
###
int testSSL()
{
//Hack Stuff
DWORD a=0;
HINTERNET hSession,hDownload,hRequest;
if((hSession = InternetOpen(_T("MFFS"), INTERNET_OPEN_TYPE_DIRECT, NULL,
NULL, 0)) == NULL){return 0;
}
if((hDownload = InternetConnect(hSession, _T("login.yahoo.com"),
INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0)) ==
NULL){
return 0;
}
if((hRequest = HttpOpenRequest(hDownload, _T("POST"),
_T("https://login.yahoo.com/config/login?"), NULL, NULL, NULL,
INTERNET_FLAG_SECURE, 0)) == NULL){
a=GetLastError();
// Error 1359 is ERROR_INTERNAL_ERROR
return 0;
}
return(1);
}