Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
af2e2a70
Commit
af2e2a70
authored
Aug 10, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
block: cancellation safety
(Eventually, this could replace block_FifoWake))
parent
7783a1ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
include/vlc_block.h
include/vlc_block.h
+8
-0
src/misc/block.c
src/misc/block.c
+12
-9
No files found.
include/vlc_block.h
View file @
af2e2a70
...
...
@@ -155,6 +155,12 @@ static inline void block_Release( block_t *p_block )
VLC_EXPORT
(
block_t
*
,
block_mmap_Alloc
,
(
void
*
addr
,
size_t
length
)
);
VLC_EXPORT
(
block_t
*
,
block_File
,
(
int
fd
)
);
static
inline
void
block_Cleanup
(
void
*
block
)
{
block_Release
((
block_t
*
)
block
);
}
#define block_cleanup_push( block ) vlc_cleanup_push (block_Cleanup, block)
/****************************************************************************
* Chains of blocks functions helper
****************************************************************************
...
...
@@ -282,6 +288,8 @@ static inline block_t *block_ChainGather( block_t *p_list )
* - block_FifoSize : how many cumulated bytes are waiting in the fifo
* - block_FifoWake : wake ups a thread with block_FifoGet() = NULL
* (this is used to wakeup a thread when there is no data to queue)
*
* block_FifoGet and block_FifoShow are cancellation points.
****************************************************************************/
VLC_EXPORT
(
block_fifo_t
*
,
block_FifoNew
,
(
void
)
);
...
...
src/misc/block.c
View file @
af2e2a70
...
...
@@ -270,7 +270,7 @@ ssize_t pread (int fd, void *buf, size_t count, off_t offset)
* Loads a file into a block of memory. If possible a private file mapping is
* created. Otherwise, the file is read normally. On 32-bits platforms, this
* function will not work for very large files, due to memory space
* constraints.
* constraints.
Cancellation point.
*
* @param fd file descriptor to load from
* @return a new block with the file content at p_buffer, and file length at
...
...
@@ -325,6 +325,7 @@ block_t *block_File (int fd)
block_t
*
block
=
block_Alloc
(
length
);
if
(
block
==
NULL
)
return
NULL
;
block_cleanup_push
(
block
);
for
(
size_t
i
=
0
;
i
<
length
;)
{
...
...
@@ -332,10 +333,12 @@ block_t *block_File (int fd)
if
(
len
==
-
1
)
{
block_Release
(
block
);
return
NULL
;
block
=
NULL
;
break
;
}
i
+=
len
;
}
vlc_cleanup_pop
();
return
block
;
}
...
...
@@ -437,14 +440,14 @@ block_t *block_FifoGet( block_fifo_t *p_fifo )
block_t
*
b
;
vlc_mutex_lock
(
&
p_fifo
->
lock
);
mutex_cleanup_push
(
&
p_fifo
->
lock
);
/* Remember vlc_cond_wait() may cause spurious wakeups
* (on both Win32 and POSIX) */
while
(
(
p_fifo
->
p_first
==
NULL
)
&&
!
p_fifo
->
b_force_wake
)
{
vlc_cond_wait
(
&
p_fifo
->
wait
,
&
p_fifo
->
lock
);
}
vlc_cleanup_pop
();
b
=
p_fifo
->
p_first
;
p_fifo
->
b_force_wake
=
false
;
...
...
@@ -475,24 +478,24 @@ block_t *block_FifoShow( block_fifo_t *p_fifo )
block_t
*
b
;
vlc_mutex_lock
(
&
p_fifo
->
lock
);
mutex_cleanup_push
(
&
p_fifo
->
lock
);
if
(
p_fifo
->
p_first
==
NULL
)
{
vlc_cond_wait
(
&
p_fifo
->
wait
,
&
p_fifo
->
lock
);
}
b
=
p_fifo
->
p_first
;
vlc_mutex_unlock
(
&
p_fifo
->
lock
);
return
(
b
);
vlc_cleanup_run
();
return
b
;
}
/* FIXME: not thread-safe */
size_t
block_FifoSize
(
const
block_fifo_t
*
p_fifo
)
{
return
p_fifo
->
i_size
;
}
/* FIXME: not thread-safe */
size_t
block_FifoCount
(
const
block_fifo_t
*
p_fifo
)
{
return
p_fifo
->
i_depth
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment