EAGAIN and EWOULDBLOCK may be not the same value, see issue #420

This commit is contained in:
Cloud Wu
2015-12-27 19:31:32 +08:00
parent f0ac66787e
commit 0c4ea81709

View File

@@ -46,6 +46,13 @@
#define MAX_UDP_PACKAGE 65535
// EAGAIN and EWOULDBLOCK may be not the same value.
#if (EAGAIN != EWOULDBLOCK)
#define AGAIN_WOULDBLOCK EAGAIN : case EWOULDBLOCK
#else
#define AGAIN_WOULDBLOCK EAGAIN
#endif
struct write_buffer {
struct write_buffer * next;
void *buffer;
@@ -475,7 +482,7 @@ send_list_tcp(struct socket_server *ss, struct socket *s, struct wb_list *list,
switch(errno) {
case EINTR:
continue;
case EAGAIN:
case AGAIN_WOULDBLOCK:
return -1;
}
force_close(ss,s, result);
@@ -531,7 +538,7 @@ send_list_udp(struct socket_server *ss, struct socket *s, struct wb_list *list,
if (err < 0) {
switch(errno) {
case EINTR:
case EAGAIN:
case AGAIN_WOULDBLOCK:
return -1;
}
fprintf(stderr, "socket-server : udp (%d) sendto error %s.\n",s->id, strerror(errno));
@@ -705,7 +712,7 @@ send_socket(struct socket_server *ss, struct request_send * request, struct sock
if (n<0) {
switch(errno) {
case EINTR:
case EAGAIN:
case AGAIN_WOULDBLOCK:
n = 0;
break;
default:
@@ -999,7 +1006,7 @@ forward_message_tcp(struct socket_server *ss, struct socket *s, struct socket_me
switch(errno) {
case EINTR:
break;
case EAGAIN:
case AGAIN_WOULDBLOCK:
fprintf(stderr, "socket-server: EAGAIN capture.\n");
break;
default:
@@ -1061,7 +1068,7 @@ forward_message_udp(struct socket_server *ss, struct socket *s, struct socket_me
if (n<0) {
switch(errno) {
case EINTR:
case EAGAIN:
case AGAIN_WOULDBLOCK:
break;
default:
// close when error