Please do not multipost. Answered in
microsoft.public.platformsdk.internet.server.isapi-dev
Basically, this filter is making incorrect assumptions and causing IIS
hangs.
--
//David
IIS
http://blogs.msdn.com/David.Wang
This posting is provided "AS IS" with no warranties, and confers no rights.
//
<gvrajkumar.TakeThisOut@gmail.com> wrote in message
news:1106565227.737370.206220@c13g2000cwb.googlegroups.com...
I have an ISAPI filter configured on an IIS server. The filter seems to
have a problem when it returns a 403(forbidden) on very large requests
(load 1MB post). Around the 43rd request the IIS stops responding to
the requests. There is no problem when the same 403 is returned on
smaller requests ( 5KB post, 30,000 requests). The same code(load 1MB
post OR 5KB pst, 30,000) works perfectly if the request goes through
with a 200. I have checked the code thoroughly for any memory leaks but
I cannot find any. Please find the code below. Any help would be
greatly appreciated.
#include <windows.h>
#include <httpfilt.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
typedef struct
{
char client_ip[20];
int processed; //Flag that tells if the request has been
processed so far or not
char data_request[3];
char * tmpCindata;
} request_Content;
BOOL WINAPI GetFilterVersion( PHTTP_FILTER_VERSION pVer )
{
pVer->dwFlags = SF_NOTIFY_ORDER_HIGH;
pVer->dwFilterVersion = MAKELONG( 0, 1 );
// Clear the flags set by base class
pVer->dwFlags &= ~SF_NOTIFY_ORDER_MASK;
strncpy(pVer->lpszFilterDesc, "******************",
SF_MAX_FILTER_DESC_LEN);
/* Ask to be notified at the authentication stage of every HTTP
request */
pVer->dwFlags = SF_NOTIFY_ORDER_HIGH |
SF_NOTIFY_READ_RAW_DATA | SF_NOTIFY_END_OF_REQUEST ;
return TRUE;
}
DWORD WINAPI HttpFilterProc( PHTTP_FILTER_CONTEXT pCtxt, DWORD
notificationType, LPVOID pvNotification )
{
request_Content *reqContent ; //Creates a request_Content structure
variable (one for each request)
//WriteEventLogEntry(portfrom,'4');
if(notificationType == SF_NOTIFY_READ_RAW_DATA)
{
PHTTP_FILTER_RAW_DATA pRawData = (PHTTP_FILTER_RAW_DATA)
pvNotification;
//define the structure for the hashmap for encoding...
//struct tmpdata tmpCin;
reqContent = (request_Content *) pCtxt->pFilterContext;
if (reqContent == NULL) //Initialize
{
reqContent = (request_Content *) malloc(sizeof(request_Content));
reqContent->processed = 0;
memset(reqContent->data_request, '\0',
strlen(reqContent->data_request));
// get the client IP
sprintf(reqContent->client_ip, "0");
DWORD dword1 = 20;
pCtxt->GetServerVariable(pCtxt, "REMOTE_HOST", reqContent->client_ip,
&dword1);
if(strstr(reqContent->client_ip,".") == NULL)
{sprintf(reqContent->client_ip, "0.0.0.0");}
pCtxt->pFilterContext = reqContent;
}
if((reqContent->processed > 0) || ((strstr((char
*)pRawData->pvInData,"\r\n\r\n")) != NULL))
{
reqContent->processed+=1;
if(strstr((char *)pRawData->pvInData,"</soap:Envelope>") != NULL)
{
//found the whole request body
//some process on the body content if not valid give 403 FORBIDDEN
pCtxt->ServerSupportFunction ( pCtxt,
SF_REQ_SEND_RESPONSE_HEADER,(LPVOID) "403 FORBIDEN",(DWORD)NULL,0 );
free(reqContent);
return SF_STATUS_REQ_FINISHED_KEEP_CONN;
}
else
{
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
else if(notificationType == SF_NOTIFY_END_OF_REQUEST)
{
//reqContent = (request_Content *) pCtxt->pFilterContext;
free(reqContent);
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
else
{
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
Venkat