[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Isapi-question
Wigle Post schrieb:
>
> Hi to all,
>
> I would like a ISAPI-Module I wrote to:
> - receive a request
> - send a response
> - then continue processing the request
>
> I would just like to acknowledge the receipt of the request - in casu the
> printing of a report, which takes a little time in processing - and I would
> like to prevent users to keep repeating the request because it takes more
> than two seconds before they get an answer.
>
> I wonder if there is any chance that the isapi-dll is killed by the server
> because the server has received a response.
>
> If not, would this be true for any server? Will Windows prevent any dll to
> be killed when it is still processing code?
>
> Thanks in advance.
> Wigle.
Hi again,
I see 2 doubts in your questions:
1.) What happens with my extension procedure if Pi3Web's ISAPI handler
calls FreeLibrary and my DLL is still in processing something?
2.) What happens with my response data? I write some data but the
transmission is made some moments later when my extension is closed.
My considerations:
1.)
Here's some info about Pi3's ISAPI-Handler structure:
method Handle of the ISAPI Handler object
|
Load Client DLL
DoISAPI--------+ * = ISAPI handler calls Client DLL
Unload Client DLL |
|
GetExtensionVersion *
RunISAPI--------+
TerminateExtension * |
|
HttpExtensionProc *
GetServerVariable |
WriteClient /____________|
ReadClient \ Callbacks into ISAPI handler DLL
ServerSupportFunction
You see - the client DLL is unloaded when your extension has made all its
stuff except you make some asynchronous actions (i.e. PostMessage,
CreateProcess calls or creating threads) from within it. You could
synchronize processes/threads with Win32 API function WaitForSingleObject.
(i.e. Your extension DLL is calling another program and should wait
until it's finished). I think you must distinguish here between old Windows
API and Win32 thread based things. Normally you must not be worried about
your extension DLL to be unloaded. If you make all your stuff from within
HTTPExtensionProc and you wait until settlement before leaving this procedure.
2.)
Even if you send the begin of a response by calling ServerSupportFunction/
WriteClient before your extension function is doing the main stuff
- the behave of the server is not your thing. You write into a buffer and
the server queues data to a socket.
2 ways I suggest to solve it in a common way:
1.)
If the report is a large one write the response data continual with
multiple calls to WriteClient instead of writing the whole data into
one buffer and to call the ServerSupportFunction with it.
- the user will see the first part of the response during the extension
is still producing the rest of the response. I tried this and it worked.
2.)
Let your extension DLL recognize and handle 2 phases - 'acknowledge'
when it's called the 1st and 'response' when it's called the 2nd time.
Your form to send the origin request:
<HTML>
<FORM METHOD=POST ACTION="http://myhost/isapi/ext.dll"
<INPUT name="Data">
<INPUT type=hidden name="Phase" value="acknowledge">
<INPUT type="submit">
</FORM>
</HTML>
I think it must work to send an answer in the acknowledgement phase in
the kind of a browser redirection from within you extension DLL:
<HTML>
<HEAD>
<meta http-equiv="refresh"
content="1;URL=http://myhost/isapi/ext.dll?data=blabla&phase=response">
</HEAD>
<BODY>
Wait a second before the response will be sent to you.<BR>
Click <A HREF="http://myhost/isapi/ext.dll?Data=blabla&Phase=response">here</A>
if your browser don't support redirection.
</BODY>
</HTML>
If the extension receives this 2nd call it must send the response data.
discussion:
- The request data is to read from STDIN during the 1st and from server
environment variable 'QUERY_STRING' during the 2nd phase.
- It is also possible to use 2 independent extension DLL's and to do
without the phase.
- The time between the 2 required requests is unused.
Maybe the HTTP protocol or the Pi3API will show you better ways to do it.
But I don't know this at the present time.
--
with regards
Holger
---------------------------------------------------------
Holger 'Zimpel' Zimmermann Contact me:
---------------------------------------------------------
Wendishain tel./fax company: on demand
Germany tel./fax private: on demand
---------------------------------------------------------
homepage: http://home.t-online.de/home/zimpel@t-online.de
web server: surf to it from my homepage (online every
Sunday 20:00-24:00 GMT, start 1. Jule 1998)
e-Mail: zimpel@t-online.de
--------------------------------------------------------