Merging upstream version 0.12.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
8a1b7bb819
commit
fae36bf8d8
18 changed files with 427 additions and 212 deletions
16
list_lz.cc
16
list_lz.cc
|
@ -605,7 +605,7 @@ done:
|
|||
|
||||
/* Get from courier the processed and sorted packets, and print
|
||||
the member lines on stdout or the diagnostics on stderr. */
|
||||
bool muxer( Packet_courier & courier )
|
||||
void muxer( Packet_courier & courier )
|
||||
{
|
||||
while( true )
|
||||
{
|
||||
|
@ -613,15 +613,14 @@ bool muxer( Packet_courier & courier )
|
|||
if( !opacket ) break; // queue is empty. all workers exited
|
||||
|
||||
if( opacket->status == Packet::error )
|
||||
{ show_error( opacket->line.c_str() ); return false; }
|
||||
{ show_error( opacket->line.c_str() ); cleanup_and_fail( 2 ); }
|
||||
if( opacket->line.size() )
|
||||
{ std::fputs( opacket->line.c_str(), stdout );
|
||||
std::fflush( stdout ); }
|
||||
delete opacket;
|
||||
}
|
||||
if( !courier.mastership_granted() ) // no worker found EOF blocks
|
||||
{ show_error( "Archive ends unexpectedly." ); return false; }
|
||||
return true;
|
||||
{ show_error( "Archive ends unexpectedly." ); cleanup_and_fail( 2 ); }
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -634,6 +633,9 @@ int list_lz( const Arg_parser & parser, std::vector< char > & name_pending,
|
|||
const bool missing_crc, const bool permissive )
|
||||
{
|
||||
const int out_slots = 65536; // max small files (<=512B) in 64 MiB
|
||||
|
||||
/* If an error happens after any threads have been started, exit must be
|
||||
called before courier goes out of scope. */
|
||||
Packet_courier courier( num_workers, out_slots );
|
||||
|
||||
Worker_arg * worker_args = new( std::nothrow ) Worker_arg[num_workers];
|
||||
|
@ -654,16 +656,16 @@ int list_lz( const Arg_parser & parser, std::vector< char > & name_pending,
|
|||
const int errcode =
|
||||
pthread_create( &worker_threads[i], 0, tworker, &worker_args[i] );
|
||||
if( errcode )
|
||||
{ show_error( "Can't create worker threads", errcode ); return 1; }
|
||||
{ show_error( "Can't create worker threads", errcode ); cleanup_and_fail(); }
|
||||
}
|
||||
|
||||
if( !muxer( courier ) ) return 2;
|
||||
muxer( courier );
|
||||
|
||||
for( int i = num_workers - 1; i >= 0; --i )
|
||||
{
|
||||
const int errcode = pthread_join( worker_threads[i], 0 );
|
||||
if( errcode )
|
||||
{ show_error( "Can't join worker threads", errcode ); return 1; }
|
||||
{ show_error( "Can't join worker threads", errcode ); cleanup_and_fail(); }
|
||||
}
|
||||
delete[] worker_threads;
|
||||
delete[] worker_args;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue