Make ADB over mDNS work on Windows
Test: Verified ADB over mDNS on a Windows machine
Bug: 30482671
(cherry picked from 9fdd77101f49d03ff29342e12e23edf241f68522)
Change-Id: If955ca304db71a5b08c5a9654f1e27ab74af9af8
diff --git a/sysdeps_win32.cpp b/sysdeps_win32.cpp
index a4b5e69..f997e6b 100644
--- a/sysdeps_win32.cpp
+++ b/sysdeps_win32.cpp
@@ -126,10 +126,7 @@
SOCKET socket;
} u;
- int mask;
-
char name[32];
-
} FHRec;
#define fh_handle u.handle
@@ -577,7 +574,6 @@
static void _fh_socket_init(FH f) {
f->fh_socket = INVALID_SOCKET;
- f->mask = 0;
}
static int _fh_socket_close( FH f ) {
@@ -598,7 +594,6 @@
}
f->fh_socket = INVALID_SOCKET;
}
- f->mask = 0;
return 0;
}
@@ -913,6 +908,12 @@
return fd;
}
+int adb_register_socket(SOCKET s) {
+ FH f = _fh_alloc( &_fh_socket_class );
+ f->fh_socket = s;
+ return _fh_to_int(f);
+}
+
#undef accept
int adb_socket_accept(int serverfd, struct sockaddr* addr, socklen_t *addrlen)
{
@@ -1113,18 +1114,22 @@
if (!fh || !fh->used) {
errno = EBADF;
+ D("Setting nonblocking on bad file descriptor %d", fd);
return false;
}
if (fh->clazz == &_fh_socket_class) {
u_long x = !block;
if (ioctlsocket(fh->u.socket, FIONBIO, &x) != 0) {
- _socket_set_errno(WSAGetLastError());
+ int error = WSAGetLastError();
+ _socket_set_errno(error);
+ D("Setting %d nonblocking failed (%d)", fd, error);
return false;
}
return true;
} else {
errno = ENOTSOCK;
+ D("Setting nonblocking on non-socket %d", fd);
return false;
}
}