1
0
Fork 0

Merging upstream version 0.28.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-06-25 03:37:17 +02:00
parent 9c81793bca
commit ca8e65110f
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
26 changed files with 1067 additions and 716 deletions

View file

@ -21,13 +21,12 @@
#include <cerrno>
#include <cstdio>
#include <queue>
#include <stdint.h> // for lzlib.h
#include <unistd.h>
#include <sys/stat.h>
#include <ftw.h>
#include <lzlib.h>
#include "tarlz.h"
#include <lzlib.h> // uint8_t defined in tarlz.h
#include "arg_parser.h"
#include "common_mutex.h"
#include "create.h"
@ -42,42 +41,6 @@ Packet_courier * courierp = 0;
unsigned long long partial_data_size = 0; // size of current block
class Slot_tally
{
const int num_slots; // total slots
int num_free; // remaining free slots
pthread_mutex_t mutex;
pthread_cond_t slot_av; // slot available
Slot_tally( const Slot_tally & ); // declared as private
void operator=( const Slot_tally & ); // declared as private
public:
explicit Slot_tally( const int slots )
: num_slots( slots ), num_free( slots )
{ xinit_mutex( &mutex ); xinit_cond( &slot_av ); }
~Slot_tally() { xdestroy_cond( &slot_av ); xdestroy_mutex( &mutex ); }
bool all_free() { return num_free == num_slots; }
void get_slot() // wait for a free slot
{
xlock( &mutex );
while( num_free <= 0 ) xwait( &slot_av, &mutex );
--num_free;
xunlock( &mutex );
}
void leave_slot() // return a slot to the tally
{
xlock( &mutex );
if( ++num_free == 1 ) xsignal( &slot_av ); // num_free was 0
xunlock( &mutex );
}
};
struct Ipacket // filename, file size and headers
{
const long long file_size;
@ -260,8 +223,10 @@ int add_member_lz( const char * const filename, const struct stat *,
uint8_t * const header = extended ? new( std::nothrow ) Tar_header : 0;
if( !header )
{ show_error( mem_msg ); if( extended ) delete extended; return 1; }
if( !fill_headers( filename, *extended, header, file_size, flag ) )
{ delete[] header; delete extended; return 0; }
std::string estr;
if( !fill_headers( estr, filename, *extended, header, file_size, flag ) )
{ if( estr.size() ) std::fputs( estr.c_str(), stderr );
delete[] header; delete extended; return 0; }
print_removed_prefix( extended->removed_prefix );
if( gcl_opts->solidity == bsolid )
@ -446,10 +411,8 @@ extern "C" void * cworker( void * arg )
const int rd = readblock( infd, buf, size );
rest -= rd;
if( rd != size )
{
show_atpos_error( filename, ipacket->file_size - rest, false );
close( infd ); exit_fail_mt();
}
{ show_atpos_error( filename, ipacket->file_size - rest, false );
close( infd ); exit_fail_mt(); }
if( rest == 0 ) // last read
{
const int rem = ipacket->file_size % header_size;
@ -505,7 +468,7 @@ int encode_lz( const Cl_options & cl_opts, const char * const archive_namep,
{
const int in_slots = 65536; // max small files (<=512B) in 64 MiB
const int num_workers = cl_opts.num_workers;
const int total_in_slots = ( INT_MAX / num_workers >= in_slots ) ?
const int total_in_slots = (INT_MAX / num_workers >= in_slots) ?
num_workers * in_slots : INT_MAX;
const int dictionary_size = option_mapping[cl_opts.level].dictionary_size;
const int match_len_limit = option_mapping[cl_opts.level].match_len_limit;