summaryrefslogtreecommitdiffstats
path: root/adb/socket_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
* adb: don't immediately close a socket when write fails.Josh Gao2018-03-281-2/+0
| | | | | | | | | | | When we fail to write to a local socket peer, we might still have data queued up to send to the other side. Defer closing the socket until we've failed to both read and write. Bug: http://b/74616284 Test: python test_device.py Change-Id: Ifc4b8fe95369b4872e475c2ae4ee611dd2d8b9d7 (cherry picked from commit 184f4805476af19c2e58dd96c2ce6aa241efaacf)
* adb: improve socket tests.Josh Gao2018-03-281-17/+14
| | | | | | | | | | Make it so that the socket tests don't leak until your machine blows up by switching an infinite loop into an assertion failure. Bug: http://b/74616284 Test: adb_test Change-Id: If618c26b224b660548454f542cab79bebe46f80e (cherry picked from commit ecb96ac04d7be37eae168658d50003434407b1ac)
* adb: add test for flushing socket data after a write failure.Josh Gao2018-03-281-0/+40
| | | | | | | | | | Add a currently failing test that's a reduced case of the 'concurrent adb shell' flakiness reported in b/74616284. Bug: http://b/74616284 Test: changed #if 0 to #if 1, test fails Change-Id: Id170a185f7c5d2ff44f772f7849a73227f9df441 (cherry picked from commit df3bae9f0675f6cfbe68e64600166e62a403ce7d)
* adb: switch asocket::enqueue to std::string.Josh Gao2018-02-061-4/+4
| | | | | | | | | Switch asocket over to taking a std::string instead of apacket* for data. This allows us to remove asocket specific fields from apacket*. Test: python test_device.py with x86_64 emulator, walleye Test: adb_test on host Change-Id: I9d157ff331a75ba49a54fdd4194e3f6cdff722f4
* adb: kill adb_thread_{create, join, detach, exit}.Josh Gao2017-04-121-23/+7
| | | | | | | | | | We have std::thread now, so we can delete this cruft. Test: python test_device.py Test: adb_test Test: wine adb_test.exe Test: /data/nativetest/adbd_test/adbd_test Change-Id: Ie1c1792547b20dec45e2a62ce6515fcb981c3ef8
* adb: add sysdeps/chrono.h for chrono literals on Win32.Josh Gao2016-11-161-3/+3
| | | | | | Bug: http://b/32878766 Test: mma Change-Id: Iaa89d4eadf07e63d6d7205057435a6c7fb5d4ec5
* Switch adb over to <chrono>.Elliott Hughes2016-11-161-13/+15
| | | | | | | | Clearer code, and lets us lose some more portability cruft. Bug: http://b/32878766 Test: manual Change-Id: Ie44928bbf8d68a74127aaf76e7e0060e25fa2cc8
* adb: fix host-side serial number parsing for IPv6.David Pursell2016-09-211-0/+11
| | | | | | | | | | | | | | | | | | | | | When the adb client sends a command to the adb server targeting a particular device serial, it looks something like this: host-serial:<serial>:<command> But if <serial> happens to be an IPv6 address (e.g. when `adb connect` targets IPv6), the current parsing code doesn't handle the additional colons properly. This CL fixes the host-serial parsing to handle this case. This only affects commands that explicitly name a device serial, e.g.: adb -s <IPv6> shell adb -s <IPv6> forward <port> <port> Implicitly using a single attached device was unaffected by this bug. Bug: http://b/30891386 Test: `adb -s [fe80::ba27:ebff:feb1:934%eth2]:5555 shell` works now, and new unittests pass. Change-Id: Iffe784e61432ae94eb96ed3c8477900a3e807329
* Most accept/accept4 calls in system/core don't actually want the remote address.Elliott Hughes2016-08-231-4/+1
| | | | | | | So don't write the extra code for it or waste the kernel's time copying it around. Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
* adb: fix socket tests.Yabin Cui2016-04-251-12/+22
| | | | | | Bug: 28386497 Change-Id: I9f37ecadf3cfc6bb4e5da502d40f49e1f3a16d8a
* Address const issues in preparation for libcxx rebase.Dan Austin2016-03-291-2/+2
| | | | Change-Id: I4eccc1b5a70da9dd325e1a7e10ab0a3fe588c03f
* adb: relax serial matching rules.David Pursell2016-03-021-0/+46
| | | | | | | | | | | | | | | | | | Currently targeting a device by serial requires matching the serial number exactly. This CL relaxes the matching rules for local transports to ignore protocol prefixes and make the port optional: [tcp:|udp:]<hostname>[:port] The purpose of this is to allow a user to set ANDROID_SERIAL to something like "tcp:100.100.100.100" and have it work for both fastboot and adb (assuming the device comes up at 100.100.100.100 in both modes). This CL also adds some unit tests for the modified functions to make sure they work as expected. Bug: 27340240 Change-Id: I006e0c70c84331ab44d05d0a0f462d06592eb879
* adb: make fdevent_test, socket_test compile on Windows.Josh Gao2016-02-191-149/+112
| | | | | | | | Switch pthread_* to use the adb_thread_* abstractions to allow the fdevent and socket tests to compile on Win32. Bug: http://b/27105824 Change-Id: I6541bb1398780b999837e701837d7f86a5eee8ca
* adb: detect sockets in CLOSE_WAIT state to prevent socket leak on linux.Yabin Cui2015-09-301-39/+48
| | | | | | | | | | | | | | | | It is possible that the adb server on host has many sockets in CLOSE_WAIT state. To prevent socket leak, always enable POLLRDHUP in fdevent.cpp to detect sockets in CLOSE_WAIT state. Update LocalSocketTest unit tests: Change half_close_with_packet to read_from_closing_socket, as reading from a SHUT_WR socket is not needed in adb. Change close_with_no_events_installed to close_socket_in_CLOSE_WAIT_state, as the latter is more close to the real situation in use. Bug: 23314034 Change-Id: Ice4f4036624e5584eab6ba5848e7f169c92f037f
* Add unit tests for local socket.Yabin Cui2015-09-161-0/+300
Add has_write_error flag in asocket, so it will not wait on local_socket_closing_list to write pending packets in local_socket_close(). Although it doesn't fix any problem, it helps to make the code more stable. Add a missing put_apacket() in error handling. Add a check when adding local socket in local_socket_closing_list. Bug: 23314034 Change-Id: I75b07ba8ee59b7f277fba2fb919db63065b291be