Summary

simple-directory-handler: error 500 on listing a directory with a link foo -> foo

Metadata

Description

Here are the steps to reproduce the problem:

 $ cat server.scm 
 (use spiffy simple-directory-handler)
 
 (handle-directory simple-directory-handler)
 
 (start-server)
 
 $ mkdir web
 $ cd web
 $ ln -s foo foo
 $ cd ..
 $ csi -s server.scm &
 [1] 6379
 
 $ wget http://localhost:8080
 --2012-10-24 17:32:45--  http://localhost:8080/
 Resolving localhost... ::1, 127.0.0.1
 Connecting to localhost|::1|:8080... failed: Connection refused.
 Connecting to localhost|127.0.0.1|:8080... connected.
 HTTP request sent, awaiting response... [Wed Oct 24 17:32:45 2012] "GET http://localhost:8080/ HTTP/1.0" Error: (file-exists?)
 system error while trying to access file
 "./web//foo"
 
         Call history:
 
         display   
         spiffy#root-path          
         make-pathname     
         simple-directory-handler#simple-directory-dotfiles?       
         directory         
         sort      
         fold      
         spiffy#root-path          
         make-pathname     
         make-pathname     
         directory?        
         file-exists?      
         k695701   
         g699700   
         spiffy#handle-exception   
         with-output-to-string           <--
 
 
 500 Internal Server Error
 2012-10-24 17:32:45 ERROR 500: Internal Server Error.

The problem seems to be in simple-directory-handler's simple-directory-handler procedure, when it calls file-exists? in the fold body (around line 82).

The call to file-exists? seems to be due to the fact that (simple-directory-display-file) calls file-size and file-modification-time on the given file. That's actually subject to race conditions, so maybe it would be better to just handle exceptions in (simple-directory-display-file) when attempting those operations.

Changes and comments

[2012-10-27 13:59:12 UTC] sjamaan changed status from new to closed

[2012-10-27 13:59:12 UTC] sjamaan set resolution to fixed

[2012-10-27 13:59:12 UTC] sjamaan wrote:

Should be fixed in r27714. Thanks, Mario!