Commit 7a2cfda9 authored by Laurent Aimar's avatar Laurent Aimar

Check for file size change at every read (improve reading of downloading

files).
parent bc19641a
...@@ -163,9 +163,7 @@ static block_t *Block (access_t *p_access) ...@@ -163,9 +163,7 @@ static block_t *Block (access_t *p_access)
{ {
access_sys_t *p_sys = p_access->p_sys; access_sys_t *p_sys = p_access->p_sys;
if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size) /* Check if file size changed... */
{
/* End of file - check if file size changed... */
struct stat st; struct stat st;
if ((fstat (p_sys->fd, &st) == 0) if ((fstat (p_sys->fd, &st) == 0)
...@@ -175,14 +173,13 @@ static block_t *Block (access_t *p_access) ...@@ -175,14 +173,13 @@ static block_t *Block (access_t *p_access)
p_access->info.i_update |= INPUT_UPDATE_SIZE; p_access->info.i_update |= INPUT_UPDATE_SIZE;
} }
/* Really at end of file then */
if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size) if ((uint64_t)p_access->info.i_pos >= (uint64_t)p_access->info.i_size)
{ {
/* We are at end of file */
p_access->info.b_eof = true; p_access->info.b_eof = true;
msg_Dbg (p_access, "at end of memory mapped file"); msg_Dbg (p_access, "at end of memory mapped file");
return NULL; return NULL;
} }
}
#ifdef MMAP_DEBUG #ifdef MMAP_DEBUG
int64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR); int64_t dbgpos = lseek (p_sys->fd, 0, SEEK_CUR);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment