Corrected error checking for socket functions (#577)
This commit is contained in:
parent
c3a3f7737f
commit
ee553c9a50
|
@ -115,11 +115,19 @@ unsigned char gdb_if_getchar(void)
|
||||||
while(1) {
|
while(1) {
|
||||||
gdb_if_conn = accept(gdb_if_serv, NULL, NULL);
|
gdb_if_conn = accept(gdb_if_serv, NULL, NULL);
|
||||||
if (gdb_if_conn == -1) {
|
if (gdb_if_conn == -1) {
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
if (WSAGetLastError() == WSAEWOULDBLOCK) {
|
||||||
|
#else
|
||||||
if (errno == EWOULDBLOCK) {
|
if (errno == EWOULDBLOCK) {
|
||||||
|
#endif
|
||||||
SET_IDLE_STATE(1);
|
SET_IDLE_STATE(1);
|
||||||
platform_delay(100);
|
platform_delay(100);
|
||||||
} else {
|
} else {
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
DEBUG("error when accepting connection: %d", WSAGetLastError());
|
||||||
|
#else
|
||||||
DEBUG("error when accepting connection: %s", strerror(errno));
|
DEBUG("error when accepting connection: %s", strerror(errno));
|
||||||
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -144,7 +152,11 @@ unsigned char gdb_if_getchar(void)
|
||||||
i = recv(gdb_if_conn, (void*)&ret, 1, 0);
|
i = recv(gdb_if_conn, (void*)&ret, 1, 0);
|
||||||
if(i <= 0) {
|
if(i <= 0) {
|
||||||
gdb_if_conn = -1;
|
gdb_if_conn = -1;
|
||||||
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
DEBUG("Dropped broken connection: %d\n", WSAGetLastError());
|
||||||
|
#else
|
||||||
DEBUG("Dropped broken connection: %s\n", strerror(errno));
|
DEBUG("Dropped broken connection: %s\n", strerror(errno));
|
||||||
|
#endif
|
||||||
/* Return '+' in case we were waiting for an ACK */
|
/* Return '+' in case we were waiting for an ACK */
|
||||||
return '+';
|
return '+';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue