Commit d7575a751685f98d2c13a5e90531976a010487b3

Authored by Grzegorz Jabłoński
1 parent 0fa57cc3

Removed unneeded errno reset

Showing 1 changed file with 1 additions and 6 deletions
epoll4.c
@@ -138,14 +138,13 @@ void server_run() { @@ -138,14 +138,13 @@ void server_run() {
138 } else if (events[i].events & EPOLLIN) { 138 } else if (events[i].events & EPOLLIN) {
139 /* handle EPOLLIN event */ 139 /* handle EPOLLIN event */
140 for (;;) { 140 for (;;) {
141 - bzero(buf, sizeof(buf));  
142 - errno = 0;  
143 n = read(events[i].data.fd, buf, sizeof(buf) - 1); 141 n = read(events[i].data.fd, buf, sizeof(buf) - 1);
144 if (n == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) { 142 if (n == -1 && ((errno == EAGAIN) || (errno == EWOULDBLOCK))) {
145 break; 143 break;
146 } else if (n == 0) { 144 } else if (n == 0) {
147 break; 145 break;
148 } else { 146 } else {
  147 + buf[n] = '\0';
149 printf("[+] data: %s\n", buf); 148 printf("[+] data: %s\n", buf);
150 n = 0; 149 n = 0;
151 while (n != strlen(buf)) { 150 while (n != strlen(buf)) {
@@ -199,7 +198,6 @@ void client_run() { @@ -199,7 +198,6 @@ void client_run() {
199 198
200 n = 0; 199 n = 0;
201 while (n != c) { 200 while (n != c) {
202 - errno = 0;  
203 int rv = send(sockfd, buf + n, c - n, MSG_NOSIGNAL); 201 int rv = send(sockfd, buf + n, c - n, MSG_NOSIGNAL);
204 if (rv == -1 && (errno == EINTR)) 202 if (rv == -1 && (errno == EINTR))
205 continue; 203 continue;
@@ -208,11 +206,8 @@ void client_run() { @@ -208,11 +206,8 @@ void client_run() {
208 n += rv; 206 n += rv;
209 } 207 }
210 208
211 - errno = 0;  
212 -  
213 n = 0; 209 n = 0;
214 while (n != c) { 210 while (n != c) {
215 - errno = 0;  
216 int rv = read(sockfd, buf + n, c - n); 211 int rv = read(sockfd, buf + n, c - n);
217 if (rv == -1 && (errno == EINTR)) 212 if (rv == -1 && (errno == EINTR))
218 continue; 213 continue;