diff options
author | Rodrigo Kumpera <kumpera@gmail.com> | 2011-07-29 20:42:25 +0400 |
---|---|---|
committer | Rodrigo Kumpera <kumpera@gmail.com> | 2011-07-29 20:42:25 +0400 |
commit | 66187b25b69ab736c0ff93f0b3ebf35f660fb343 (patch) | |
tree | a2f6ac2f02e1b96256e0cdef902c80e58bf1adb5 | |
parent | f3deab1057480543e8a224e529a7891223dea668 (diff) |
Use wrappers for accessing socket errors. Cygwin does not have some errors in errno.h. Fixes Windows build.2.10.3
-rw-r--r-- | mono/mini/debugger-agent.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/mono/mini/debugger-agent.c b/mono/mini/debugger-agent.c index 67622d0f091..7ecae9dcb5c 100644 --- a/mono/mini/debugger-agent.c +++ b/mono/mini/debugger-agent.c @@ -514,6 +514,16 @@ typedef struct { #define DEBUG(level,s) do { if (G_UNLIKELY ((level) <= log_level)) { s; fflush (log_file); } } while (0) +#ifdef TARGET_WIN32 +#define get_last_sock_error() WSAGetLastError() +#define MONO_EWOULDBLOCK WSAEWOULDBLOCK +#define MONO_EINTR WSAEINTR +#else +#define get_last_sock_error() errno +#define MONO_EWOULDBLOCK EWOULDBLOCK +#define MONO_EINTR EINTR +#endif + /* * Globals */ @@ -985,11 +995,11 @@ recv_length (int fd, void *buf, int len, int flags) res = recv (fd, (char *) buf + total, len - total, flags); if (res > 0) total += res; - if (agent_config.keepalive && res == -1 && errno == EWOULDBLOCK) { + if (agent_config.keepalive && res == -1 && get_last_sock_error () == MONO_EWOULDBLOCK) { process_profiler_event (EVENT_KIND_KEEPALIVE, NULL); goto again; } - } while ((res > 0 && total < len) || (res == -1 && errno == EINTR)); + } while ((res > 0 && total < len) || (res == -1 && get_last_sock_error () == MONO_EINTR)); return total; } @@ -1075,7 +1085,7 @@ transport_connect (const char *host, int port) /* This will bind the socket to a random port */ res = listen (sfd, 16); if (res == -1) { - fprintf (stderr, "debugger-agent: Unable to setup listening socket: %s\n", strerror (errno)); + fprintf (stderr, "debugger-agent: Unable to setup listening socket: %s\n", strerror (get_last_sock_error ())); exit (1); } @@ -1238,7 +1248,7 @@ transport_send (guint8 *data, int len) do { res = send (conn_fd, data, len, 0); - } while (res == -1 && errno == EINTR); + } while (res == -1 && get_last_sock_error () == MONO_EINTR); if (res != len) return FALSE; else |