Skip to content
This repository was archived by the owner on Jun 30, 2020. It is now read-only.

Use recv/send for non-stdio in the test tooling #30

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion bin/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ on_conn(options_t *opts, int con, int in, int out, const struct addrinfo *ai)
if (!pfds[i].revents)
continue;

ret = read(pfds[i].fd, buffer, sizeof(buffer));
if (pfds[i].fd <= 2)
ret = read(pfds[i].fd, buffer, sizeof(buffer));
else
ret = recv(pfds[i].fd, buffer, sizeof(buffer), 0);
if (ret <= 0) {
if (pfds[i].revents != POLLHUP &&
(errno == EAGAIN || errno == EWOULDBLOCK))
Expand Down
5 changes: 4 additions & 1 deletion bin/non.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ non_write(int fd, void *buf, size_t len)
uint8_t *b = buf;
ssize_t ret;

ret = write(fd, buf, len);
if (fd <= 2)
ret = write(fd, buf, len);
else
ret = send(fd, buf, len, 0);
if (ret < 0) {
if (errno != EAGAIN)
return ret;
Expand Down