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

Use ulimit to Set Queue Size #53

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

technojoe
Copy link
Contributor

NOTE: This change needs testing.
 
Summary: Use returned value from getrlimit to dynamically allocate memory for client_cs, which removes the hardcoded, arbitrary limit of 1000. In effect, the ulimit for file descriptors becomes the maximum queue size, and ulimit is a system-configurable value.

Details:

  1. Changed "client_cs" from a global array to a global pointer, which allows malloc to be used later.
  2. Set "max" to an initial value of 1000, which is only used if getrlimit fails to return a value.
  3. Moved the getrlimit section to earlier within get_max_descriptors, so its return value could be used as a starting point.
  4. Added malloc for "client_cs" in server_main immediately after get_max_descriptors returns.
  5. Added free for "client_cs" in end_server.
  6. Removed enum MAXCONN, since it is no longer needed.

…ocate memory for client_cs, which removes the hardcoded, arbitrary limit of 1000.
@justanhduc justanhduc merged commit e604647 into justanhduc:master Dec 19, 2023
7 checks passed
@justanhduc
Copy link
Owner

Thanks @technojoe!

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