Commit 86b2aa15 authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Log fd and do proper ISSET test.

parent 1f047dff
Pipeline #2971 passed with stages
in 1 minute and 38 seconds
......@@ -122,14 +122,14 @@ static inline ssize_t _send(socket_t conn, const char *buf, size_t size)
tv.tv_sec = 1;
tv.tv_usec = 0;
retval = select(conn + 1, NULL, &wfds, NULL, &tv);
if (!FD_ISSET(conn, &wfds)) {
continue;
}
if (retval == -1) {
printf("Select failed: %d.\n", errno);
return -1;
} else if (retval > 0) {
if (!FD_ISSET(conn, &wfds)) {
printf("FD not set: %d\n", conn);
continue;
}
n = write(conn, buf, size - written);
if (n < 0) {
_time();
......@@ -164,9 +164,6 @@ static inline ssize_t _recv(socket_t conn, char *buf, size_t size)
tv.tv_sec = 1;
tv.tv_usec = 0;
retval = select(conn + 1, &rfds, NULL, NULL, &tv);
if (!FD_ISSET(conn, &rfds)) {
continue;
}
if (!keepRunning) {
printf("No longer running.\n");
return -1;
......@@ -176,6 +173,10 @@ static inline ssize_t _recv(socket_t conn, char *buf, size_t size)
printf("Select failed: %d.\n", errno);
return -1;
} else if (retval > 0) {
if (!FD_ISSET(conn, &rfds)) {
printf("FD not set: %d\n", conn);
continue;
}
n = recv(conn, buf, size - received, 0);
if (n < 0) {
_time();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment