1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

tests: avoid loop on older system

Cleanup overload of 'push'.
Don't busy-loop when reading is finished.
This commit is contained in:
Zdenek Kabelac 2015-03-12 00:07:45 +01:00
parent 26f5ec0e98
commit eded54df7b

View File

@ -463,6 +463,19 @@ struct Source {
char buf[ 128 * 1024 ];
if ( (sz = read(fd, buf, sizeof(buf) - 1)) > 0 )
sink->push( std::string( buf, sz ) );
/*
* On RHEL5 box this code busy-loops here, while
* parent process no longer writes anything.
*
* Unclear why 'select()' is anouncing available
* data, while we read 0 bytes with errno == 0.
*
* Temporarily resolved with usleep() instead of loop.
*/
if (!sz && (!errno || errno == EINTR))
usleep(50000);
if ( sz < 0 && errno != EAGAIN )
throw syserr( "reading pipe" );
}
@ -625,11 +638,11 @@ struct IO : Sink {
return *new (this) IO( io );
}
void clear(int push = 1) {
void clear( int to_push = 1 ) {
for ( Sinks::iterator i = sinks.begin(); i != sinks.end(); ++i )
delete *i;
sinks.clear();
if (push)
if ( to_push )
sinks.push_back( _observer = new Observer );
}