aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiku Voipio <riku.voipio@nokia.com>2009-12-04 15:16:31 +0200
committerAurelien Jarno <aurelien@aurel32.net>2009-12-19 19:45:27 +0100
commitd032d1b4b4bc29cb44592ee207bd8ae7cd4da668 (patch)
tree3b20bf8ee99edc01a4a109d503dbe9dfa6a7d30c
parentf76cfe56d9bc281685c5120bf765d29d9323756f (diff)
linux-user: Fix mmap_lock ordering
mmap_lock() can be called while tb_lock() is being held. To avoid deadlock when one thread is holding mmap_lock and another tb_lock, _always_ lock first tb_lock(). Signed-off-by: Riku Voipio <riku.voipio@nokia.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
-rw-r--r--linux-user/main.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index e51539eff8..12502ad173 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -99,13 +99,14 @@ static int pending_cpus;
/* Make sure everything is in a consistent state for calling fork(). */
void fork_start(void)
{
- mmap_fork_start();
pthread_mutex_lock(&tb_lock);
pthread_mutex_lock(&exclusive_lock);
+ mmap_fork_start();
}
void fork_end(int child)
{
+ mmap_fork_end(child);
if (child) {
/* Child processes created by fork() only have a single thread.
Discard information about the parent threads. */
@@ -122,7 +123,6 @@ void fork_end(int child)
pthread_mutex_unlock(&exclusive_lock);
pthread_mutex_unlock(&tb_lock);
}
- mmap_fork_end(child);
}
/* Wait for pending exclusive operations to complete. The exclusive lock