The test implementation of BluetoothSocket::GetInputStream() would crash if
the socket was closed. That's not ideal because the caller can't verify if the
socket is open or closed.
New test verifies that GetOutputStream() and GetInputStream() always return a
valid reference.
PiperOrigin-RevId: 518722540
Read() can return fewer bytes than requested.
ReadExactly() will call Read() repeatedly until we
have read as many bytes as we need.
PiperOrigin-RevId: 518719418
In Prod LLVM release branch 515643669.1 ( cl/517696539 ) the experimental coroutines implementation is dropped. The `experimental/coroutines` header is removed.
Nearby doesn't use coroutines, but it uses libraries that depend on the existence of coroutine function definitions. Specifically, WinRT needs certain coroutine function definitions in order to compile.
Ordinarily, WinRT relied on the coroutine function definitions provided in the MSVC STL' `experimental/coroutines` header. The introduction of libc++ complicated this dependency for Nearby, because libc++' `experimental/coroutines` header took the place of the MSVC version, and (correctly, for C++17) provided none of the coroutine function definitions.
To resolve these issues, we implemented a patch of WinRT. The patch provided placeholder definitions, which allowed WinRT to pass compilation. This patch was submitted in cl/495104919. The patch was necessary to enable the Nearby migration from MSVC STL to libc++.
--
The removal of `experimental/coroutines` from libc++ makes this patch unnecessary. However, the patch will not compile without libc++' `experimental/coroutines` header.
The presence of libc++' `experimental/coroutines` header had prevented the corresponding MSVC STL' header from defining the functions for which the patch makes placeholders. Without the libc++' `experimental/coroutines` header, the MSVC STL header is employed and makes these definitions. The patch then redefines these functions, which causes a compilation failure.
--
This CL makes two changes: 1) It eliminates the patch, and 2) It eliminates the libc++ `experimental/coroutines` file from the Lexan libc++ distribution. This allows Nearby to function identically before and after the release of Lexan 515643669.1.
This change prevents a break from occurring when Lexan 515643669.1 is released.
PiperOrigin-RevId: 518119913
Previously reading from an empty, closed Pipe returned:
* IO exception if there were no writes to the pipe,
* Empty byte array if there were writes to the pipe.
With this change, we return an empty byte array on both paths.
This also fixes a subtle race condition in the following flow:
1. Pipe is empty
2. Thread A is reading from the pipe (blocking call).
3. Thread B writes to the pipe and immediately closes it.
4. Thread A is unblocked and returns IO error. The data written by thread B is
ignored!
The new test in bluetooth_classic_test triggered that defect consistently.
PiperOrigin-RevId: 518107700