summaryrefslogtreecommitdiffstats
path: root/logd/tests/logd_test.cpp
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2014-04-18 14:49:28 -0700
committerMark Salyzyn <salyzyn@google.com>2014-04-21 17:07:25 -0700
commit696817d3524e2fb8bbbcc2ec3526f4383f789163 (patch)
tree3a27aeefb3bd2c6782c06036e728dbe8ed5c4399 /logd/tests/logd_test.cpp
parenta67914e4d656b8375cfba17739f9c97e900c8328 (diff)
downloadsystem_core-696817d3524e2fb8bbbcc2ec3526f4383f789163.zip
system_core-696817d3524e2fb8bbbcc2ec3526f4383f789163.tar.gz
system_core-696817d3524e2fb8bbbcc2ec3526f4383f789163.tar.bz2
liblog: Statistics truncated to 16384 bytes
- if network read/write broken up, reassemble the pieces. - Use a 20ms poll to check if a new fragment has been sent by the other side. - fixup logd-unit-tests to take a (simplified) fragment from the liblog changes. Bug: 14164765 Change-Id: I98ff87888c119e1e8349717646d0f733e8971bc8
Diffstat (limited to 'logd/tests/logd_test.cpp')
-rw-r--r--logd/tests/logd_test.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp
index 9ad8973..23e6146 100644
--- a/logd/tests/logd_test.cpp
+++ b/logd/tests/logd_test.cpp
@@ -15,6 +15,7 @@
*/
#include <fcntl.h>
+#include <poll.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -37,7 +38,25 @@ static void my_android_logger_get_statistics(char *buf, size_t len)
SOCK_STREAM);
if (sock >= 0) {
if (write(sock, buf, strlen(buf) + 1) > 0) {
- read(sock, buf, len);
+ ssize_t ret;
+ while ((ret = read(sock, buf, len)) > 0) {
+ if ((size_t)ret == len) {
+ break;
+ }
+ len -= ret;
+ buf += ret;
+
+ struct pollfd p = {
+ .fd = sock,
+ .events = POLLIN,
+ .revents = 0
+ };
+
+ ret = poll(&p, 1, 20);
+ if ((ret <= 0) || !(p.revents & POLLIN)) {
+ break;
+ }
+ }
}
close(sock);
}