Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
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-2-2
Commits
4213a133
Commit
4213a133
authored
Apr 11, 2010
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work-around non-thread-safe use of the C random number generator
parent
4e1ff3a1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
bin/override.c
bin/override.c
+31
-0
No files found.
bin/override.c
View file @
4213a133
...
...
@@ -41,6 +41,7 @@ void vlc_enable_override (void)
#include <stdio.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <pthread.h>
static
void
vlogbug
(
const
char
*
level
,
const
char
*
func
,
const
char
*
fmt
,
va_list
ap
)
...
...
@@ -116,4 +117,34 @@ int unsetenv (const char *name)
}
/*** Pseudo random numbers ***
*
* The C PRNG is not thread-safe (and generally sucks, the POSIX 48-bits PRNG
* is much better as a reproducible non-secure PRNG). To work around this, we
* force evil callers to serialize. This makes the call safe, but fails to
* preserve reproducibility of the number sequence (which usually does not
* matter).
**/
static
pthread_mutex_t
prng_lock
=
PTHREAD_MUTEX_INITIALIZER
;
void
srand
(
unsigned
int
seed
)
{
pthread_mutex_lock
(
&
prng_lock
);
LOG
(
"Warning"
,
"%d"
,
seed
);
CALL
(
srand
,
seed
);
pthread_mutex_unlock
(
&
prng_lock
);
}
int
rand
(
void
)
{
int
ret
;
pthread_mutex_lock
(
&
prng_lock
);
LOG
(
"Warning"
,
""
);
ret
=
CALL
(
rand
);
pthread_mutex_unlock
(
&
prng_lock
);
return
ret
;
}
#endif
/* __ELF__ */
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