Discussion:
[omniORB] Logging Stream problem
Roger Wenham
2010-12-20 20:33:17 UTC
Permalink
Hi,

I have compiled omniORB on AIX 6.1 using gcc version 4.2.0, without problem.

Unfortunately when I start omniNames I get an error message:

$ ./omniNames -start

Mon Dec 20 22:04:45 2010:

Starting omniNames for the first time.
Error: cannot create initial log file '/tmp/omninames-tmxd12e.log':
No such file or directory

You can set the environment variable OMNINAMES_LOGDIR to specify the
directory where the log files are kept.

The problem is not with the file or permissions...

Chasing this back, the problem appears to be in the stream handling.

The code creates a stream, and then calls the method putPort which raises an exception,
which produces the above error message.

The uppercase OPEN mystifies me somewhat ...

....
logf.OPEN(active,ios::out|ios::trunc,0666);
if (!logf)
throw IOError();

putPort(port, logf);
...

void
omniNameslog:putPort(int p, ostream& file)
{
file << "port " << p << '\n';
if (!file) throw IOError();
}

class omniNameslog {
....
ofstream logf;

To me it seems that logf.OPEN(...) is not creating a stream, but its quite a while since I did any
serious c++ work.

I would be eternally thankful for any help or pointers....

Thanks in advance,

Roger
Martin B.
2010-12-21 13:21:31 UTC
Permalink
Post by Roger Wenham
Hi,
I have compiled omniORB on AIX 6.1 using gcc version 4.2.0, without problem.
$ ./omniNames -start
Starting omniNames for the first time.
No such file or directory
[...]
The code creates a stream, and then calls the method putPort which raises an exception,
which produces the above error message.
The uppercase OPEN mystifies me somewhat ...
omniNames/log.cc - (73)
#ifdef HAVE_STD
# define USE_STREAM_OPEN
# define OPEN(name,mode,perm) open(name,mode)
#elif defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x500
# define USE_STREAM_OPEN
# define OPEN(name,mode,perm) open(name,mode,perm)
#elif defined(__DMC__)
# define USE_STREAM_OPEN
# define OPEN(name,mode,perm) open(name,mode,perm)
#elif defined(__ICC)
# define USE_STREAM_OPEN
# define OPEN(name,mode,perm) open(name,mode,perm)
#endif

Uppercase OPEN is simply a macro, apparently mapping to .open() calls
with 2 or 3 parameters.
Post by Roger Wenham
....
logf.OPEN(active,ios::out|ios::trunc,0666);
if (!logf)
throw IOError();
putPort(port, logf);
...
void
omniNameslog:putPort(int p, ostream& file)
{
file<< "port "<< p<< '\n';
if (!file) throw IOError();
}
class omniNameslog {
....
ofstream logf;
Also, if the exception is actually raised from the putPort() function,
then the .open() call succeeded, but writing to the file somehow failed.

See also: http://www.cplusplus.com/reference/iostream/ofstream/

br,
Martin

Loading...