stop the background download thread from pre-fetching beyond EOF

This commit is contained in:
Fufu Fang 2019-09-02 16:05:55 +01:00
parent eb463478a8
commit 4c0b7da34b
No known key found for this signature in database
GPG Key ID: 0F6BB5EF6F8BB729
1 changed files with 1 additions and 3 deletions

View File

@ -1013,11 +1013,9 @@ long Cache_read(Cache *cf, char * const output_buf, const off_t len,
bgdl:
;
off_t next_dl_offset = round_div(offset_start, cf->blksz) * cf->blksz;
// printf("offset_start: %ld, next_dl_offset: %ld, dl_offset: %ld, next_seg_exists: %d, content_length :%ld\n",
// offset_start, next_dl_offset, dl_offset, Seg_exist(cf, next_dl_offset), cf->content_length);
if ( (next_dl_offset > dl_offset) &&
!Seg_exist(cf, next_dl_offset) &&
cf->next_dl_offset < cf->content_length ){
next_dl_offset < cf->content_length ){
/* Stop the spawning of multiple background pthreads */
if(!pthread_mutex_trylock(&cf->bgt_lock)) {
#ifdef CACHE_LOCK_DEBUG