Skip to content

Commit

Permalink
MORE WORK
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldsharp committed Nov 2, 2023
1 parent 0ea5635 commit 6ead446
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1654,17 +1654,26 @@ static inline void thread_process_io_inner_loop(struct event_loop *m, unsigned i
* Walks through file descriptor array looking for those pollfds whose .revents
* field has something interesting. Deletes any invalid file descriptors.
*
* Try to impart some impartiality to handling of reads. The event
* system will cycle through the fd's available for being read
* giving each one a chance to go first.
*
* @param m the thread master
* @param num the number of active file descriptors (return value of poll())
*/
static void thread_process_io(struct event_loop *m, unsigned int num)
{
unsigned int ready = 0;
struct pollfd *pfds = m->handler.copy;
nfds_t last_read = m->last_read & m->handler.copycount;

for (nfds_t i = 0; i < m->handler.copycount && ready < num; ++i) {
thread_process_io_inner_loop(m, num, pfds, &i, &ready);
}
for (nfds_t i = last_read; i < m->handler.copycount && ready < num; ++i)
thread_process_io_inner_loop(m, num, pfds, &i, &ready);

for (nfds_t i = 0; i < last_read && ready < num; ++i)
thread_process_io_inner_loop(m, num, pfds, &i, &ready);

m->last_read++;
}

/* Add all timers that have popped to the ready list. */
Expand Down
2 changes: 2 additions & 0 deletions lib/frrevent.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ struct event_loop {
pthread_mutex_t mtx;
pthread_t owner;

nfds_t last_read;

bool ready_run_loop;
RUSAGE_T last_getrusage;
};
Expand Down

0 comments on commit 6ead446

Please sign in to comment.