Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Side by Side Diff: tools/android/common/adb_connection.cc

Issue 9419020: fake_dns tool for Android (fixed DEPS). (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: Try to remove references of fake_dns.gyp from all_android.gyp Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/all_android.gyp ('k') | tools/android/common/net.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "tools/android/common/adb_connection.h" 5 #include "tools/android/common/adb_connection.h"
6 6
7 #include <arpa/inet.h> 7 #include <arpa/inet.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bytes_sent += ret; 76 bytes_sent += ret;
77 bytes_remaining -= ret; 77 bytes_remaining -= ret;
78 } 78 }
79 79
80 const size_t kAdbStatusLength = 4; 80 const size_t kAdbStatusLength = 4;
81 char response[kBufferMaxLength]; 81 char response[kBufferMaxLength];
82 int response_length = HANDLE_EINTR(recv(host_socket, response, 82 int response_length = HANDLE_EINTR(recv(host_socket, response,
83 kBufferMaxLength, 0)); 83 kBufferMaxLength, 0));
84 if (response_length < kAdbStatusLength || 84 if (response_length < kAdbStatusLength ||
85 strncmp("OKAY", response, kAdbStatusLength) != 0) { 85 strncmp("OKAY", response, kAdbStatusLength) != 0) {
86 char fail_msg_buffer[kBufferMaxLength * 3 + 1];
87 char* p = fail_msg_buffer;
88 for (int i = 0; i < response_length; ++i) {
89 snprintf(p, 3, "%02x,", static_cast<unsigned char>(response[i]));
90 p += 3;
91 }
92
93 if (p > fail_msg_buffer)
94 *(--p) = 0; // Eliminate the last comma.
95 LOG(ERROR) << "Bad response from ADB: length: " << response_length 86 LOG(ERROR) << "Bad response from ADB: length: " << response_length
96 << " data: " << fail_msg_buffer; 87 << " data: " << DumpBinary(response, response_length);
97 HANDLE_EINTR(close(host_socket)); 88 HANDLE_EINTR(close(host_socket));
98 return -1; 89 return -1;
99 } 90 }
100 91
101 return host_socket; 92 return host_socket;
102 } 93 }
103 94
104 } // namespace tools 95 } // namespace tools
105 96
OLDNEW
« no previous file with comments | « build/all_android.gyp ('k') | tools/android/common/net.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698