From 26e0b7e748badd2dd95d8b5a0743b0af5ea7f78f Mon Sep 17 00:00:00 2001 From: Xavier Roche Date: Fri, 3 May 2013 11:10:42 +0000 Subject: Fixed bug inside hts_mirror_wait_for_next_file() that may lead to race conditions in downloaded files, leading to download several times the same file, possibly ending with "Unexpected 412/416 error" errors. --- src/htsparse.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/htsparse.c') diff --git a/src/htsparse.c b/src/htsparse.c index b718655..41d1797 100644 --- a/src/htsparse.c +++ b/src/htsparse.c @@ -3988,6 +3988,11 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct* str, htsmoduleStructExtended* int b; int n; + /* This is not supposed to hapen. */ + if (liens[ptr]->pass2 == -1) { + HTS_LOG(opt, LOG_WARNING); fprintf(opt->log, "Link is already ready %s%s"LF, urladr, urlfil); + } + /* User interaction */ ENGINE_SAVE_CONTEXT(); { @@ -3995,6 +4000,15 @@ int hts_mirror_wait_for_next_file(htsmoduleStruct* str, htsmoduleStructExtended* } ENGINE_SET_CONTEXT(); + /* Done while processing user interactions ? */ + if (liens[ptr]->pass2 == -1) { + if ( (opt->debug>0) && (opt->log!=NULL) ) { + HTS_LOG(opt,LOG_DEBUG); fprintf(opt->log, "Link is now ready %s%s"LF, urladr, urlfil); + } + // We are ready + return 2; // goto jump_if_done; + } + // si le fichier n'est pas en backing, le mettre.. if (!back_exist(str->sback,str->opt,urladr,urlfil,savename)) { #if BDEBUG==1 -- cgit v1.2.3