Re: IIS with ISAPI filter does not respond on load testing

From: David Wang [Msft] (someone_at_online.microsoft.com)
Date: 01/24/05


Date: Mon, 24 Jan 2005 13:53:47 -0800

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@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


Relevant Pages

  • Re: IIS Extensions in URL causes filter to break.
    ... If your filter operates the way you say, ... IIS can only say that one or more of the events contain ... every request, and maybe more than once, depending on whether the URL causes ... As for the order of handling between ISAPI Extensions and Filters - Filters ...
    (microsoft.public.inetserver.iis.security)
  • Re: IIS Extensions in URL causes filter to break.
    ... I delete all cached files at the browser to ensure that the browser ... I confirmed using NetMon on IIS server that the static HTML is ... What my filter does exactly? ... It filters every incoming request looking for "mystring" inside it. ...
    (microsoft.public.inetserver.iis.security)
  • Re: pszPhysicalPath not working with directory request on IIS 6
    ... >multiple times for a given request? ... >404 because you didn't modify pszPhysicalPath correctly. ... and a proper ISAPI Filter must handle ... >I have an ISAPI filter that hooks into IIS which has ...
    (microsoft.public.inetserver.misc)
  • Re: pszPhysicalPath not working with directory request on IIS 6
    ... How does your filter deal with the fact that SF_NOTIFY_URL_MAP fires ... pszPhysicalPath in SF_NOTIFY_URL_MAP event only once per request. ... need to modify since that is what IIS is going to execute. ...
    (microsoft.public.inetserver.misc)
  • Re: Page Cannot Be Displayed Errors
    ... In WFetch, for Advanced Request, change to "Add Headers" and write: ... > directly on the web server, ... >>> Where can I get the IIS 6.0 Resource Kit, and how do I use WFetch? ...
    (microsoft.public.inetserver.iis)

Quantcast