ATL component freezes after destructor
From: TxITGuy (txitguy.nospam_at_earthlink.net)
Date: 03/10/05
- Next message: Alexander Nickolov: "Re: Is this consider as the reentrancy problem?"
- Previous message: Alexander Nickolov: "Re: HOWTO set up minimal sink object in console COM client?"
- Next in thread: Brian Muth: "Re: ATL component freezes after destructor"
- Reply: Brian Muth: "Re: ATL component freezes after destructor"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Mar 2005 09:53:06 -0800
This is my first ATL project, and I am encapsulating the WinInet API in a
DLL. So far, everything is working fine ... until I try to unload the DLL
from the test console.
At that point, it calls the destructor function, which clears the callback
function for each cached handle and then closes the handle. This runs
completely without error. Then it goes into assembly code and runs until it
hits "JMP 70ABB2B6", at which point it completely stops executing anything.
I have to use the "Stop Debugging" command to get out of it.
So far, it only fails this way if I call the following method while testing
the component. This method also completes without error, and in stepping
through the code it appears to correctly release all the resources it uses.
STDMETHODIMP CHTTP::GetRequest(BSTR sDomain, BSTR sDocument, BSTR
sQueryString, BSTR sAccept, BOOL bSecure)
{
char *lpszDomain = _com_util::ConvertBSTRToString(sDomain);
char *lpszDocument = _com_util::ConvertBSTRToString(sDocument);
char *lpszQueryString = _com_util::ConvertBSTRToString(sQueryString);
char *lpszAccept = _com_util::ConvertBSTRToString(sAccept);
char **lplpszAccepts = NULL; //variable to hold "Accepts:" string array.
unsigned int uiRows = 0;
BOOL bRequestSent = FALSE;
HINTERNET hSession;
HINTERNET hRequest;
DWORD dwErrorNum;
char sError[200] = "";
m_bSecure = bSecure;
if(!m_bOpen) return Error("HTTP class not ready, please call Open
method.",GUID_NULL,0xE0000003);
hSession = GetInetSession(lpszDomain,INTERNET_SERVICE_HTTP,80);
//assemble and save the current URL string.
SetCurrentURL((const char *) lpszDomain,(const char *) lpszDocument,
bSecure);
//concatenate document and querystring for HttpOpenRequest
CComBSTR sResource;
sResource.Empty();
sResource.AppendBSTR(sDocument);
sResource.AppendBSTR(sQueryString);
char * lpszResource = _com_util::ConvertBSTRToString(sResource.m_str);
if(split(lpszAccept,',',&lplpszAccepts,&uiRows))
{
//convert "Accepts:" string array to a constant pointer for API.
hRequest =
HttpOpenRequest(hSession,"GET",lpszResource,"HTTP/1.1","",(const char**)
lplpszAccepts,INTERNET_FLAG_PRAGMA_NOCACHE,(DWORD) this);
if(hRequest != NULL)
{
bRequestSent = HttpSendRequest(hRequest,0,0,0,0);
if(bRequestSent)
{
freearray(lplpszAccepts,uiRows);
return S_OK;
}
else strcat(sError,"Unable to send request.\r\n");
}
else strcat(sError,"Unable to open request.\r\n");
dwErrorNum = GetLastError();
strcat(sError,InetErrorDesc(dwErrorNum));
}
else
{
dwErrorNum = 0xE0000002;
strcat(sError,"Insufficient memory to complete requested operation.");
}
freearray(lplpszAccepts,uiRows);
return Error(sError,GUID_NULL,dwErrorNum);
}
I'm probably missing something simple here about how to unload a COM DLL
properly. Any help will be greatly appreciated.
Thanks,
Ben
- Next message: Alexander Nickolov: "Re: Is this consider as the reentrancy problem?"
- Previous message: Alexander Nickolov: "Re: HOWTO set up minimal sink object in console COM client?"
- Next in thread: Brian Muth: "Re: ATL component freezes after destructor"
- Reply: Brian Muth: "Re: ATL component freezes after destructor"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|