CGI Hung Process Help!
Dave Cragg
dave.cragg at lacscentre.co.uk
Sun May 6 04:44:10 EDT 2007
On 5 May 2007, at 23:09, Sivakatirswami wrote:
>
> repeat until length(PostIn) >= $CONTENT_LENGTH
> read from stdin until ""
> put it after PostIn
> end repeat
>
I'd suspect this part. I used to use this approach, but ran into
trouble after moving some scripts to a new server. If something
happens to stall the connection during the read process, you'll be in
an endless loop, possibly with high CPU usage.
I've started using something like this. It puts a limit on how many
"empty reads" happen before bailing out. (I copied this quickly, and
modified slightly to remove some application specific code. Check
before using.):
local sPostdata = ""
local sDataRead = false
local sReadCount = 0
local sEmptyReadCount = 0
local sEmptyReadLimit = 200
local sShortRead = false
on startup
readData
repeat while sDataRead = false
wait for messages
end repeat
if sShortRead then
## exit routine needed here
end if
## carry on
end startup
on readData
read from stdin for $CONTENT_LENGTH
put it into tTemp
add 1 to sReadCount
if tTemp <> empty then
put tTemp after sPostdata
else
add 1 to sEmptyReadCount
end if
if length(sPostdata) < $CONTENT_LENGTH then
if sEmptyReadCount < sEmptyReadLimit then
send readData to me in 50 milliseconds
else
put true into sDataRead
put true into sShortRead
end if
else
put true into sDataRead
end if
end readData
More information about the use-livecode
mailing list