I have some strange errors when more than 1 client is rendering the page at
a time. It's some kind of problem with threads + ActiveScripting interface
(error occurs when two threads are executing JScript at exact one moment).
It is very easy to reproduce:
1. Build Apache DSO WebSnap app - just from the wizard
2. Put a script which takes a lot of time to render
example:
<html>
<body>
<% for (i = 0; i < 10000; i++)
Response.Write(i);
%>
</body>
</html>
3. Write a static page like this:
<HTML>
<FRAMESET ROWS="10%, 10%, 10%, 10%, 60%">
<FRAME src="page's URL here">
<FRAME src="page's URL here">
<FRAME src="page's URL here">
<FRAME src="page's URL here">
<FRAME src="page's URL here">
</FRAMESET>
</HTML>
When you display the frameset 5 copies of the page are rendered at a time.
The result is that one or more pages display a random error message like:
"List index out of bounds"
"Wrong number of parameters for WriteItem" etc.
The number of error pages increases on two-processor machine so thread
concurrency must be involved in this issue.
The error occurs whenever you access scripting objects from within the
script. If the page doesn't contain any references to scripting objects
there is no error.
The only scripting object which looks "safe" is WebSnap inner HTML_ object
used for html content rendering. Even read of properties like
Application.Title inside loop causes random errors.
The only solution I've made so far is rendering the pages in critical
section - so no more than one thread can render a page at a time, but I
worry about the performance. I won't take advantage from my two-processor
server any more :(
Any ideas ? Clues ? Solutions ?
After many hours of websnap debugging I'm desperate.
Hope for help
Paweł Kowalik
i also had a problem with the "script engine"
i was using CoInitialize();
i replaced it with
CoInitializeEx(nil,COINIT_MULTITHREADED);
(not sure if this help's)
robert
"Paulo" <p.ko...@gazeta.pl> schrieb im Newsbeitrag
news:3f45ebfa$1...@newsgroups.borland.com...
Użytkownik "Robert" <rob...@nospam.com> napisał w wiadomości
news:3f49...@newsgroups.borland.com...
i have tested this (the static page with the frameset...)
and i am getting the same "random" errors
i also think that there is a big problem when using websnap with an COM
interface to an activeX server
(with CoInitializeEx()... and so on)
hello borland-people: any idea how to connect to an ActiveX server when
using websnap ??? (i think this is the main problem ???)
robert
"Paulo" <p.ko...@gazeta.pl> schrieb im Newsbeitrag
news:3f45ebfa$1...@newsgroups.borland.com...
> hi
>
> i have tested this (the static page with the frameset...)
> and i am getting the same "random" errors
>
> i also think that there is a big problem when using websnap with an
> COM interface to an activeX server
> (with CoInitializeEx()... and so on)
>
> hello borland-people: any idea how to connect to an ActiveX server
> when using websnap ??? (i think this is the main problem ???)
>
> robert
>
Robert,
I am not using Apache, so my findings might not work the same. I am,
however, using IIS/ISAPI and also accessing multiple ActiveX servers
from various vendors and had to do the following to get it to work:
1) Add as the first unit in the library "COMINIT" which looks like the
following:
unit cominit;
interface
uses
ActiveX;
implementation
initialization
CoInitializeEx(nil,COINIT_MULTITHREADED);
finalization
CoUninitialize;
end.
2) On your TWebAppPageModule, add
CoInitializeEx(Nil,COINIT_MULTITHREADED) to the OnActivate event and
CoUninitialize to the OnDeactivate event.
This corrected the problems I was having with random access violations
when running under idDebugger/idRunner/IIS. Each "server" was behaving
differently before, but now they are all consistant.
.
.
var CS:TRTLCriticalSection;
function DefaultHandler(r: Prequest_rec): Integer; cdecl;
var
RequestedHandler: string;
begin
EnterCriticalSection(CS);
try
RequestedHandler := r^.handler;
if SameText(RequestedHandler, Handler) then
Result := (Application as TApacheTwoApplication).ProcessRequest(r^)
else
Result := DECLINED;
finally
LeaveCriticalSection(CS);
end;
end;
procedure RegisterHooks(p: Papr_pool_t); cdecl;
begin
EnterCriticalSection(CS);
try
ap_hook_handler(DefaultHandler, nil, nil, APR_HOOK_MIDDLE);
if Assigned(OnRegisterHooks) then
OnRegisterHooks(p);
finally
LeaveCriticalSection(CS);
end;
end;
.
.
.
.
initialization
InitializeCriticalSection(CS);
InitApplication;
finalization
DeleteCriticalSection(CS);
end.
Pavel Zedník
"Steven Kamradt" <ste...@resource-dynamics.com> píše v diskusním poíspivku
news:3f4b773e$1...@newsgroups.borland.com...
Pavel
"Pavel" <pavel....@seznam.cz> píše v diskusním příspěvku
news:3fa9...@newsgroups.borland.com...
Regards
Pawel Kowalik
Użytkownik Pavel napisał:
> We have tried to solve this problem with CoInitializeEx, but on my 2 CPU PC
> (win2k, D7) websnap with apache still generate "random" error. The problem
> was removed with addition critical section in ApacheTwoApp unit and using
> CoInitializeEx. Her is code.
> unit ApacheTwoApp;
>
> ..
>
> ..
> ..
>
> ..