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