Operating System - HP-UX
1834604 Members
4383 Online
110069 Solutions
New Discussion

Re: problem with opening file in a process when system is loaded

 
Laurent Laperrousaz
Regular Advisor

problem with opening file in a process when system is loaded

hello,

We have a strange behaviour of the system:
it happens taht sometimes we get errno 2 (file not exist) when trying to read the configuration file of a process.
Still the file is present and I restart the process and it works ok.
It seems that this happens when the load is high (many processes running).

Here is the code:

TG_BUS::TG_BUS(byte1 *p1p_file, tg_idDic p2_idDic, byte4 p4_lMem)
{
const byte1* ka_funcName = "TG_BUS::TG_BUS";
m1p_bus = 0;
cout << ka_funcName << " p1p_file" << ":" << p1p_file << ":" << endl << flush ;
cout << ka_funcName << " errno avant" << ":" << errno << ":" << endl << flush ;

ifstream lc_file(p1p_file);

if (lc_file == NULL)
{
cout << ka_funcName << " errno" << ":" << errno << ":" << endl << flush ;
cout << ka_funcName << " !lc_file" << ":" << !lc_file << ":" << endl << flush ;
cout << ka_funcName << " lc_file .rdstate()" << ":" << lc_file.rdstate() << ":" << endl << flush ;
cout << ka_funcName << " ios_base::badbit" << ":" << ios_base::badbit << ":" << endl << flush ;
cout << ka_funcName << " ios_base::eofbit" << ":" << ios_base::eofbit << ":" << endl << flush ;
cout << ka_funcName << " ios_base::failbit" << ":" << ios_base::failbit << ":" << endl << flush ;
cout << ka_funcName << " ios_base::goodbit" << ":" << ios_base::goodbit << ":" << endl << flush ;

throw(TgExcepSys(p1p_file, ENOENT, 0));
// TG_ERROR("TG_BUS: fichier absent");
}

m4_lMem = max(p4_lMem,k4_busLHeader);

m1p_bus = new byte1[m4_lMem];
if (!m1p_bus)
{
m4_lMem = 0;
TgExcepSysExit("", ENOMEM, 0);
// TG_ERROR("plus de mem");
}

initHead(p2_idDic);


(*this) = TG_BUS(lc_file, p2_idDic, p4_lMem);
}
7 REPLIES 7
Robert-Jan Goossens
Honored Contributor

Re: problem with opening file in a process when system is loaded

Hi,

Could you check the syslog / dmesg if you get any error messages ?

Robert-Jan.
Steven Gillard_2
Honored Contributor

Re: problem with opening file in a process when system is loaded

I can see you're printing the value of errno earlier in the code, but I also see this which doesn't look right:

throw(TgExcepSys(p1p_file, ENOENT, 0));

Looks like you've hard-coded the error to ENOENT when perhaps its something else? Is the value of errno as printed by the above code actually set to 2?

Regards,
Steve
Laurent Laperrousaz
Regular Advisor

Re: problem with opening file in a process when system is loaded

Yes Steven, errno is set to 2...
Laurent Laperrousaz
Regular Advisor

Re: problem with opening file in a process when system is loaded

Yes Steven, errno is set to 2...

And I gave directives to check the syslog when it happens again
Laurent Laperrousaz
Regular Advisor

Re: problem with opening file in a process when system is loaded

when it happens, no related message appears in the syslog...
Steven Gillard_2
Honored Contributor

Re: problem with opening file in a process when system is loaded

My next steps at this point would be:

* Install the latest libc and C++ library patches
* If that doesn't help, try to replace the ifstream constructor call with standard C open() or fopen() calls. Once you're sure the open succeeded you can construct an ifstream object from the FILE*. The reason I suggest this is because its possible the C++ library is losing the value of errno through some other action - I don't think C++ guarantees that errno is every set correctly after a library call.

Regards,
Steve
Laurent Laperrousaz
Regular Advisor

Re: problem with opening file in a process when system is loaded

I change the ifstream constructor to start with the fd generated by "open" and it seems to work...
Unfortunately this constructor ifstream(int fd) is not available on other systems (like Linux, AIX) and it is now conditional code for HPUX.

It is to early to tell that the problem is really solved; I wait for production reaction and if it's fine I 'll give you 10 points Steven!
:-)

regards

Laurent