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

SocketManager: Enable open(nil) to select path automatically #143

Merged
merged 1 commit into from
Mar 14, 2023

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Mar 12, 2023

I already created

but we need a more fundamental solution as discussed in #140.

This PR enables ServerEngine::SocketManager::Server.open(nil) to select path automatically.

Especially on Windows, it is hard to search an available port for path, so we should use this feature.
(The current generate_path logic sometimes chooses an unavailable port. For example, it does not consider the excluded port range.)

This fix keeps backward compatibility.

daipom added a commit to daipom/fluentd that referenced this pull request Mar 12, 2023
Use ServerEngine's new feature:

treasure-data/serverengine#143

On Windows, this prevents SocketManager from wrongly selecting an
unavailable port, such as a port in excluded port range.

Signed-off-by: Daijiro Fukuda <[email protected]>
@daipom
Copy link
Contributor Author

daipom commented Mar 13, 2023

Though quite late now, I'm starting to think this may be better...

def self.open(path)
new(path)
end

def self.open(path = nil)
  return new(path) unless path.nil?
  if ServerEngine.windows?
    new(0)
  else
    new(self.generate_path)
  end
end

@daipom
Copy link
Contributor Author

daipom commented Mar 13, 2023

Though quite late now, I'm starting to think this may be better...

def self.open(path)
new(path)
end

def self.open(path = nil)
  return new(path) unless path.nil?
  if ServerEngine.windows?
    new(0)
  else
    new(self.generate_path)
  end
end

What do you think? If so, I will fix.

README.md Outdated Show resolved Hide resolved
This `open(nil)` selects `path` automatically.

Especially on Windows, it is hard to search a available port for `path`,
so we should use this feature.
(The current `generate_path` logic sometimes chooses unavailable port.
For example, it does not consider the excluded port range.)

Note: This fix keeps backward compatibility.

Signed-off-by: Daijiro Fukuda <[email protected]>
@daipom daipom force-pushed the add-open-auto-path branch from 6c23c4a to 1155c73 Compare March 14, 2023 01:47
@daipom daipom changed the title SocketManager: Add open_auto_path to select path automatically SocketManager: Enable open(nil) to select path automatically Mar 14, 2023
daipom added a commit to daipom/fluentd that referenced this pull request Mar 14, 2023
Use ServerEngine's new feature:

treasure-data/serverengine#143

On Windows, this prevents SocketManager from wrongly selecting an
unavailable port, such as a port in excluded port range.

Signed-off-by: Daijiro Fukuda <[email protected]>
Copy link
Collaborator

@ashie ashie left a comment

Choose a reason for hiding this comment

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

LGTM

@ashie ashie merged commit 85d4dba into treasure-data:master Mar 14, 2023
@ashie
Copy link
Collaborator

ashie commented Mar 14, 2023

Thanks!

@daipom daipom deleted the add-open-auto-path branch March 14, 2023 02:50
@daipom
Copy link
Contributor Author

daipom commented Mar 14, 2023

Thanks for your review!

ashie pushed a commit to daipom/fluentd that referenced this pull request Mar 14, 2023
Use ServerEngine's new feature:

treasure-data/serverengine#143

On Windows, this prevents SocketManager from wrongly selecting an
unavailable port, such as a port in excluded port range.

Signed-off-by: Daijiro Fukuda <[email protected]>
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.

Windows: Apply excluded port range to SocketManager
2 participants