Skip to content

Commit

Permalink
Revert "selftests/bpf: Add select for send_recv_data"
Browse files Browse the repository at this point in the history
This reverts commit dee8fd8.
  • Loading branch information
Geliang Tang committed Apr 15, 2024
1 parent 2b77074 commit 27ab670
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions tools/testing/selftests/bpf/network_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,12 +594,9 @@ struct send_recv_arg {
static void *send_recv_server(void *arg)
{
struct send_recv_arg *a = (struct send_recv_arg *)arg;
struct timeval timeout = { .tv_sec = 3 };
ssize_t nr_sent = 0, bytes = 0;
char batch[1500];
int err = 0, fd;
fd_set wset;
int max_fd;

fd = accept(a->fd, NULL, NULL);
while (fd == -1) {
Expand All @@ -615,17 +612,6 @@ static void *send_recv_server(void *arg)
}

while (bytes < a->bytes && !READ_ONCE(a->stop)) {
/* FD sets */
FD_ZERO(&wset);
FD_SET(fd, &wset);
max_fd = fd;

if (select(max_fd + 1, NULL, &wset, NULL, &timeout) == -1) {
log_err("Failed to select");
err = -1;
break;
}

nr_sent = send(fd, &batch,
MIN(a->bytes - bytes, sizeof(batch)), 0);
if (nr_sent == -1 && errno == EINTR)
Expand Down Expand Up @@ -655,7 +641,6 @@ static void *send_recv_server(void *arg)

int send_recv_data(int lfd, int fd, uint32_t total_bytes)
{
struct timeval timeout = { .tv_sec = 3 };
ssize_t nr_recv = 0, bytes = 0;
struct send_recv_arg arg = {
.fd = lfd,
Expand All @@ -665,9 +650,7 @@ int send_recv_data(int lfd, int fd, uint32_t total_bytes)
pthread_t srv_thread;
void *thread_ret;
char batch[1500];
int max_fd = fd;
int err = 0;
fd_set rset;

err = pthread_create(&srv_thread, NULL, send_recv_server, (void *)&arg);
if (err) {
Expand All @@ -677,16 +660,6 @@ int send_recv_data(int lfd, int fd, uint32_t total_bytes)

/* recv total_bytes */
while (bytes < total_bytes && !READ_ONCE(arg.stop)) {
/* FD sets */
FD_ZERO(&rset);
FD_SET(fd, &rset);

if (select(max_fd + 1, &rset, NULL, NULL, &timeout) == -1) {
log_err("Failed to select");
err = -1;
break;
}

nr_recv = recv(fd, &batch,
MIN(total_bytes - bytes, sizeof(batch)), 0);
if (nr_recv == -1 && errno == EINTR)
Expand Down

0 comments on commit 27ab670

Please sign in to comment.