Skip to content

Commit

Permalink
optimize select hash loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sreimers committed Jan 26, 2023
1 parent c640279 commit c168893
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,18 +761,17 @@ static int fd_poll(struct re *re)

int index = 0;
int max_fd = 0;

uint32_t bsize = hash_bsize(re->fhl);
for (uint32_t i = 0; i < bsize; i++) {
LIST_FOREACH(hash_list_idx(re->fhl, i), he)
{
he = hash_list_idx(re->fhl, i)->head;
while (he) {
struct fhs *fhs = he->data;
he = he->next;

if (!fhs->flags)
continue;

if (index >= DEFAULT_MAXFDS)
return EMFILE;

sfds[index] = fhs->fd;

if (fhs->flags & FD_READ)
Expand All @@ -786,6 +785,9 @@ static int fd_poll(struct re *re)
#endif
++index;
}

if (index >= nfds)
break;
}

#ifdef WIN32
Expand Down

0 comments on commit c168893

Please sign in to comment.