-
Notifications
You must be signed in to change notification settings - Fork 74
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
base: master
Are you sure you want to change the base?
Conversation
@olofhagsand, Good afternoon, I would really like to see this functionality. |
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] # Значение по умолчанию, если не указано |
There was a problem hiding this comment.
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]; |
There was a problem hiding this comment.
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; | ||
} |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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.
@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.