platform_system_core/base/include/android-base
Tom Cherry 3d5729402e Fix timeouts for android::base::WaitForProperty*
std::chrono doesn't handle integer overflow, so using
std::chrono::milliseconds::max() to indicate an infinite timeout is
not handled well in the current code.  It causes an 'absolute_timeout'
earlier in time than 'now' and causes the associated WaitForProperty*
functions to return immediately.

Also, any duration_cast from relative_timeout to nanoseconds would
cause the same issue, as it would overflow in the conversion and
result in an invalid results.

This change prevents any duration_casts of relative_timeout to
nanoseconds and replaces the logic to wait on an absolute timeout with
logic that compares the time elapsed to the provided relative timeout.

This change also includes a test that std::chrono::milliseconds::max()
does not return immediately and that negative values do return immediately.

Test: Boot bullhead + libbase_test

Change-Id: I335bfa7ba71e86c20119a0ed46014cad44361162
2017-03-27 18:05:58 -07:00
..
endian.h Add cross-platform <android-base/endian.h>. 2017-02-24 14:03:36 -08:00
errors.h Fix <android-base/*.h> header guards. 2016-03-23 15:04:52 -07:00
file.h Add android::base::Realpath. 2017-03-15 22:20:50 -07:00
logging.h Add some basic docs for <android-base/logging.h> 2017-02-22 18:02:46 -08:00
macros.h Base: assume and use C++11 in libbase 2016-09-01 13:38:12 -07:00
memory.h Switch to memcpy for accessing misaligned data. 2016-12-07 03:46:55 -08:00
parsedouble.h libbase: add parsedouble.h. 2016-10-19 11:19:42 -07:00
parseint.h Move off std::sto* function which abort on failure. 2016-10-13 15:34:05 -07:00
parsenetaddress.h Fix <android-base/*.h> header guards. 2016-03-23 15:04:52 -07:00
properties.h Fix timeouts for android::base::WaitForProperty* 2017-03-27 18:05:58 -07:00
quick_exit.h base: add quick_exit emulation. 2016-09-13 17:54:50 -07:00
stringprintf.h Fix <android-base/*.h> header guards. 2016-03-23 15:04:52 -07:00
strings.h bootable/recovery wants EqualsIgnoreCase. 2017-01-13 18:51:32 -08:00
test_utils.h Move CapturedStderr to test_util library 2016-10-22 10:35:21 -07:00
thread_annotations.h Base: add more thread annotations 2016-08-31 13:29:07 -07:00
unique_fd.h base: rename unique_fd::clear() to unique_fd::reset(). 2016-09-19 11:24:58 -07:00
utf8.h Fix <android-base/*.h> header guards. 2016-03-23 15:04:52 -07:00