summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichihiro NAKAJIMA <ggcueroad@gmail.com>2012-01-05 02:35:24 -0500
committerMichihiro NAKAJIMA <ggcueroad@gmail.com>2012-01-05 02:35:24 -0500
commit2c87f98f52e383ad17d1d476cfca1ebbfac3f1cc (patch)
treee745e326baecbc1c29830b16619eb96741a26946
parenta21919fbac4ff59a6f6f4833b0d5172f5ec9e6a6 (diff)
downloadlibarchive-2c87f98f52e383ad17d1d476cfca1ebbfac3f1cc.tar.gz
Make sure remaining asynchronous reads are canceled whenever something unexpected sequence happen.
SVN-Revision: 4088
-rw-r--r--libarchive/archive_read_disk_windows.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c
index 29ffabc7..5e3c0837 100644
--- a/libarchive/archive_read_disk_windows.c
+++ b/libarchive/archive_read_disk_windows.c
@@ -629,6 +629,15 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)
return (t->ol_remaining_bytes == 0)? ARCHIVE_EOF: ARCHIVE_OK;
}
+static void
+cancel_async(struct tree *t)
+{
+ if (t->ol_num_doing != t->ol_num_done) {
+ CancelIo(t->entry_fh);
+ t->ol_num_doing = t->ol_num_done = 0;
+ }
+}
+
static int
_archive_read_data_block(struct archive *_a, const void **buff,
size_t *size, int64_t *offset)
@@ -703,14 +712,11 @@ _archive_read_data_block(struct archive *_a, const void **buff,
return (ARCHIVE_OK);
abort_read_data:
- if (t->ol_num_doing != t->ol_num_done) {
- CancelIo(t->entry_fh);
- t->ol_num_doing = t->ol_num_done = 0;
- }
*buff = NULL;
*size = 0;
*offset = t->entry_total;
if (t->entry_fh != INVALID_HANDLE_VALUE) {
+ cancel_async(t);
/* Close the current file descriptor */
close_and_restore_time(t->entry_fh, t, &t->restore_time);
t->entry_fh = INVALID_HANDLE_VALUE;
@@ -734,6 +740,7 @@ _archive_read_next_header2(struct archive *_a, struct archive_entry *entry)
t = a->tree;
if (t->entry_fh != INVALID_HANDLE_VALUE) {
+ cancel_async(t);
close_and_restore_time(t->entry_fh, t, &t->restore_time);
t->entry_fh = INVALID_HANDLE_VALUE;
}
@@ -1902,6 +1909,7 @@ tree_close(struct tree *t)
if (t == NULL)
return;
if (t->entry_fh != INVALID_HANDLE_VALUE) {
+ cancel_async(t);
close_and_restore_time(t->entry_fh, t, &t->restore_time);
t->entry_fh = INVALID_HANDLE_VALUE;
}