From 48dc679d7bfe9f45bd50d86882d88a9ddb1d659c Mon Sep 17 00:00:00 2001 From: François Revol Date: Fri, 22 Mar 2013 00:25:27 +0100 Subject: beos: Fix replicants Waiting on the semaphore was not enough, it was causing a crash on replicant removal. Now we wait for the replicant main thread to exit. It fixes replicants, at least when a single one is used per application. Using more than one still causes issues due to some libs not liking being used twice (hlcache it seems). --- beos/scaffolding.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'beos') diff --git a/beos/scaffolding.cpp b/beos/scaffolding.cpp index 7f2b12096..9954dd678 100644 --- a/beos/scaffolding.cpp +++ b/beos/scaffolding.cpp @@ -142,6 +142,7 @@ struct replicant_thread_info { static int open_windows = 0; /**< current number of open browsers */ static NSBaseView *replicant_view = NULL; /**< if not NULL, the replicant View we are running NetSurf for */ static sem_id replicant_done_sem = -1; +static thread_id replicant_thread = -1; static void nsbeos_window_update_back_forward(struct beos_scaffolding *); static void nsbeos_throb(void *); @@ -224,9 +225,14 @@ NSBaseView::NSBaseView(BMessage *archive) NSBaseView::~NSBaseView() { //warn_user ("~NSBaseView()", NULL); - BMessage *message = new BMessage(B_QUIT_REQUESTED); - nsbeos_pipe_message_top(message, NULL, fScaffolding); - while (acquire_sem(replicant_done_sem) == EINTR); + if (replicated) { + BMessage *message = new BMessage(B_QUIT_REQUESTED); + nsbeos_pipe_message_top(message, NULL, fScaffolding); + while (acquire_sem(replicant_done_sem) == EINTR); + //debugger("plop"); + status_t status = -1; + wait_for_thread(replicant_thread, &status); + } } @@ -397,15 +403,15 @@ NSBaseView::Instantiate(BMessage *archive) gui_init_replicant(2, info->args); replicant_done_sem = create_sem(0, "NS Replicant created"); - thread_id nsMainThread = spawn_thread(nsbeos_replicant_main_thread, + replicant_thread = spawn_thread(nsbeos_replicant_main_thread, "NetSurf Main Thread", B_NORMAL_PRIORITY, info); - if (nsMainThread < B_OK) { + if (replicant_thread < B_OK) { delete_sem(replicant_done_sem); delete info; delete view; return NULL; } - resume_thread(nsMainThread); + resume_thread(replicant_thread); //XXX: deadlocks BeHappy //while (acquire_sem(replicant_done_sem) == EINTR); -- cgit v1.2.3