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

Limit inbound connections. #271

Merged
merged 1 commit into from
Feb 11, 2025
Merged

Limit inbound connections. #271

merged 1 commit into from
Feb 11, 2025

Conversation

ioquatix
Copy link
Member

This is a PoC to demonstrate how to limit inbound connections.

Types of Changes

  • New feature.

Contribution

Comment on lines +51 to +55
server.wait_readable

# Acquire the semaphore:
Console.info(self, "Acquiring semaphore...")
token = semaphore.acquire
Copy link

@macournoyer macournoyer Feb 11, 2025

Choose a reason for hiding this comment

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

Should this be in a loop? For the case when it's readable, but the semaphore can't be acquire.

Suggested change
server.wait_readable
# Acquire the semaphore:
Console.info(self, "Acquiring semaphore...")
token = semaphore.acquire
token = loop do
server.wait_readable
# Acquire the semaphore:
Console.info(self, "Acquiring semaphore...")
break semaphore.try_acquire # acts like a acquire_nonblock, returns nil if not ready
end

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, that's an interesting point. I actually don't know the answer off the top of my head, I'll have to experiment and think about it a bit.

@ioquatix ioquatix merged commit ecb69fa into main Feb 11, 2025
86 of 92 checks passed
@ioquatix ioquatix deleted the connection-limiter branch February 11, 2025 22:40
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