Commit e6765fdc authored by heikki@donna.mysql.fi's avatar heikki@donna.mysql.fi
Browse files

sync0sync.c Fix the infinite spin on FreeBSD

os0thread.c	Use pthread_yield instead of os_thread_sleep(0)
parent 09fa56ff
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
mwagner@evoq.mwagner.org
jcole@abel.spaceapes.com
monty@donna.mysql.fi
sasha@mysql.sashanet.com
heikki@donna.mysql.fi
+1 −1
Original line number Diff line number Diff line
@@ -122,7 +122,7 @@ os_thread_yield(void)
#ifdef __WIN__	
	Sleep(0);
#else
	os_thread_sleep(0);
	pthread_yield();
#endif
}

+9 −0
Original line number Diff line number Diff line
@@ -367,6 +367,15 @@ mutex_spin_wait(
                return;
   	}

	/* We may end up with a situation where lock_word is
	0 but the OS fast mutex is still reserved. On FreeBSD
	the OS does not seem to schedule a thread which is constantly
	calling pthread_mutex_trylock (in mutex_test_and_set
	implementation). Then we could end up spinning here indefinitely.
	The following 'i++' stops this infinite spin. */

	i++;
        
	if (i < SYNC_SPIN_ROUNDS) {

		goto spin_loop;