From fe6d4aef3a692847cc908f6970f8c7c778484ff0 Mon Sep 17 00:00:00 2001 From: "ramil/ram@mysql.com/ramil.myoffice.izhnet.ru" <> Date: Fri, 15 Feb 2008 16:03:54 +0400 Subject: [PATCH] Fix for bug #33304: Test 'func_group' hangs on Mac OS X 10.4 PowerPC 64-bit Problem: SLEEP(0) never returns on 64-bit Mac OS X due to a bug in pthread_cond_timedwait(). Fix: when given a very short timeout just return immediately. --- sql/item_func.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sql/item_func.cc b/sql/item_func.cc index 639e069d24e..e20b0762ea2 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3729,6 +3729,18 @@ longlong Item_func_sleep::val_int() DBUG_ASSERT(fixed == 1); double time= args[0]->val_real(); + /* + On 64-bit OSX pthread_cond_timedwait() waits forever + if passed abstime time has already been exceeded by + the system time. + When given a very short timeout (< 10 mcs) just return + immediately. + We assume that the lines between this test and the call + to pthread_cond_timedwait() will be executed in less than 0.00001 sec. + */ + if (time < 0.00001) + return 0; + set_timespec_nsec(abstime, (ulonglong)(time * ULL(1000000000))); pthread_cond_init(&cond, NULL);