saved_errno
Jeremy Allison
jallison at cthulhu.engr.sgi.com
Mon Nov 1 18:29:33 GMT 1999
Andrew Tridgell wrote:
>
> Jeremy,
>
> What is the logic behind saved_errno in filename.c??
>
> To me it seems totally spurious, and if you set "case sensitive = yes"
> then the saved_errno code slows down directory reads by a factor of
> about 20 in tests I've done (test with 10000 files took 400 seconds
> with code as is and 20 seconds after removing the saved_errno test in
> unix_convert())
>
> I don't see what else saved_errno will be set to other than ENOENT and
> I don't see why we should do the search just because it was a
> ENOENT.
>
> I'll take the test out for the moment - I'm sure it's not correct.
Actually, saved_errno as a variable wasn't needed (it was paranoid code
as I was assuming the debug statement might trash errno), however
the test itself seemed useful and was meant as an optimisation
(although I might have got the logic swapped...).
The original code went :
if (dos_stat(name,&st) == 0) {
...found name...
}
/*
* A special case - if we don't have any mangling chars and are case
* sensitive then searching won't help.
*/
if (case_sensitive && !is_mangled(name) &&
!lp_strip_dot() && !use_mangled_map && (saved_errno != ENOENT))
return(False);
Ah - now I see the problem. I got the logic on the test wrong
on the case sensitive test. What I *should* have written was
if (case_sensitive && !is_mangled(name) &&
!lp_strip_dot() && !use_mangled_map && (saved_errno == ENOENT))
return(False);
Note the != to == change. Rats :-(. Of course the test
itself was totally bogus anyway, as even if the error was
other than ENOENT we should have been returning at that
point anyway !
Sorry, logic bug. I'll commit it to the release tree.
Jeremy.
--
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------
More information about the samba-technical
mailing list