Remove seeks that aren't required and don't work on tmp input buffers.

Clean up open_stream_in.
This commit is contained in:
Con Kolivas 2011-03-14 21:51:27 +11:00
parent c832e80085
commit 3a8c0b6689
3 changed files with 13 additions and 7 deletions

View file

@ -299,7 +299,7 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, int fd_out, int fd_his
print_maxverbose("Checksum for block: 0x%08x\n", cksum); print_maxverbose("Checksum for block: 0x%08x\n", cksum);
} }
if (unlikely(close_stream_in(control, ss))) if (unlikely(close_stream_in(ss)))
fatal("Failed to close stream!\n"); fatal("Failed to close stream!\n");
return total; return total;
@ -336,9 +336,12 @@ i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 exp
md5_finish_ctx (&control->ctx, md5_resblock); md5_finish_ctx (&control->ctx, md5_resblock);
if (HAS_MD5) { if (HAS_MD5) {
#if 0
/* Unnecessary, we should already be there */
if (unlikely(lseek(fd_in, -MD5_DIGEST_SIZE, SEEK_END)) == -1) if (unlikely(lseek(fd_in, -MD5_DIGEST_SIZE, SEEK_END)) == -1)
fatal("Failed to seek to md5 data in runzip_fd\n"); fatal("Failed to seek to md5 data in runzip_fd\n");
if (unlikely(read(fd_in, md5_stored, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE)) #endif
if (unlikely(read_1g(control, fd_in, md5_stored, MD5_DIGEST_SIZE) != MD5_DIGEST_SIZE))
fatal("Failed to read md5 data in runzip_fd\n"); fatal("Failed to read md5 data in runzip_fd\n");
for (i = 0; i < MD5_DIGEST_SIZE; i++) for (i = 0; i < MD5_DIGEST_SIZE; i++)
if (md5_stored[i] != md5_resblock[i]) { if (md5_stored[i] != md5_resblock[i]) {

View file

@ -1539,14 +1539,17 @@ int close_stream_out(rzip_control *control, void *ss)
} }
/* close down an input stream */ /* close down an input stream */
int close_stream_in(rzip_control *control, void *ss) int close_stream_in(void *ss)
{ {
struct stream_info *sinfo = ss; struct stream_info *sinfo = ss;
int i; int i;
if (unlikely(read_seekto(control, sinfo, sinfo->initial_pos + sinfo->total_read))) #if 0
return -1; /* Unnecessary, we should already be here */
if (unlikely(lseek(sinfo->fd, sinfo->initial_pos + sinfo->total_read,
SEEK_SET) != sinfo->initial_pos + sinfo->total_read))
return -1;
#endif
for (i = 0; i < sinfo->num_streams; i++) for (i = 0; i < sinfo->num_streams; i++)
free(sinfo->s[i].buf); free(sinfo->s[i].buf);

View file

@ -36,7 +36,7 @@ void flush_buffer(rzip_control *control, struct stream_info *sinfo, int stream);
int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len); int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len);
i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len); i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len);
int close_stream_out(rzip_control *control, void *ss); int close_stream_out(rzip_control *control, void *ss);
int close_stream_in(rzip_control *control, void *ss); int close_stream_in(void *ss);
const i64 one_g; const i64 one_g;
#endif #endif