Release the main_loop lock around calls to prepare() and check() so that