On 11/08/11 02:10, Alex Rousskov wrote:
> On 08/09/2011 06:34 PM, Amos Jeffries wrote:
>> On Tue, 09 Aug 2011 12:56:09 -0600, Alex Rousskov wrote:
>>> On 08/09/2011 02:13 AM, Kinkie wrote:
>>>>> ./cf_gen cf.data ../../src/cf.data.depend
>>>>> error while opening input file 'cf.data': Unknown error: 0
>>>>
>>>> Now this puzzles me.
>>>> ifstream fp.bad() reports badbits set, but errno is OK. On FreeBSD
>>>> 6.4 only.
>>>
>>> Perhaps the errno is reset by subsequent system calls? How close is your
>>> bad() detection to the errno use?
>>>
>>
>> The code in question is:
>>
>>      fp.open(type_depend, std::ifstream::in);
>>      if (fp.fail()) {
>>          std::cerr<<  "error while opening type dependencies file '"<<
>>                    input_filename<<  "': "<<  strerror(errno)<<  std::endl;
>>          exit(1);
>>      }
>
> Does rewriting the above to preserve errno (as in the sketch below) help?
>
>      fp.open(...);
>      if (!fp) {
>          const int savedErrno = errno;
>          std::cerr<<  "error: "<<  strerror(errno)<<  std::endl;
>      }
>
> Cheers,
>
> Alex.
Neither of those worked in any combination.
But....
   looking at the snippet I see type_depends being opened and 
input_filename being reported. So fix that typo and look for 
input_filename being opened.
  ... which shows that fp is re-used between the two files.
Adding fp.clear() to reset the flags (including EOF?) after the 
fp.close() solves it.
Amos
-- Please be using Current Stable Squid 2.7.STABLE9 or 3.1.14 Beta testers wanted for 3.2.0.10Received on Wed Aug 10 2011 - 14:42:58 MDT
This archive was generated by hypermail 2.2.0 : Wed Aug 10 2011 - 12:00:03 MDT