updated: August 31 2011 to include the call to SendError. Requires 5.34 or later.
a) create a global mem variable, a LONG, unthreaded, called say ThreadsCount
b) In WebHandler, before the line;
p_web.ProcessRequest(p_ReqString)
add
p_web._wait()
ThreadsCount += 1
p_web._release()
and after the call to
p_web.ProcessRequest(p_ReqString)
put
p_web._wait()
ThreadsCount -= 1
p_web._release()
c) In WebServer procedure, StartNewThread method, after loc:RequestData :=: p_RequestData
If ThreadsCount >= x
self.SendError(500,'Server Busy','Server Busy, try again shortly')
Return
End
The value you use for x will depend on the memory usage of each thread. And the only real way to know how high it can go is to monitor the value under load, and see at what point the server dies.
As a debugging tool you could write out the value to DebugView, or perhaps write it away to an Ini file or something here.
Cheers
Bruce