Commit a2c4be7c9b0a14024013e52f78a4a95bb11c1bae
1 parent
eeb7695e
Reacting on recv error
Showing
1 changed file
with
5 additions
and
1 deletions
epoll4.c
@@ -140,6 +140,9 @@ void server_run() { | @@ -140,6 +140,9 @@ void server_run() { | ||
140 | break; | 140 | break; |
141 | } else if (n == 0) { | 141 | } else if (n == 0) { |
142 | break; | 142 | break; |
143 | + } else if (n == -1) { | ||
144 | + perror("recv"); | ||
145 | + break; | ||
143 | } else { | 146 | } else { |
144 | buf[n] = '\0'; | 147 | buf[n] = '\0'; |
145 | printf("[+] data: %s\n", buf); | 148 | printf("[+] data: %s\n", buf); |
@@ -148,7 +151,8 @@ void server_run() { | @@ -148,7 +151,8 @@ void server_run() { | ||
148 | int rv = send(events[i].data.fd, buf + n, strlen(buf) - n, | 151 | int rv = send(events[i].data.fd, buf + n, strlen(buf) - n, |
149 | MSG_NOSIGNAL); | 152 | MSG_NOSIGNAL); |
150 | if (rv == -1 && (errno == EINTR)) | 153 | if (rv == -1 && (errno == EINTR)) |
151 | - continue; // FIXME: might lock up due to client not receiving - should wait using epoll | 154 | + continue; // FIXME: might lock up due to client not receiving - |
155 | + // should wait using epoll | ||
152 | if (rv == -1) | 156 | if (rv == -1) |
153 | break; | 157 | break; |
154 | n += rv; | 158 | n += rv; |