mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Make ucthreads part of the stream_info struct.
This commit is contained in:
parent
0d34833601
commit
a71f7bdb57
|
|
@ -468,6 +468,15 @@ struct rzip_control {
|
||||||
i64 (*match_len)(rzip_control *, struct rzip_state *, i64, i64, i64, i64 *);
|
i64 (*match_len)(rzip_control *, struct rzip_state *, i64, i64, i64, i64 *);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct uncomp_thread {
|
||||||
|
uchar *s_buf;
|
||||||
|
i64 u_len, c_len;
|
||||||
|
i64 last_head;
|
||||||
|
uchar c_type;
|
||||||
|
int busy;
|
||||||
|
int streamno;
|
||||||
|
};
|
||||||
|
|
||||||
struct stream {
|
struct stream {
|
||||||
i64 last_head;
|
i64 last_head;
|
||||||
uchar *buf;
|
uchar *buf;
|
||||||
|
|
@ -491,6 +500,7 @@ struct stream_info {
|
||||||
i64 total_read;
|
i64 total_read;
|
||||||
i64 ram_alloced;
|
i64 ram_alloced;
|
||||||
i64 size;
|
i64 size;
|
||||||
|
struct uncomp_thread *ucthreads;
|
||||||
long thread_no;
|
long thread_no;
|
||||||
long next_thread;
|
long next_thread;
|
||||||
int chunks;
|
int chunks;
|
||||||
|
|
|
||||||
40
stream.c
40
stream.c
|
|
@ -73,18 +73,10 @@ static struct compress_thread {
|
||||||
uchar salt[SALT_LEN];
|
uchar salt[SALT_LEN];
|
||||||
} *cthreads;
|
} *cthreads;
|
||||||
|
|
||||||
static struct uncomp_thread {
|
|
||||||
uchar *s_buf;
|
|
||||||
i64 u_len, c_len;
|
|
||||||
i64 last_head;
|
|
||||||
uchar c_type;
|
|
||||||
int busy;
|
|
||||||
int streamno;
|
|
||||||
} *ucthreads;
|
|
||||||
|
|
||||||
typedef struct stream_thread_struct {
|
typedef struct stream_thread_struct {
|
||||||
int i;
|
int i;
|
||||||
rzip_control *control;
|
rzip_control *control;
|
||||||
|
struct stream_info *sinfo;
|
||||||
} stream_thread_struct;
|
} stream_thread_struct;
|
||||||
|
|
||||||
static long output_thread;
|
static long output_thread;
|
||||||
|
|
@ -1059,6 +1051,7 @@ static bool decrypt_header(rzip_control *control, uchar *head, uchar *c_type,
|
||||||
/* prepare a set of n streams for reading on file descriptor f */
|
/* prepare a set of n streams for reading on file descriptor f */
|
||||||
void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
|
void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
|
||||||
{
|
{
|
||||||
|
struct uncomp_thread *ucthreads;
|
||||||
struct stream_info *sinfo;
|
struct stream_info *sinfo;
|
||||||
int total_threads, i;
|
int total_threads, i;
|
||||||
i64 header_length;
|
i64 header_length;
|
||||||
|
|
@ -1077,7 +1070,7 @@ void *open_stream_in(rzip_control *control, int f, int n, char chunk_bytes)
|
||||||
if (unlikely(!threads))
|
if (unlikely(!threads))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ucthreads = calloc(sizeof(struct uncomp_thread), total_threads);
|
sinfo->ucthreads = ucthreads = calloc(sizeof(struct uncomp_thread), total_threads);
|
||||||
if (unlikely(!ucthreads)) {
|
if (unlikely(!ucthreads)) {
|
||||||
dealloc(sinfo);
|
dealloc(sinfo);
|
||||||
dealloc(threads);
|
dealloc(threads);
|
||||||
|
|
@ -1506,13 +1499,12 @@ void flush_buffer(rzip_control *control, struct stream_info *sinfo, int streamno
|
||||||
|
|
||||||
static void *ucompthread(void *data)
|
static void *ucompthread(void *data)
|
||||||
{
|
{
|
||||||
stream_thread_struct *s = data;
|
stream_thread_struct *sts = data;
|
||||||
rzip_control *control = s->control;
|
rzip_control *control = sts->control;
|
||||||
int waited = 0, ret = 0, i = s->i;
|
int waited = 0, ret = 0, i = sts->i;
|
||||||
struct uncomp_thread *uci;
|
struct uncomp_thread *uci = &sts->sinfo->ucthreads[i];
|
||||||
|
|
||||||
dealloc(data);
|
dealloc(data);
|
||||||
uci = &ucthreads[i];
|
|
||||||
|
|
||||||
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) {
|
if (unlikely(setpriority(PRIO_PROCESS, 0, control->nice_val) == -1)) {
|
||||||
print_err("Warning, unable to set thread nice value %d...Resetting to %d\n", control->nice_val, control->current_priority);
|
print_err("Warning, unable to set thread nice value %d...Resetting to %d\n", control->nice_val, control->current_priority);
|
||||||
|
|
@ -1570,7 +1562,8 @@ static int fill_buffer(rzip_control *control, struct stream_info *sinfo, struct
|
||||||
{
|
{
|
||||||
i64 u_len, c_len, last_head, padded_len, header_length, max_len;
|
i64 u_len, c_len, last_head, padded_len, header_length, max_len;
|
||||||
uchar enc_head[25 + SALT_LEN], blocksalt[SALT_LEN];
|
uchar enc_head[25 + SALT_LEN], blocksalt[SALT_LEN];
|
||||||
stream_thread_struct *st;
|
stream_thread_struct *sts;
|
||||||
|
struct uncomp_thread *ucthreads = sinfo->ucthreads;
|
||||||
uchar c_type, *s_buf;
|
uchar c_type, *s_buf;
|
||||||
void *thr_return;
|
void *thr_return;
|
||||||
|
|
||||||
|
|
@ -1686,13 +1679,14 @@ fill_another:
|
||||||
print_maxverbose("Starting thread %ld to decompress %lld bytes from stream %d\n",
|
print_maxverbose("Starting thread %ld to decompress %lld bytes from stream %d\n",
|
||||||
s->uthread_no, padded_len, streamno);
|
s->uthread_no, padded_len, streamno);
|
||||||
|
|
||||||
st = malloc(sizeof(stream_thread_struct));
|
sts = malloc(sizeof(stream_thread_struct));
|
||||||
if (unlikely(!st))
|
if (unlikely(!sts))
|
||||||
fatal_return(("Unable to malloc in fill_buffer"), -1);
|
fatal_return(("Unable to malloc in fill_buffer"), -1);
|
||||||
st->i = s->uthread_no;
|
sts->i = s->uthread_no;
|
||||||
st->control = control;
|
sts->control = control;
|
||||||
if (unlikely(!create_pthread(control, &threads[s->uthread_no], NULL, ucompthread, st))) {
|
sts->sinfo = sinfo;
|
||||||
dealloc(st);
|
if (unlikely(!create_pthread(control, &threads[s->uthread_no], NULL, ucompthread, sts))) {
|
||||||
|
dealloc(sts);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1837,7 +1831,7 @@ int close_stream_in(rzip_control *control, void *ss)
|
||||||
dealloc(sinfo->s[i].buf);
|
dealloc(sinfo->s[i].buf);
|
||||||
|
|
||||||
output_thread = 0;
|
output_thread = 0;
|
||||||
dealloc(ucthreads);
|
dealloc(sinfo->ucthreads);
|
||||||
dealloc(threads);
|
dealloc(threads);
|
||||||
dealloc(sinfo->s);
|
dealloc(sinfo->s);
|
||||||
dealloc(sinfo);
|
dealloc(sinfo);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue