Skip to content

Commit

Permalink
Corrected closing of sockets for Windows versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
orineman committed Jun 9, 2017
1 parent 256e599 commit f881677
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/gdbserver/gdb-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,11 @@ int serve(stlink_t *sl, st_state_t *st) {
return 1;
}

close(sock);
#if defined(__MINGW32__) || defined(_MSC_VER)
win32_close_socket(sock);
#else
close(sock);
#endif

stlink_force_debug(sl);
if (st->reset) {
Expand All @@ -1089,7 +1093,7 @@ int serve(stlink_t *sl, st_state_t *st) {
if(status < 0) {
ELOG("cannot recv: %d\n", status);
#if defined(__MINGW32__) || defined(_MSC_VER)
win32_close_socket(sock);
win32_close_socket(client);
#endif
return 1;
}
Expand Down Expand Up @@ -1342,7 +1346,7 @@ int serve(stlink_t *sl, st_state_t *st) {
if(status < 0) {
ELOG("cannot check for int: %d\n", status);
#if defined(__MINGW32__) || defined(_MSC_VER)
win32_close_socket(sock);
win32_close_socket(client);
#endif
return 1;
}
Expand Down Expand Up @@ -1744,7 +1748,7 @@ int serve(stlink_t *sl, st_state_t *st) {
free(reply);
free(packet);
#if defined(__MINGW32__) || defined(_MSC_VER)
win32_close_socket(sock);
win32_close_socket(client);
#endif
return 1;
}
Expand All @@ -1756,7 +1760,7 @@ int serve(stlink_t *sl, st_state_t *st) {
}

#if defined(__MINGW32__) || defined(_MSC_VER)
win32_close_socket(sock);
win32_close_socket(client);
#endif

return 0;
Expand Down

0 comments on commit f881677

Please sign in to comment.