apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject how to test for a valid apr_file_info_t and valid apr_file_t filehandle?
Date Sat, 15 Nov 2003 21:00:45 GMT
In apache 1.3 one could check whether a r->finfo is already opened by checking 
whether r->finfo.filehand is non-NULL. However with ap2/apr, r->finfo could be 
unitilialized and containing random garbage.

1) What's the correct way to check that a given apr_file_info_t was populated 
via stat and doesn't contain random garbage. I suppose I could query some bits 
of apr_file_info_get(), but since all struct members aren't simple types they 
could all contain garbage when uninitilized. Why there is no function that 
does this testing for me? there is some mentioning of testing the protection 
bit, to see whether the file exists? I suppose that this is a suggestion for 
what I want? If so, can we have an API apr_file_info_is_valid(), so that if in 
the future this protection bit changes our code will still work.

2) Assuming that I have an API that answers to (1), how do I know that 
finfo.filehand is a valid filehandle? It's possible that apr_file_info_t is 
valid after calling stat, but filehand may still contain a garbase. I see that 
implementations have a bit ->isopen in apr_file_t, but there is no API to test 
that bit.

FWIW, here is a dump of r->finfo during one of the executions reported by one 
of the users... it looks like it was stat'ed but filehand is bogus.

$2 = {pool = 0x819fe80, valid = 7598448, protection = 1877,
   filetype = APR_REG, user = 48, group = 48, inode = 410325, device = 774,
   nlink = 1, size = 7123, csize = 1077577583, atime = 1068909622000000,
   mtime = 1027905783000000, ctime = 1068307947000000,
   fname = 0x81a1818 "/usr/local/lxr/source", name = 0x0, filehand = 0x1}


Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

View raw message