Apache 2.2: Partial results are valid but processing is incomplete, unable to stat file (X-Sendfile)
Error Message:
(70008) Partial results are valid but processing is incomplete: xsendfile: unable to stat file: //server_name/folder/file
I deployed my code to our development box over the weekend which uses the X-Sendfile module for Apache to serve files but ran into this issue when I tried to download a file. The X-Sendfile module worked fine on my local machine. The only difference I could find was our development box was running Windows XP 64-bit and I'm running 32-bit (this is why it's a good idea to try to have the machines in all your environments to be identical, VMs are great for this).
I couldn't find a solution for my exact problem so I decided to check out the source code and searched for the error message “unable to stat file":
/* stat (for etag/cache/content-length stuff) */ if ((rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd)) != APR_SUCCESS) { ap_log_rerror( APLOG_MARK, APLOG_ERR, rv, r, "xsendfile: unable to stat file: %s", translated ); apr_file_close(fd); ap_remove_output_filter(f); ap_die(HTTP_FORBIDDEN, r); return HTTP_FORBIDDEN; }
It appears that the apr_file_info_get() function was not returning APR_SUCCESS on our development box for some reason. I did some research on that function and found an old article that mentions something about one of the arguments may be beyond the OS file system support and would always return APR_INCOMPLETE (http://dev.ariel-networks.com/apr/apr-tutorial/html/apr-tutorial-5.html).
I put a quick fix/hack to make it work in our environment by simply checking for both APR_SUCCESS and APR_INCOMPLETE and only throw the error when the status is neither of those.
I simply changed:
if ((rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd)) != APR_SUCCESS)
to
if ((rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd)) != APR_SUCCESS && (rv = apr_file_info_get(&finfo, APR_FINFO_NORM, fd)) != APR_INCOMPLETE)
I then did a compile/build on Windows (this is another story), redeployed the module, and it finally worked! I also checked the MD5 and SHA-1 hashes of a couple of files served through mod_xsendfile just to make sure it's working properly and they matched the original hashes.
You can download the source and the .so file (if you trust me enough :)) with the fix from here.
Tags: tech, software development