I saw a case where poll(2) was blocking despite being passed an fd of -1.
Since that's clearly invalid, we can fail tcp_{read,write} before that
point.
Weird.
*/
int tcp_read(int sd, char *buf, int len) {
+ if (sd < 0)
+ return -1;
struct pollfd pfd;
pfd.fd = sd;
pfd.events = POLLIN | POLLHUP | POLLRDHUP | POLLNVAL | POLLERR;
}
int tcp_write(int sd, const char *buf, int len) {
+ if (sd < 0)
+ return -1;
struct pollfd pfd;
pfd.fd = sd;
pfd.events = POLLOUT | POLLHUP | POLLRDHUP | POLLNVAL | POLLERR;