adb: improve network error info
- handle_forward_request
- Because we have detailed info about which syscall failed (at least
on Win32), use a more generic prefix of "cannot bind listener" followed
by the detailed info.
- install_listener
- Return string errors for a few errors even though I don't think any
callers actually output the string for those errors.
- Remove the printf since the callers print the message themselves.
- adb_main
- LOG(FATAL) calls abort() which on Windows calls the Windows Error
Reporting service which pops up a dialog asking if you want a
crashdump to be uploaded to Microsoft. So really, abort() is
designed for app bugs. Windows isn't the only one doing this, Chromium
also makes LOG(FATAL) crashdump-ready. Since an error here is not
necessarily an app-bug, use a 'normal' error output API like fatal()
which prints an error and just uses exit().
- sysdeps_win32.cpp
- When Winsock APIs fail, make the string clarify which API failed.
Use terse unix-style descriptions (like what you'd get from
cp/mv/dd/etc.).
- Don't trace WSAEWOULDBLOCK from recv() which is a normal occurrence.
- Add a comment about WSAEWOULDBLOCK => EAGAIN.
Change-Id: I58e47f49fa2f6c1b4b92a36d0c4bfe369b456f2a
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/adb/adb_listeners.cpp b/adb/adb_listeners.cpp
index 1e7ce5d..8fb2d19 100644
--- a/adb/adb_listeners.cpp
+++ b/adb/adb_listeners.cpp
@@ -190,16 +190,19 @@
/* can't repurpose a smartsocket */
if(l->connect_to[0] == '*') {
+ *error = "cannot repurpose smartsocket";
return INSTALL_STATUS_INTERNAL_ERROR;
}
/* can't repurpose a listener if 'no_rebind' is true */
if (no_rebind) {
+ *error = "cannot rebind";
return INSTALL_STATUS_CANNOT_REBIND;
}
cto = strdup(connect_to);
if(cto == 0) {
+ *error = "cannot duplicate string";
return INSTALL_STATUS_INTERNAL_ERROR;
}
@@ -232,7 +235,6 @@
listener->fd = local_name_to_fd(listener->local_name, error);
if (listener->fd < 0) {
- printf("cannot bind '%s': %s\n", listener->local_name, error->c_str());
free(listener->local_name);
free(listener->connect_to);
free(listener);