[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ISAPI Extension
Just wrote an ISAPI Extension for MzScheme but I'm having some difficulties.
The web server I'm using Aphache on Winnt 4.0
Problems:
1. Apache seems to run two processes and the one that you start is not the
one that loads the ISAPI dll.
this makes it a problem to debug my code.
2. Whenever Scheme has an error, the error is reported to the log file *and*
Apache crashes. msdev did catch
this one it's in eval.c
3. Here's a snippet:
// begin snippet
BOOL WINAPI GetExtensionVersion( HSE_VERSION_INFO *ver )
{
// Get an environment
Scheme_Env *env = scheme_basic_env();
sch_xcb_type=scheme_make_type("<extension-control-block");
// Register the C globals with the GC.
// No globals
// Add new primitives to the environment
scheme_add_global("write-client",
scheme_make_prim_w_arity(sch_WriteClient,
"write-client",
3,
3),
env);
scheme_add_global("extension-control-block?",
scheme_make_prim_w_arity(xcb_pred,
"extension-control-block?",
1,
1),
env);
scheme_add_global("message-box",
scheme_make_prim_w_arity(sch_msgbox,
"message-box",
1,
1),
env);
ver->dwExtensionVersion = HSE_VERSION_MAJOR;
ver->dwExtensionVersion = ( ver->dwExtensionVersion << 16 ) |
HSE_VERSION_MINOR;
sprintf( ver->lpszExtensionDesc, "%s", "This is a Sample Extension
DLL by Process Software Corp" );
return TRUE;
}
DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *c)
{
unsigned long k;
c->ServerSupportFunction(c->ConnID,
HSE_REQ_SEND_RESPONSE_HEADER,
0,
0,
&k);
sch_xcb *xcb = (sch_xcb *)scheme_malloc(sizeof(sch_xcb));
xcb->type = sch_xcb_type;
xcb->xcb = c;
scheme_apply(scheme_load("MzISAPI.ss"), 1, (Scheme_Object **)&xcb);
\\<---- Exhibit A
return 1;
}
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID ptr ){return
TRUE;}
// end snippet
I'm not sure where I should put the Scheme init stuff.
I originally had it in the HttpExtensionProc but I thought that it might get
called more than once,
(which I suppose is a bad thing) so I stuck it in the GetExtensionVersion
hoping that that my cure
some of my pains. Is there a better place to put it? Might Windows honor
some standard export that gets
called only when the *any* dll is initially loaded? (Don't know too much
about dlls)
4. Direct your attention to "Exhibit A" in the above code. Here I have it
hardcoded to load a file called
"MzISAPI.ss" The result of which should be a scheme proc that gets applied
to an extension control block.
The catch is that if you don't have MzISAPI.ss in the right directory, you
get a scheme error and a subsequent
crash. Bummer. This is seems like a bad way to do it. Anyone got a better
idea?
5. My little ISAPI extension is *intermittently* crashing. I suppose I'll
just have to sweat it out and find out why.
Anyone wanna help?
6. Everytime I use this thing, I get the following error in the Log file:
[Fri Mar 03 20:55:13 2000] [error] [client 10.0.1.191] (2)No such file or
directory: ISA sent invalid headers
The client number is the same one I had when scheme was giving errors, but
now the damn thing is working i.e. I'm getting the
expected output in the browser. Somebody isn't finding a file, and I don't
think it is mzscheme but I don't know why Apache
would be looking for a file either. Anybody spent anytime writing ISAPI
extensions for Apache on Winnt?
Here's MzISAPI.ss for reference:
(lambda (x)
(write-client "Hello World!" 'hse-io-sync x))