androiddump: Fix non-blocking connect on Windows
Commit 043ed1f6
enabled non-blocking connect on Windows. This seems to
break androiddump on Windows completely, since a successful connection
always returns SOCKET_ERROR on connect, with WSAGetLastError() set to
WSAEWOULDBLOCK.
Apparently, the only way to check for a real connection is to try a
write select on the socket:
https://stackoverflow.com/questions/35370239/timeout-in-connect-function-from-winsock
This fixes androiddump on Windows:
- If ADB server is running, extcap interfaces are listed
- If ADB is not running, there is no noticeable delay in Wireshark
Change-Id: I6bd772215c7b232c8fe8e840cb7ad1d54c7d8860
Reviewed-on: https://code.wireshark.org/review/25715
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
bfef57ebb7
commit
02a3056af3
|
@ -547,6 +547,22 @@ static socket_handle_t adb_connect(const char *server_ip, unsigned short *server
|
|||
while (tries < SOCKET_CONNECT_TIMEOUT_TRIES) {
|
||||
status = connect(sock, (struct sockaddr *) &server, (socklen_t)sizeof(server));
|
||||
tries += 1;
|
||||
|
||||
#ifdef _WIN32
|
||||
if ((status == SOCKET_ERROR) && (WSAGetLastError() == WSAEWOULDBLOCK)) {
|
||||
const struct timeval timeout = {
|
||||
.tv_sec = 0,
|
||||
.tv_usec = SOCKET_CONNECT_DELAY_US,
|
||||
};
|
||||
fd_set fdset;
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(sock, &fdset);
|
||||
if ((select(0, NULL, &fdset, NULL, &timeout) != 0) && (FD_ISSET(sock, &fdset))) {
|
||||
status = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (status != SOCKET_ERROR)
|
||||
break;
|
||||
g_usleep(SOCKET_CONNECT_DELAY_US);
|
||||
|
|
Loading…
Reference in New Issue