Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace in clixon_event_loop select to poll #589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khromenokroman
Copy link
Contributor

@olofhagsand in continuation of the previous pull request #584
I replaced it in the main loop too, and moved the number of events to the configuration file.

./configure --with-max-events=2048 --enable-event-poll

@khromenokroman
Copy link
Contributor Author

@olofhagsand, Good afternoon, I would really like to see this functionality.

@olofhagsand
Copy link
Member

Will look shortly

@khromenokroman
Copy link
Contributor Author

Will look shortly

@olofhagsand Thanks :)

AC_ARG_WITH([max-events],
AS_HELP_STRING([--with-max-events=VALUE], [Set the maximum number of events (default: 1024)]),
[MAX_EVENTS=$withval],
[MAX_EVENTS=1024] # Значение по умолчанию, если не указано
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use english (more places)

clixon_event_loop(clixon_handle h)
{
struct event_data *e = NULL;
struct pollfd fds[MAX_EVENTS];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: struct event_data *e = NULL; (indentation on the variable "e", not on the struct name "event_data"

}
free(e);
continue;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "continue" statement may cause starvation so that only timeouts run. This can happen for example if a timeout registers itself, and then causes a loop that only serves timeouts, causing a deadlock.
Typically if the new timeout due to overload has already timed out.
This is the way it works in select at least, I am not sure if poll is different.
Removing continue will first serve one timeout, then serve file descriptors.
It is not 100% fair either but at least interleaving timeouts with file input removes some deadlocks.

continue;
}

for (int i = 0; i < nfds; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also removed the primitive CLICON_SOCK_PRIO algorithm.
It is somewhat primitive but at least avoided the same kind of deadlock as timeouts could cause. That is, if there is a prioritized file, then at most one un-prioritized file is served.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants