1
0
Fork 0

Don't remove the named pipe on a "Reset" or position change (i.e. when

FGExternalPipe is destructed.)  This leaves the name pipe hanging around
even after flightgear exits, but assuming we put the files in /tmp that
shouldn't be a big deal.
This commit is contained in:
curt 2003-03-03 17:48:09 +00:00
parent c8b8afeb78
commit 11e0a3b1f8

View file

@ -89,6 +89,8 @@ FGExternalPipe::FGExternalPipe( double dt, string name ) {
FGExternalPipe::~FGExternalPipe() {
delete [] buf;
SG_LOG( SG_IO, SG_INFO, "Closing up the ExternalPipe." );
#if defined( HAVE_SYS_TYPES_H ) && defined( HAVE_SYS_STAT_H )
// close
int result;
@ -102,18 +104,6 @@ FGExternalPipe::~FGExternalPipe() {
SG_LOG( SG_IO, SG_ALERT, "Unable to close named pipe: "
<< fifo_name_2 );
}
// remove the file system entry
result = unlink( fifo_name_1.c_str() );
if ( result == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "Unable to remove named pipe: "
<< fifo_name_1 );
}
result = unlink( fifo_name_2.c_str() );
if ( result == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "Unable to remove named pipe: "
<< fifo_name_2 );
}
#endif
}
@ -193,6 +183,8 @@ void FGExternalPipe::init() {
// Run an iteration of the EOM.
void FGExternalPipe::update( double dt ) {
#if defined( HAVE_SYS_TYPES_H ) && defined( HAVE_SYS_STAT_H )
// SG_LOG( SG_IO, SG_INFO, "Start FGExternalPipe::udpate()" );
int length;
int result;
@ -216,9 +208,8 @@ void FGExternalPipe::update( double dt ) {
SG_LOG( SG_IO, SG_ALERT, "Write error to named pipe: "
<< fifo_name_1 );
}
// cout << "wrote to pipe" << endl;
// cout << " wrote to pipe" << endl;
// Read next set of FDM data (blocking enabled to maintain 'sync')
length = sizeof(fdm);
result = std::read( pd2, (char *)(& fdm), length );
if ( result == -1 ) {
@ -227,5 +218,7 @@ void FGExternalPipe::update( double dt ) {
}
FGNetFDM2Props( &fdm, false );
// cout << "read from pipe" << endl;
// SG_LOG( SG_IO, SG_INFO, " End FGExternalPipe::udpate()" );
#endif
}