libcras: Change CLOCK used for cond variable timeout

Inside containers, the clock_gettime() + pthread_cond_timedwait()
behaviour is a little weird when we use CLOCK_MONOTONIC. The calling
thread always seems to wake up *after* the timeout expires,
regardless of the timeout value.

It also always fails in this scenario. Interestingly, if we just use
a normal pthread_cond_wait(), the variable gets set and the thread
gets woken correctly, allowing cras initialization to proceed.
It may be that pthread_cond_timedwait() uses CLOCK_REALTIME to
check its timeout condition.

Using CLOCK_REALTIME to set the condition variable timeout eliminates
this issue. Since the resultant behaviour should be effectively
the same as before, we can make this change in Chrome OS itself,
since other cras clients (apart from ARC) should continue
working normally.

BUG: b:68722835
TEST: cras initialization proceeds on a kevin ARC++ instance.
Change-Id: Iaeec2e59c9155301a33c714880e2fa12da57af98
Reviewed-on: https://chromium-review.googlesource.com/748203
Commit-Ready: Prashant Malani <pmalani@google.com>
Tested-by: Prashant Malani <pmalani@google.com>
Reviewed-by: Luis Hector Chavez <lhchavez@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
1 file changed