Why doesn't a request with an infinite loop get killed by ColdFusion request timeout?

前端 未结 3 831
日久生厌
日久生厌 2020-12-18 04:44

First, I set Timeout Requests after (seconds) to 20 in CF Admin.

Then I run a cfm with a line like while(true);

The page will run w

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 05:37

    Request timeouts in ColdFuison don't behave in the way you expect. They way it's presented you'd imagine that there's a watchdog which checks how long your request has been running and kills it on or shortly after the request timeout. What actually appears to happen is that only when certain tags are run does CF check whether the elapsed time of the request is over the set limit. is one of the tags where it checks, which is why you often see the timeout exceeded message pointing to a cfoutput, even though you know it can't be taking long to execute.

    
    
    
    
    
        
        
    
        
    
        
            
        
    
    
    
    
    
        
    
    
    
    
        
        Hello
    
    
    
    
    
    for(foo=1;foo<=8;foo++){
        sleep(1000);
    }
    
    
    
    
    for(foo=1;foo<=8;foo++){
        sleep(1000);
        writeoutput("tick...");
    }
    
    

    The code above shows some of the odd behaviour of the requesttimeout. As Mark Kruger pointed out, any call to an external resource will mean no checking for timeout, and its my guess that large blocks of script which are just executing your own logic will also not be checked, leaving the next output statement to be blamed.

    If you need to trace where code is lagging and the timeout messages are pointing to the wrong place, I'd either use logging or jstack to grab stack traces from the server whilst the long-running code is running. Grab a few stack traces a few seconds apart, then run the log file through Samurai to find what the code is doing.

提交回复
热议问题