Codebase list squeezelite / 8c11031
use WSAEWOULDBLOCK on windows, EWOULDBLOCK on linux/osx Adrian Smith 10 years ago
3 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
8383 while (len) {
8484 n = send(sock, ptr, len, MSG_NOSIGNAL);
8585 if (n <= 0) {
86 if (n < 0 && last_error() == EAGAIN && try < 10) {
86 if (n < 0 && last_error() == ERROR_WOULDBLOCK && try < 10) {
8787 LOG_DEBUG("retrying (%d) writing to socket", ++try);
8888 usleep(1000);
8989 continue;
459459 if (expect > 0) {
460460 int n = recv(sock, buffer + got, expect, 0);
461461 if (n <= 0) {
462 if (n < 0 && last_error() == EAGAIN) {
462 if (n < 0 && last_error() == ERROR_WOULDBLOCK) {
463463 continue;
464464 }
465465 LOG_INFO("error reading from socket: %s", n ? strerror(last_error()) : "closed");
474474 } else if (expect == 0) {
475475 int n = recv(sock, buffer + got, 2 - got, 0);
476476 if (n <= 0) {
477 if (n < 0 && last_error() == EAGAIN) {
477 if (n < 0 && last_error() == ERROR_WOULDBLOCK) {
478478 continue;
479479 }
480480 LOG_INFO("error reading from socket: %s", n ? strerror(last_error()) : "closed");
139139 #define thread_t pthread_t;
140140 #define closesocket(s) close(s)
141141 #define last_error() errno
142 #define ERROR_WOULDBLOCK EWOULDBLOCK
142143
143144 typedef u_int8_t u8_t;
144145 typedef u_int16_t u16_t;
193194 #define usleep(x) Sleep(x/1000)
194195 #define sleep(x) Sleep(x*1000)
195196 #define last_error() WSAGetLastError()
197 #define ERROR_WOULDBLOCK WSAEWOULDBLOCK
196198 #define open _open
197199 #define read _read
198200
4545 while (len) {
4646 n = send(fd, ptr, len, MSG_NOSIGNAL);
4747 if (n <= 0) {
48 if (n < 0 && last_error() == EAGAIN && try < 10) {
48 if (n < 0 && last_error() == ERROR_WOULDBLOCK && try < 10) {
4949 LOG_SDEBUG("retrying (%d) writing to socket", ++try);
5050 usleep(1000);
5151 continue;
124124
125125 int n = recv(fd, &c, 1, 0);
126126 if (n <= 0) {
127 if (n < 0 && last_error() == EAGAIN) {
127 if (n < 0 && last_error() == ERROR_WOULDBLOCK) {
128128 UNLOCK;
129129 continue;
130130 }
166166 u8_t c;
167167 int n = recv(fd, &c, 1, 0);
168168 if (n <= 0) {
169 if (n < 0 && last_error() == EAGAIN) {
169 if (n < 0 && last_error() == ERROR_WOULDBLOCK) {
170170 UNLOCK;
171171 continue;
172172 }
183183 if (stream.meta_left) {
184184 int n = recv(fd, stream.header + stream.header_len, stream.meta_left, 0);
185185 if (n <= 0) {
186 if (n < 0 && last_error() == EAGAIN) {
186 if (n < 0 && last_error() == ERROR_WOULDBLOCK) {
187187 UNLOCK;
188188 continue;
189189 }
222222 LOG_INFO("end of stream");
223223 _disconnect(DISCONNECT, DISCONNECT_OK);
224224 }
225 if (n < 0 && last_error() != EAGAIN) {
225 if (n < 0 && last_error() != ERROR_WOULDBLOCK) {
226226 LOG_INFO("error reading: %s", strerror(last_error()));
227227 _disconnect(DISCONNECT, REMOTE_DISCONNECT);
228228 }