]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-6969 #resolve #comment This patch should accomplish the same and handle other...
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 7 Nov 2014 14:37:53 +0000 (08:37 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 7 Nov 2014 14:38:01 +0000 (08:38 -0600)
src/include/switch_utils.h
src/switch_utils.c

index e8b6843d1401287a22f958d12dcef0eb038623de..523e3a47689e34b4e6488d69807f0130e1156662 100644 (file)
@@ -541,6 +541,28 @@ SWITCH_DECLARE(int) switch_build_uri(char *uri, switch_size_t size, const char *
 
 #define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35 || x == SWITCH_STATUS_INTR)
 
+
+#ifdef _MSC_VER
+
+#define switch_errno() WSAGetLastError()
+
+static inline int switch_errno_is_break(int errcode)
+{
+       return errcode == WSAEWOULDBLOCK || errcode == WSAEINPROGRESS || errcode == WSAEINTR;
+}
+
+#else
+
+#define switch_errno() errno
+
+static inline int switch_errno_is_break(int errcode)
+{
+  return errcode == EAGAIN || errcode == EWOULDBLOCK || errcode == EINPROGRESS || errcode == EINTR || errcode == ETIMEDOUT;
+}
+
+#endif
+
+
 /*!
   \brief Return a printable name of a switch_priority_t
   \param priority the priority to get the name of
index 3cde97a1272e1c339c8ad11cff0d5bcb18b1e234..444333ec127f2fe6c1e6d57f4f6376d23d6b6eb0 100644 (file)
@@ -2567,6 +2567,12 @@ SWITCH_DECLARE(int) switch_wait_sock(switch_os_socket_t sock, uint32_t ms, switc
        
        s = poll(pfds, 1, ms);
 
+       if (s < 0) {
+               if (switch_errno_is_break(switch_errno())) {
+                       s = 0;
+               }
+       }
+
        if (s < 0) {
                r = s;
        } else if (s > 0) {
@@ -2645,6 +2651,12 @@ SWITCH_DECLARE(int) switch_wait_socklist(switch_waitlist_t *waitlist, uint32_t l
        
        s = poll(pfds, len, ms);
 
+       if (s < 0) {
+               if (switch_errno_is_break(switch_errno())) {
+                       s = 0;
+               }
+       }
+
        if (s < 0) {
                r = s;
        } else if (s > 0) {
@@ -2758,6 +2770,12 @@ SWITCH_DECLARE(int) switch_wait_sock(switch_os_socket_t sock, uint32_t ms, switc
        
        s = select(sock + 1, (flags & SWITCH_POLL_READ) ? rfds : NULL, (flags & SWITCH_POLL_WRITE) ? wfds : NULL, (flags & SWITCH_POLL_ERROR) ? efds : NULL, &tv);
 
+       if (s < 0) {
+               if (switch_errno_is_break(switch_errno())) {
+                       s = 0;
+               }
+       }
+
        if (s < 0) {
                r = s;
        } else if (s > 0) {
@@ -2858,6 +2876,12 @@ SWITCH_DECLARE(int) switch_wait_socklist(switch_waitlist_t *waitlist, uint32_t l
        
        s = select(max_fd + 1, (flags & SWITCH_POLL_READ) ? rfds : NULL, (flags & SWITCH_POLL_WRITE) ? wfds : NULL, (flags & SWITCH_POLL_ERROR) ? efds : NULL, &tv);
 
+       if (s < 0) {
+               if (switch_errno_is_break(switch_errno())) {
+                       s = 0;
+               }
+       }
+
        if (s < 0) {
                r = s;
        } else if (s > 0) {