RFC playlist.c add_indices_to_playlist() seek back to start of file
get_filename() changes the seek pos with out restoring it seek back to the beginning or after the BOM if utf8 -- the other option is to open our own file descriptor this will remove the need for the mutex but it would no longer block get_filename from getting potential stale / bad data Change-Id: I0d2b8a1a297c7aaf453b3bc558b2b5b53dbe591b
This commit is contained in:
parent
d7557e8da8
commit
773fa7874d
1 changed files with 9 additions and 5 deletions
|
@ -576,20 +576,24 @@ static int add_indices_to_playlist(struct playlist_info* playlist,
|
|||
mutex_lock(playlist->control_mutex); /* read can yield! */
|
||||
|
||||
if(-1 == playlist->fd)
|
||||
{
|
||||
playlist->fd = open_utf8(playlist->filename, O_RDONLY);
|
||||
if(playlist->fd >= 0 && lseek(playlist->fd, 0, SEEK_CUR) > 0)
|
||||
playlist->utf8 = true; /* Override any earlier indication. */
|
||||
}
|
||||
|
||||
if(playlist->fd < 0)
|
||||
return -1; /* failure */
|
||||
playlist_fd = playlist->fd;
|
||||
|
||||
if((i = lseek(playlist->fd, 0, SEEK_CUR)) > 0)
|
||||
playlist->utf8 = true; /* Override any earlier indication. */
|
||||
i = lseek(playlist->fd, playlist->utf8 ? BOM_UTF_8_SIZE : 0, SEEK_SET);
|
||||
|
||||
playlist_fd = playlist->fd;
|
||||
playlist->fd = -2; /* DEBUGGING Remove me! */
|
||||
|
||||
splash(0, ID2P(LANG_WAIT));
|
||||
|
||||
store_index = true;
|
||||
|
||||
playlist->fd = -2; /* DEBUGGING Remove me! */
|
||||
|
||||
/* invalidate playlist in case we yield */
|
||||
int amount = playlist->amount;
|
||||
playlist->amount = -1;
|
||||
|
|
Loading…
Reference in a new issue